diff options
-rw-r--r-- | src/com/android/packageinstaller/PackageInstallerActivity.java | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java index 50ef0bf0..cf264d12 100644 --- a/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -120,6 +120,9 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen private static final int DLG_NOT_SUPPORTED_ON_WEAR = DLG_BASE + 7; private void startInstallConfirm() { + ((TextView) findViewById(R.id.install_confirm_question)) + .setText(R.string.install_confirm_question); + findViewById(R.id.spacer).setVisibility(View.GONE); TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setVisibility(View.VISIBLE); @@ -324,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) { - initiateInstall(); + checkIfAllowedAndInitiateInstall(); } else { clearCachedApkIfNeededAndFinish(); } @@ -454,11 +457,23 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen mOk.setOnClickListener(this); mCancel.setOnClickListener(this); + boolean wasSetUp = processPackageUri(packageUri); + if (!wasSetUp) { + return; + } + + checkIfAllowedAndInitiateInstall(); + } + + /** + * Check if it is allowed to install the package and initiate install if allowed. If not allowed + * show the appropriate dialog. + */ + private void checkIfAllowedAndInitiateInstall() { // Block the install attempt on the Unknown Sources setting if necessary. - final boolean requestFromUnknownSource = isInstallRequestFromUnknownSource(intent); + final boolean requestFromUnknownSource = isInstallRequestFromUnknownSource(getIntent()); if (!requestFromUnknownSource) { - processPackageUri(packageUri); - return; + initiateInstall(); } // If the admin prohibits it, or we're running in a managed profile, just show error @@ -479,7 +494,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen showDialogInner(DLG_UNKNOWN_SOURCES); } else { - processPackageUri(packageUri); + initiateInstall(); } } @@ -492,7 +507,14 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen super.onDestroy(); } - private void processPackageUri(final Uri packageUri) { + /** + * Parse the Uri and set up the installer for this package. + * + * @param packageUri The URI to parse + * + * @return {@code true} iff the installer could be set up + */ + private boolean processPackageUri(final Uri packageUri) { mPackageURI = packageUri; final String scheme = packageUri.getScheme(); @@ -511,7 +533,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen + " not available. Discontinuing installation"); showDialogInner(DLG_PACKAGE_ERROR); setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK); - return; + return false; } as = new PackageUtil.AppSnippet(mPm.getApplicationLabel(mPkgInfo.applicationInfo), mPm.getApplicationIcon(mPkgInfo.applicationInfo)); @@ -526,7 +548,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen Log.w(TAG, "Parse error when parsing manifest. Discontinuing installation"); showDialogInner(DLG_PACKAGE_ERROR); setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK); - return; + return false; } mPkgInfo = PackageParser.generatePackageInfo(parsed, null, PackageManager.GET_PERMISSIONS, 0, 0, null, @@ -537,20 +559,20 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen case SCHEME_CONTENT: { mStagingAsynTask = new StagingAsyncTask(); mStagingAsynTask.execute(packageUri); - return; + return false; } default: { Log.w(TAG, "Unsupported scheme " + scheme); setPmResult(PackageManager.INSTALL_FAILED_INVALID_URI); clearCachedApkIfNeededAndFinish(); - return; + return false; } } PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet); - initiateInstall(); + return true; } /** Get the ApplicationInfo for the calling package, if available */ @@ -776,7 +798,11 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen } mContentUriApkStagingFile = file; Uri fileUri = Uri.fromFile(file); - processPackageUri(fileUri); + + boolean wasSetUp = processPackageUri(fileUri); + if (wasSetUp) { + checkIfAllowedAndInitiateInstall(); + } } @Override |