diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2015-07-29 17:54:23 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-29 17:54:23 +0000 |
commit | 9352af2a9ef95e3f577a04474625249d3da62a04 (patch) | |
tree | b4f13ca45bea5c9fdac99b42dd91c7b948593e92 | |
parent | 6b96de8dae8be99f75c86c795672905e10fca153 (diff) | |
parent | f1b7f20bb839c96e8254ccb65398135f10fd45d9 (diff) | |
download | frameworks_base-9352af2a9ef95e3f577a04474625249d3da62a04.zip frameworks_base-9352af2a9ef95e3f577a04474625249d3da62a04.tar.gz frameworks_base-9352af2a9ef95e3f577a04474625249d3da62a04.tar.bz2 |
Merge "Remove dependencies on the package installer's package name" into mnc-dev
7 files changed, 53 insertions, 11 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 1fb0b2a..dbe91f9 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -110,6 +110,9 @@ final class ApplicationPackageManager extends PackageManager { @GuardedBy("mDelegates") private final ArrayList<MoveCallbackDelegate> mDelegates = new ArrayList<>(); + @GuardedBy("mLock") + private String mPermissionsControllerPackageName; + UserManager getUserManager() { synchronized (mLock) { if (mUserManager == null) { @@ -429,6 +432,23 @@ final class ApplicationPackageManager extends PackageManager { } } + /** + * @hide + */ + @Override + public String getPermissionControllerPackageName() { + synchronized (mLock) { + if (mPermissionsControllerPackageName == null) { + try { + mPermissionsControllerPackageName = mPM.getPermissionControllerPackageName(); + } catch (RemoteException e) { + throw new RuntimeException("Package manager has died", e); + } + } + return mPermissionsControllerPackageName; + } + } + @Override public boolean addPermission(PermissionInfo info) { try { diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index bc24d67..0336645 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -505,4 +505,6 @@ interface IPackageManager { void grantDefaultPermissionsToEnabledCarrierApps(in String[] packageNames, int userId); boolean isPermissionRevokedByPolicy(String permission, String packageName, int userId); + + String getPermissionControllerPackageName(); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index cda5816..0f936fd 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -1876,14 +1876,6 @@ public abstract class PackageManager { "android.content.pm.action.REQUEST_PERMISSIONS"; /** - * The component name handling runtime permission grants. - * - * @hide - */ - public static final String GRANT_PERMISSIONS_PACKAGE_NAME = - "com.android.packageinstaller"; - - /** * The names of the requested permissions. * <p> * <strong>Type:</strong> String[] @@ -2431,7 +2423,17 @@ public abstract class PackageManager { * @return Whether the permission is restricted by policy. */ @CheckResult - public abstract boolean isPermissionRevokedByPolicy(String permName, String pkgName); + public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, + @NonNull String pkgName); + + /** + * Gets the package name of the component controlling runtime permissions. + * + * @return The package name. + * + * @hide + */ + public abstract String getPermissionControllerPackageName(); /** * Add a new dynamic permission to the system. For this to work, your @@ -2615,7 +2617,7 @@ public abstract class PackageManager { } Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); - intent.setPackage(GRANT_PERMISSIONS_PACKAGE_NAME); + intent.setPackage(getPermissionControllerPackageName()); return intent; } diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index b5ef3b7..4a473fd 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -489,7 +489,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { // User needs to accept permissions; give installer an intent they // can use to involve user. final Intent intent = new Intent(PackageInstaller.ACTION_CONFIRM_PERMISSIONS); - intent.setPackage("com.android.packageinstaller"); + intent.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()); intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId); try { mRemoteObserver.onUserActionRequired(intent); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index e6ce16e..98137f8 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3195,6 +3195,13 @@ public class PackageManagerService extends IPackageManager.Stub { } } + @Override + public String getPermissionControllerPackageName() { + synchronized (mPackages) { + return mRequiredInstallerPackage; + } + } + /** * Checks if the request is from the system or an app that has INTERACT_ACROSS_USERS * or INTERACT_ACROSS_USERS_FULL permissions, if the userid is not for the caller. diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java index 3df7bbc..1ff621a 100644 --- a/test-runner/src/android/test/mock/MockPackageManager.java +++ b/test-runner/src/android/test/mock/MockPackageManager.java @@ -181,6 +181,12 @@ public class MockPackageManager extends PackageManager { throw new UnsupportedOperationException(); } + /** @hide */ + @Override + public String getPermissionControllerPackageName() { + throw new UnsupportedOperationException(); + } + @Override public boolean addPermission(PermissionInfo info) { throw new UnsupportedOperationException(); diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java index 90ef28c..f04654e 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java @@ -172,6 +172,11 @@ public class BridgePackageManager extends PackageManager { } @Override + public String getPermissionControllerPackageName() { + return null; + } + + @Override public boolean addPermission(PermissionInfo info) { return false; } |