summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/PackageInstallerActivity.java
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2016-10-20 10:12:09 -0700
committerPhilip P. Moltmann <moltmann@google.com>2016-10-28 12:35:20 -0700
commitf48b92a58f99e7e6f34c7aec586ab0cc83edec3d (patch)
tree7c75e769da2c1fcec43868598ab743749291540a /src/com/android/packageinstaller/PackageInstallerActivity.java
parent03c6b224b93910624759a97343e81786df6b9ee8 (diff)
downloadandroid_packages_apps_PackageInstaller-f48b92a58f99e7e6f34c7aec586ab0cc83edec3d.tar.gz
android_packages_apps_PackageInstaller-f48b92a58f99e7e6f34c7aec586ab0cc83edec3d.tar.bz2
android_packages_apps_PackageInstaller-f48b92a58f99e7e6f34c7aec586ab0cc83edec3d.zip
Split start triaging from confirm activity.
Before the PackageInstallerActivity had two duties: - Select if we needed to stage and then launch the stage activity - Let the user confirm the installation This change splits the first one out into the InstallStart activity. Also: - Only show window animation in first activity, suppress otherwise - Corectly read and persist source/caller information in start and later just read it from the intent. Test: Installed an app Change-Id: Iea94ddca1162d8f90a8d0bf7d21974fee883b199
Diffstat (limited to 'src/com/android/packageinstaller/PackageInstallerActivity.java')
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java113
1 files changed, 8 insertions, 105 deletions
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 93e85b30..08926faf 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -17,7 +17,6 @@
package com.android.packageinstaller;
import android.app.Activity;
-import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
@@ -67,10 +66,10 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
private static final int REQUEST_ENABLE_UNKNOWN_SOURCES = 1;
private static final String SCHEME_FILE = "file";
- private static final String SCHEME_CONTENT = "content";
private static final String SCHEME_PACKAGE = "package";
- private static final String EXTRA_ORIGINAL_SOURCE_INFO = "EXTRA_ORIGINAL_SOURCE_INFO";
+ static final String EXTRA_CALLING_PACKAGE = "EXTRA_CALLING_PACKAGE";
+ static final String EXTRA_ORIGINAL_SOURCE_INFO = "EXTRA_ORIGINAL_SOURCE_INFO";
private int mSessionId = -1;
private Uri mPackageURI;
@@ -83,6 +82,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
UserManager mUserManager;
PackageInstaller mInstaller;
PackageInfo mPkgInfo;
+ String mCallingPackage;
ApplicationInfo mSourceInfo;
// ApplicationInfo object primarily used for already existing applications
@@ -325,8 +325,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
}
private boolean isInstallRequestFromUnknownSource(Intent intent) {
- String callerPackage = getCallingPackage();
- if (callerPackage != null && intent.getBooleanExtra(
+ if (mCallingPackage != null && intent.getBooleanExtra(
Intent.EXTRA_NOT_UNKNOWN_SOURCE, false)) {
if (mSourceInfo != null) {
if ((mSourceInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED)
@@ -399,15 +398,10 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
final Intent intent = getIntent();
- // This activity might have been started by InstallStaging. In this case recover
- // the info from the app that initiated the install request
- if (getPackageName().equals(getCallingPackage())) {
- mSourceInfo = getIntent().getParcelableExtra(EXTRA_ORIGINAL_SOURCE_INFO);
- } else {
- mSourceInfo = getSourceInfo();
- }
-
- mOriginatingUid = getOriginatingUid(intent);
+ mCallingPackage = intent.getStringExtra(EXTRA_CALLING_PACKAGE);
+ mSourceInfo = intent.getParcelableExtra(EXTRA_ORIGINAL_SOURCE_INFO);
+ mOriginatingUid = intent.getIntExtra(Intent.EXTRA_ORIGINATING_UID,
+ VerificationParams.NO_UID);
final Uri packageUri;
@@ -514,11 +508,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
}
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- }
-
/**
* Parse the Uri and set up the installer for this package.
*
@@ -567,21 +556,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
mAppSnippet = PackageUtil.getAppSnippet(this, mPkgInfo.applicationInfo, sourceFile);
} break;
- case SCHEME_CONTENT: {
- Intent installStaging = new Intent(getIntent());
- installStaging.setClass(this, InstallStaging.class);
-
- // Store UID which might not be set in original intent
- installStaging.putExtra(Intent.EXTRA_ORIGINATING_UID, mOriginatingUid);
-
- // Store source info as when called back the source is the packageinstaller
- installStaging.putExtra(EXTRA_ORIGINAL_SOURCE_INFO, mSourceInfo);
- installStaging.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- startActivity(installStaging);
- finish();
- return false;
- }
-
default: {
Log.w(TAG, "Unsupported scheme " + scheme);
setPmResult(PackageManager.INSTALL_FAILED_INVALID_URI);
@@ -593,77 +567,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
return true;
}
- /** Get the ApplicationInfo for the calling package, if available */
- private ApplicationInfo getSourceInfo() {
- String callingPackage = getCallingPackage();
- if (callingPackage != null) {
- try {
- return mPm.getApplicationInfo(callingPackage, 0);
- } catch (NameNotFoundException ex) {
- // ignore
- }
- }
- return null;
- }
-
-
- /** Get the originating uid if possible, or VerificationParams.NO_UID if not available */
- private int getOriginatingUid(Intent intent) {
- // The originating uid from the intent. We only trust/use this if it comes from a
- // system application
- int uidFromIntent = intent.getIntExtra(Intent.EXTRA_ORIGINATING_UID,
- VerificationParams.NO_UID);
-
- // Get the source info from the calling package, if available. This will be the
- // definitive calling package, but it only works if the intent was started using
- // startActivityForResult,
- if (mSourceInfo != null) {
- if (uidFromIntent != VerificationParams.NO_UID &&
- (mSourceInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) {
- return uidFromIntent;
-
- }
- // We either didn't get a uid in the intent, or we don't trust it. Use the
- // uid of the calling package instead.
- return mSourceInfo.uid;
- }
-
- // We couldn't get the specific calling package. Let's get the uid instead
- int callingUid;
- try {
- callingUid = ActivityManagerNative.getDefault()
- .getLaunchedFromUid(getActivityToken());
- } catch (android.os.RemoteException ex) {
- Log.w(TAG, "Could not determine the launching uid.");
- // nothing else we can do
- return VerificationParams.NO_UID;
- }
-
- // If we got a uid from the intent, we need to verify that the caller is a
- // privileged system package before we use it
- if (uidFromIntent != VerificationParams.NO_UID) {
- String[] callingPackages = mPm.getPackagesForUid(callingUid);
- if (callingPackages != null) {
- for (String packageName: callingPackages) {
- try {
- ApplicationInfo applicationInfo =
- mPm.getApplicationInfo(packageName, 0);
-
- if ((applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED)
- != 0) {
- return uidFromIntent;
- }
- } catch (NameNotFoundException ex) {
- // ignore it, and try the next package
- }
- }
- }
- }
- // We either didn't get a uid from the intent, or we don't trust it. Use the
- // calling uid instead.
- return callingUid;
- }
-
@Override
public void onBackPressed() {
if (mSessionId != -1) {