summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2014-03-24 16:25:51 -0700
committerChristopher Tate <ctate@google.com>2014-03-27 12:37:47 -0700
commitf1977b4500e82b72ea6aa5c46d97406a20017caf (patch)
tree9d6b4e63bc4b4c70eb9fbd5eb2cff9587ba45485 /cmds/pm
parent9ad8a5331ca5eb6390c702ec57952043b56170bf (diff)
downloadframeworks_base-f1977b4500e82b72ea6aa5c46d97406a20017caf.zip
frameworks_base-f1977b4500e82b72ea6aa5c46d97406a20017caf.tar.gz
frameworks_base-f1977b4500e82b72ea6aa5c46d97406a20017caf.tar.bz2
Expand install observer semantics
...and now fail conservatively when two apps both attempt to define the same permission. Apps signed with the same certificate are permitted to redefine permissions. We also finally have a (hidden) interface class for observing package installation so that we can now rev the interface without breaking existing callers. Bug 13551375 Change-Id: Ifa4e59154dcccbb286ee46a35a6f25e4ad0f0f01
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index d513a10..f415c85 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -25,7 +25,7 @@ import android.content.pm.ContainerEncryptionParams;
import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageDeleteObserver;
-import android.content.pm.IPackageInstallObserver;
+import android.content.pm.IPackageInstallObserver2;
import android.content.pm.IPackageManager;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
@@ -39,6 +39,7 @@ import android.content.pm.VerificationParams;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.net.Uri;
+import android.os.Bundle;
import android.os.IUserManager;
import android.os.Process;
import android.os.RemoteException;
@@ -700,14 +701,23 @@ public final class Pm {
ActivityManager.dumpPackageStateStatic(FileDescriptor.out, pkg);
}
- class PackageInstallObserver extends IPackageInstallObserver.Stub {
+ class PackageInstallObserver extends IPackageInstallObserver2.Stub {
boolean finished;
int result;
+ String extraPermission;
+ String extraPackage;
- public void packageInstalled(String name, int status) {
+ @Override
+ public void packageInstalled(String name, Bundle extras, int status) {
synchronized( this) {
finished = true;
result = status;
+ if (status == PackageManager.INSTALL_FAILED_DUPLICATE_PERMISSION) {
+ extraPermission = extras.getString(
+ PackageManager.EXTRA_FAILURE_EXISTING_PERMISSION);
+ extraPackage = extras.getString(
+ PackageManager.EXTRA_FAILURE_EXISTING_PACKAGE);
+ }
notifyAll();
}
}
@@ -717,7 +727,8 @@ public final class Pm {
* Converts a failure code into a string by using reflection to find a matching constant
* in PackageManager.
*/
- private String installFailureToString(int result) {
+ private String installFailureToString(PackageInstallObserver obs) {
+ final int result = obs.result;
Field[] fields = PackageManager.class.getFields();
for (Field f: fields) {
if (f.getType() == int.class) {
@@ -732,7 +743,16 @@ public final class Pm {
// get the int value and compare it to result.
try {
if (result == f.getInt(null)) {
- return fieldName;
+ StringBuilder sb = new StringBuilder(64);
+ sb.append(fieldName);
+ if (obs.extraPermission != null) {
+ sb.append(" perm=");
+ sb.append(obs.extraPermission);
+ }
+ if (obs.extraPackage != null) {
+ sb.append(" pkg=" + obs.extraPackage);
+ }
+ return sb.toString();
}
} catch (IllegalAccessException e) {
// this shouldn't happen since we only look for public static fields.
@@ -956,7 +976,7 @@ public final class Pm {
VerificationParams verificationParams = new VerificationParams(verificationURI,
originatingURI, referrerURI, VerificationParams.NO_UID, null);
- mPm.installPackageWithVerificationAndEncryption(apkURI, obs, installFlags,
+ mPm.installPackageWithVerificationAndEncryptionEtc(apkURI, null, obs, installFlags,
installerPackageName, verificationParams, encryptionParams);
synchronized (obs) {
@@ -970,7 +990,7 @@ public final class Pm {
System.out.println("Success");
} else {
System.err.println("Failure ["
- + installFailureToString(obs.result)
+ + installFailureToString(obs)
+ "]");
}
}