diff options
author | Philip P. Moltmann <moltmann@google.com> | 2016-10-17 20:50:45 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-10-17 20:50:45 +0000 |
commit | 85a0e77511552222b79b6dde17923788e0ae21bf (patch) | |
tree | a25e5097800f2e36f41a6ffdbf0cf6e238526d40 /src/com | |
parent | ee9254afcfe3cb3ed513ca0b6b0d851ebdaca005 (diff) | |
parent | df52c788dab741a070d195de2fe6cc9edc1f404c (diff) | |
download | android_packages_apps_PackageInstaller-85a0e77511552222b79b6dde17923788e0ae21bf.tar.gz android_packages_apps_PackageInstaller-85a0e77511552222b79b6dde17923788e0ae21bf.tar.bz2 android_packages_apps_PackageInstaller-85a0e77511552222b79b6dde17923788e0ae21bf.zip |
Support install once feature.
am: df52c788da
Change-Id: I2444b6612f988b5ac8ff6de351ef53f3b9516255
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/packageinstaller/PackageInstallerActivity.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java index cf264d12..55a1f814 100644 --- a/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -327,7 +327,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen // whether the untrusted sources setting is on. This allows partners to // implement a "allow untrusted source once" feature. if (request == REQUEST_ENABLE_UNKNOWN_SOURCES && result == RESULT_OK) { - checkIfAllowedAndInitiateInstall(); + checkIfAllowedAndInitiateInstall(true); } else { clearCachedApkIfNeededAndFinish(); } @@ -462,14 +462,17 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen return; } - checkIfAllowedAndInitiateInstall(); + checkIfAllowedAndInitiateInstall(false); } /** * Check if it is allowed to install the package and initiate install if allowed. If not allowed * show the appropriate dialog. + * + * @param ignoreUnknownSourcesSettings Ignore {@link #isUnknownSourcesEnabled()} and proceed + * even if this would prevented installation. */ - private void checkIfAllowedAndInitiateInstall() { + private void checkIfAllowedAndInitiateInstall(boolean ignoreUnknownSourcesSettings) { // Block the install attempt on the Unknown Sources setting if necessary. final boolean requestFromUnknownSource = isInstallRequestFromUnknownSource(getIntent()); if (!requestFromUnknownSource) { @@ -482,7 +485,11 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen if (isUnknownSourcesDisallowed()) { if ((mUserManager.getUserRestrictionSource(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, Process.myUserHandle()) & UserManager.RESTRICTION_SOURCE_SYSTEM) != 0) { - showDialogInner(DLG_UNKNOWN_SOURCES); + if (ignoreUnknownSourcesSettings) { + initiateInstall(); + } else { + showDialogInner(DLG_UNKNOWN_SOURCES); + } } else { startActivity(new Intent(Settings.ACTION_SHOW_ADMIN_SUPPORT_DETAILS)); clearCachedApkIfNeededAndFinish(); @@ -490,9 +497,12 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen } else if (!isUnknownSourcesEnabled() && isManagedProfile) { showDialogInner(DLG_ADMIN_RESTRICTS_UNKNOWN_SOURCES); } else if (!isUnknownSourcesEnabled()) { - // Ask user to enable setting first - - showDialogInner(DLG_UNKNOWN_SOURCES); + if (ignoreUnknownSourcesSettings) { + initiateInstall(); + } else { + // Ask user to enable setting first + showDialogInner(DLG_UNKNOWN_SOURCES); + } } else { initiateInstall(); } @@ -801,7 +811,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen boolean wasSetUp = processPackageUri(fileUri); if (wasSetUp) { - checkIfAllowedAndInitiateInstall(); + checkIfAllowedAndInitiateInstall(false); } } |