summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorSvet Ganov <svetoslavganov@google.com>2015-07-23 09:32:26 -0700
committerSvet Ganov <svetoslavganov@google.com>2015-07-23 10:36:35 -0700
commit9c8b8ab941e3ca7bdf2cccad6836760d7723518e (patch)
tree1cfbb0068e29946fa9ecc53863d6a3c4b1824d9b /services
parenta0a71d8a221d4f3896c7b0d3b2b87eba4e7a77f7 (diff)
downloadframeworks_base-9c8b8ab941e3ca7bdf2cccad6836760d7723518e.zip
frameworks_base-9c8b8ab941e3ca7bdf2cccad6836760d7723518e.tar.gz
frameworks_base-9c8b8ab941e3ca7bdf2cccad6836760d7723518e.tar.bz2
Reset permissions and app links when clearing app preferences - framework
bug:22359132 Change-Id: I198c0b1cd6c3dcb91fe560874a8502eb6b5f65b3
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java57
1 files changed, 45 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 0b74996..449bde8 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3555,7 +3555,7 @@ public class PackageManagerService extends IPackageManager.Stub {
continue;
}
PackageSetting ps = (PackageSetting) pkg.mExtras;
- resetUserChangesToRuntimePermissionsAndFlagsLocked(ps, userId);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, userId);
}
}
}
@@ -13090,7 +13090,7 @@ public class PackageManagerService extends IPackageManager.Stub {
if (clearPackagePreferredActivitiesLPw(packageName, removeUser)) {
scheduleWritePackageRestrictionsLocked(removeUser);
}
- resetUserChangesToRuntimePermissionsAndFlagsLocked(ps, removeUser);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, removeUser);
}
return true;
}
@@ -13251,7 +13251,7 @@ public class PackageManagerService extends IPackageManager.Stub {
}
PackageSetting ps = (PackageSetting) pkg.mExtras;
- resetUserChangesToRuntimePermissionsAndFlagsLocked(ps, userId);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, userId);
}
// Always delete data directories for package, even if we found no other
@@ -13283,12 +13283,27 @@ public class PackageManagerService extends IPackageManager.Stub {
}
/**
+ * Reverts user permission state changes (permissions and flags) in
+ * all packages for a given user.
+ *
+ * @param userId The device user for which to do a reset.
+ */
+ private void resetUserChangesToRuntimePermissionsAndFlagsLPw(int userId) {
+ final int packageCount = mPackages.size();
+ for (int i = 0; i < packageCount; i++) {
+ PackageParser.Package pkg = mPackages.valueAt(i);
+ PackageSetting ps = (PackageSetting) pkg.mExtras;
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, userId);
+ }
+ }
+
+ /**
* Reverts user permission state changes (permissions and flags).
*
* @param ps The package for which to reset.
* @param userId The device user for which to do a reset.
*/
- private void resetUserChangesToRuntimePermissionsAndFlagsLocked(
+ private void resetUserChangesToRuntimePermissionsAndFlagsLPw(
final PackageSetting ps, final int userId) {
if (ps.pkg == null) {
return;
@@ -13788,6 +13803,15 @@ public class PackageManagerService extends IPackageManager.Stub {
}
/** This method takes a specific user id as well as UserHandle.USER_ALL. */
+ private void clearIntentFilterVerificationsLPw(int userId) {
+ final int packageCount = mPackages.size();
+ for (int i = 0; i < packageCount; i++) {
+ PackageParser.Package pkg = mPackages.valueAt(i);
+ clearIntentFilterVerificationsLPw(pkg.packageName, userId);
+ }
+ }
+
+ /** This method takes a specific user id as well as UserHandle.USER_ALL. */
void clearIntentFilterVerificationsLPw(String packageName, int userId) {
if (userId == UserHandle.USER_ALL) {
if (mSettings.removeIntentFilterVerificationLPw(packageName,
@@ -13803,7 +13827,6 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
-
void clearDefaultBrowserIfNeeded(String packageName) {
for (int oneUserId : sUserManager.getUserIds()) {
String defaultBrowserPackageName = getDefaultBrowserPackageName(oneUserId);
@@ -13815,17 +13838,27 @@ public class PackageManagerService extends IPackageManager.Stub {
}
@Override
- public void resetPreferredActivities(int userId) {
+ public void resetApplicationPreferences(int userId) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
// writer
synchronized (mPackages) {
- clearPackagePreferredActivitiesLPw(null, userId);
- mSettings.applyDefaultPreferredAppsLPw(this, userId);
- applyFactoryDefaultBrowserLPw(userId);
- primeDomainVerificationsLPw(userId);
-
- scheduleWritePackageRestrictionsLocked(userId);
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ clearPackagePreferredActivitiesLPw(null, userId);
+ mSettings.applyDefaultPreferredAppsLPw(this, userId);
+ // TODO: We have to reset the default SMS and Phone. This requires
+ // significant refactoring to keep all default apps in the package
+ // manager (cleaner but more work) or have the services provide
+ // callbacks to the package manager to request a default app reset.
+ applyFactoryDefaultBrowserLPw(userId);
+ clearIntentFilterVerificationsLPw(userId);
+ primeDomainVerificationsLPw(userId);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(userId);
+ scheduleWritePackageRestrictionsLocked(userId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
}
}