# HG changeset patch # User Carl Byington # Date 1654643092 25200 # Node ID 267e72057707f24e03df76ff0d606fcba3e586bd # Parent 3feac274a27b2a400497080831d7e1d5c82ed0aa updates for android10+ diff -r 3feac274a27b -r 267e72057707 app/src/main/AndroidManifest.xml --- a/app/src/main/AndroidManifest.xml Mon Jun 06 15:05:20 2022 -0700 +++ b/app/src/main/AndroidManifest.xml Tue Jun 07 16:04:52 2022 -0700 @@ -16,113 +16,114 @@ limitations under the License. --> + package="com.five_ten_sg.connectbot" + android:versionName="1.9.4-4" + android:versionCode="1944" + android:installLocation="auto"> - - - - - + + + + + + - - - - + + + - - - - + - + - + android:usesCleartextTraffic="true" + android:icon="@drawable/icon" + android:label="@string/app_name" + android:description="@string/app_desc" + android:allowBackup="false" + android:backupAgent=".service.BackupAgent" + android:killAfterRestore="true"> - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + diff -r 3feac274a27b -r 267e72057707 app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java --- a/app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java Mon Jun 06 15:05:20 2022 -0700 +++ b/app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java Tue Jun 07 16:04:52 2022 -0700 @@ -176,27 +176,14 @@ // ask for permissions, must match AndroidManifest.xml if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - String [] perms = {Manifest.permission.INTERNET, - Manifest.permission.ACCESS_NETWORK_STATE, - Manifest.permission.WAKE_LOCK}; - checkp(perms); + get_permissions(new String[] {Manifest.permission.ACCESS_NETWORK_STATE, + Manifest.permission.INTERNET, + Manifest.permission.WAKE_LOCK}); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - if (!Environment.isExternalStorageManager()) { - try { - Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); - intent.addCategory("android.intent.category.DEFAULT"); - intent.setData(Uri.parse(String.format("package:%s",getApplicationContext().getPackageName()))); - startActivity(intent); - } catch (Exception e) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); - startActivity(intent); - } - } + get_storage_manager(); } else { - String [] perms2 = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; - checkp(perms2); + get_permissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}); } } @@ -291,7 +278,34 @@ } } - public void checkp(String [] perms) { + public void get_storage_manager() { + if (!Environment.isExternalStorageManager()) { + try { + Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); + intent.addCategory("android.intent.category.DEFAULT"); + intent.setData(Uri.parse(String.format("package:%s",getApplicationContext().getPackageName()))); + startActivityForResult(intent, 31415); + } catch (Exception e) { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); + startActivityForResult(intent, 31415); + } + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 31415) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if (!Environment.isExternalStorageManager()) { + Toast.makeText(this, "Allow permission for storage access!", Toast.LENGTH_SHORT).show(); + } + } + } + } + + public void get_permissions(String [] perms) { boolean need = false; for (String perm : perms) { if (ContextCompat.checkSelfPermission(this, perm) != PackageManager.PERMISSION_GRANTED) {