[app] don't show repeated unknown sources screen when installing apps

by limiting the use of PackageManager#canRequestPackageInstalls() method to flavors targeting at least O
This commit is contained in:
Torsten Grote
2023-05-31 17:41:45 -03:00
parent 137182aab5
commit 91bbfd4cf0

View File

@@ -50,8 +50,9 @@ public class DefaultInstaller extends Installer {
@Override
protected void installPackageInternal(Uri localApkUri, Uri canonicalUri) {
// ask to enable unknown sources on old Android versions
if (Build.VERSION.SDK_INT >= 26 && Build.VERSION.SDK_INT < 31) {
// ask to enable unknown sources on old Android versions (needs to target at least 26 for this to work)
if (Build.VERSION.SDK_INT >= 26 && Build.VERSION.SDK_INT < 31 &&
context.getApplicationInfo().targetSdkVersion >= 26) {
if (!context.getPackageManager().canRequestPackageInstalls()) {
Intent i = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);