summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Todd Kennedy <toddke@google.com> 2015-08-12 18:17:06 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-08-12 18:17:06 +0000
commit2fee91c5683d4f3e89c9bd2485207044ab495f43 (patch)
tree55a6a9546f54a1ad3193264b538abb9e45a9f312
parentb28285f8a8980a71c71f8ba97ae5ff85037f0073 (diff)
parentf6f11daafe9884b93218487d5af29130e97107e9 (diff)
am f6f11daa: am f5107e38: am d43f4d92: am 8af3406a: am 24e4d48f: Merge "Promote system app permissions" into mnc-dev
* commit 'f6f11daafe9884b93218487d5af29130e97107e9': Promote system app permissions
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java42
1 files changed, 38 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index dc6e17d92db8..c0a30977070b 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -481,12 +481,21 @@ public class PackageManagerService extends IPackageManager.Stub {
new ArrayMap<String, ArrayMap<String, PackageParser.Package>>();
/**
- * Tracks new system packages [receiving in an OTA] that we expect to
+ * Tracks new system packages [received in an OTA] that we expect to
* find updated user-installed versions. Keys are package name, values
* are package location.
*/
final private ArrayMap<String, File> mExpectingBetter = new ArrayMap<>();
+ /**
+ * Tracks existing system packages prior to receiving an OTA. Keys are package name.
+ */
+ final private ArraySet<String> mExistingSystemPackages = new ArraySet<>();
+ /**
+ * Whether or not system app permissions should be promoted from install to runtime.
+ */
+ boolean mPromoteSystemApps;
+
final Settings mSettings;
boolean mRestoredSettings;
@@ -2047,6 +2056,24 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
+ final VersionInfo ver = mSettings.getInternalVersion();
+ mIsUpgrade = !Build.FINGERPRINT.equals(ver.fingerprint);
+ // when upgrading from pre-M, promote system app permissions from install to runtime
+ mPromoteSystemApps =
+ mIsUpgrade && ver.sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1;
+
+ // save off the names of pre-existing system packages prior to scanning; we don't
+ // want to automatically grant runtime permissions for new system apps
+ if (mPromoteSystemApps) {
+ Iterator<PackageSetting> pkgSettingIter = mSettings.mPackages.values().iterator();
+ while (pkgSettingIter.hasNext()) {
+ PackageSetting ps = pkgSettingIter.next();
+ if (isSystemApp(ps)) {
+ mExistingSystemPackages.add(ps.name);
+ }
+ }
+ }
+
// Collect vendor overlay packages.
// (Do this before scanning any apps.)
// For security and version matching reason, only consider
@@ -2266,8 +2293,6 @@ public class PackageManagerService extends IPackageManager.Stub {
// cases get permissions that the user didn't initially explicitly
// allow... it would be nice to have some better way to handle
// this situation.
- final VersionInfo ver = mSettings.getInternalVersion();
-
int updateFlags = UPDATE_PERMISSIONS_ALL;
if (ver.sdkVersion != mSdkVersion) {
Slog.i(TAG, "Platform changed from " + ver.sdkVersion + " to "
@@ -2276,6 +2301,9 @@ public class PackageManagerService extends IPackageManager.Stub {
}
updatePermissionsLPw(null, null, updateFlags);
ver.sdkVersion = mSdkVersion;
+ // clear only after permissions have been updated
+ mExistingSystemPackages.clear();
+ mPromoteSystemApps = false;
// If this is the first boot, and it is a normal boot, then
// we need to initialize the default preferred apps.
@@ -2287,7 +2315,6 @@ public class PackageManagerService extends IPackageManager.Stub {
// If this is first boot after an OTA, and a normal boot, then
// we need to clear code cache directories.
- mIsUpgrade = !Build.FINGERPRINT.equals(ver.fingerprint);
if (mIsUpgrade && !onlyCore) {
Slog.i(TAG, "Build fingerprint changed; clearing code caches");
for (int i = 0; i < mSettings.mPackages.size(); i++) {
@@ -8422,6 +8449,13 @@ public class PackageManagerService extends IPackageManager.Stub {
} else if (origPermissions.hasInstallPermission(bp.name)) {
// For legacy apps that became modern, install becomes runtime.
grant = GRANT_UPGRADE;
+ } else if (mPromoteSystemApps
+ && isSystemApp(ps)
+ && mExistingSystemPackages.contains(ps.name)) {
+ // For legacy system apps, install becomes runtime.
+ // We cannot check hasInstallPermission() for system apps since those
+ // permissions were granted implicitly and not persisted pre-M.
+ grant = GRANT_UPGRADE;
} else {
// For modern apps keep runtime permissions unchanged.
grant = GRANT_RUNTIME;