Skip to content

Commit

Permalink
Merge pull request #1 from thebeast1/master
Browse files Browse the repository at this point in the history
fix: remove REQUEST_INSTALL_PACKAGES permission.
  • Loading branch information
javaherisaber authored Oct 25, 2022
2 parents 9a95e90 + ab32fd0 commit 304691e
Showing 1 changed file with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 304691e

Please sign in to comment.