From 50feb72dd2d8e67b2ab053fd169284caf9c0cd55 Mon Sep 17 00:00:00 2001 From: MOo_Reda Date: Sun, 9 Oct 2022 14:20:59 +0200 Subject: [PATCH 1/2] fix: remove REQUEST_INSTALL_PACKAGES permission. --- .../crazecoder/openfile/OpenFilePlugin.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java b/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java index f31c7e8c..8d08f9a2 100644 --- a/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java +++ b/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java @@ -353,25 +353,25 @@ private String getFileType(String filePath) { @RequiresApi(api = Build.VERSION_CODES.M) private void openApkFile() { - if (!canInstallApk()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - startInstallPermissionSettingActivity(); - } else { - ActivityCompat.requestPermissions(activity, - new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES}, REQUEST_CODE); - } - } else { +// if (!canInstallApk()) { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { +// startInstallPermissionSettingActivity(); +// } else { +// ActivityCompat.requestPermissions(activity, +// new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES}, REQUEST_CODE); +// } +// } else { startActivity(); - } +// } } - @RequiresApi(api = Build.VERSION_CODES.M) - private boolean canInstallApk() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - return activity.getPackageManager().canRequestPackageInstalls(); - } - return hasPermission(Manifest.permission.REQUEST_INSTALL_PACKAGES); - } +// @RequiresApi(api = Build.VERSION_CODES.M) +// private boolean canInstallApk() { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { +// return activity.getPackageManager().canRequestPackageInstalls(); +// } +// return hasPermission(Manifest.permission.REQUEST_INSTALL_PACKAGES); +// } @RequiresApi(api = Build.VERSION_CODES.O) private void startInstallPermissionSettingActivity() { @@ -406,11 +406,11 @@ public boolean onRequestPermissionsResult(int requestCode, String[] strings, int @Override public boolean onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == RESULT_CODE) { - if (canInstallApk()) { +// if (canInstallApk()) { startActivity(); - } else { - result(-3, "Permission denied: " + Manifest.permission.REQUEST_INSTALL_PACKAGES); - } +// } else { +// result(-3, "Permission denied: " + Manifest.permission.REQUEST_INSTALL_PACKAGES); +// } } return false; } From ab32fd043b860319a7b99660e403ea51a0514995 Mon Sep 17 00:00:00 2001 From: Mohamed Reda <33456197+thebeast1@users.noreply.github.com> Date: Thu, 13 Oct 2022 00:36:19 +0200 Subject: [PATCH 2/2] remove the commented permission --- .../crazecoder/openfile/OpenFilePlugin.java | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java b/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java index 8d08f9a2..0667e9c5 100644 --- a/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java +++ b/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java @@ -353,25 +353,10 @@ private String getFileType(String filePath) { @RequiresApi(api = Build.VERSION_CODES.M) private void openApkFile() { -// if (!canInstallApk()) { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { -// startInstallPermissionSettingActivity(); -// } else { -// ActivityCompat.requestPermissions(activity, -// new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES}, REQUEST_CODE); -// } -// } else { startActivity(); -// } } -// @RequiresApi(api = Build.VERSION_CODES.M) -// private boolean canInstallApk() { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { -// return activity.getPackageManager().canRequestPackageInstalls(); -// } -// return hasPermission(Manifest.permission.REQUEST_INSTALL_PACKAGES); -// } + @RequiresApi(api = Build.VERSION_CODES.O) private void startInstallPermissionSettingActivity() { @@ -406,11 +391,7 @@ public boolean onRequestPermissionsResult(int requestCode, String[] strings, int @Override public boolean onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == RESULT_CODE) { -// if (canInstallApk()) { startActivity(); -// } else { -// result(-3, "Permission denied: " + Manifest.permission.REQUEST_INSTALL_PACKAGES); -// } } return false; }