summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2015-07-13 22:45:33 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-13 22:45:33 +0000
commit0fd2d2b124d2aa614131c7b9cedde9d18e830724 (patch)
tree7db61c4b0bade63c6c58fd1ca1a67841aa01733b /services
parent8117c2f8e491d9b48769139c5bca685e88106ae5 (diff)
parent292eb65f1ee0747e60899c1b1d0b6cb16c9cd37a (diff)
downloadframeworks_base-0fd2d2b124d2aa614131c7b9cedde9d18e830724.zip
frameworks_base-0fd2d2b124d2aa614131c7b9cedde9d18e830724.tar.gz
frameworks_base-0fd2d2b124d2aa614131c7b9cedde9d18e830724.tar.bz2
am 292eb65f: Merge "Fix new user creation regression due to vold remount calls" into mnc-dev
* commit '292eb65f1ee0747e60899c1b1d0b6cb16c9cd37a': Fix new user creation regression due to vold remount calls
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java20
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java13
2 files changed, 19 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a477f25..a0c9b80 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3458,8 +3458,12 @@ public class PackageManagerService extends IPackageManager.Stub {
mSettings.writeRuntimePermissionsForUserLPr(userId, false);
}
- if (READ_EXTERNAL_STORAGE.equals(name)
- || WRITE_EXTERNAL_STORAGE.equals(name)) {
+ // Only need to do this if user is initialized. Otherwise it's a new user
+ // and there are no processes running as the user yet and there's no need
+ // to make an expensive call to remount processes for the changed permissions.
+ if ((READ_EXTERNAL_STORAGE.equals(name)
+ || WRITE_EXTERNAL_STORAGE.equals(name))
+ && sUserManager.isInitialized(userId)) {
final long token = Binder.clearCallingIdentity();
try {
final StorageManager storage = mContext.getSystemService(StorageManager.class);
@@ -15965,16 +15969,8 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
- void newUserCreatedLILPw(final int userHandle) {
- // We cannot grant the default permissions with a lock held as
- // we query providers from other components for default handlers
- // such as enabled IMEs, etc.
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mDefaultPermissionPolicy.grantDefaultPermissions(userHandle);
- }
- });
+ void newUserCreated(final int userHandle) {
+ mDefaultPermissionPolicy.grantDefaultPermissions(userHandle);
}
@Override
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index daaaa53..8ca10d3 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -1220,6 +1220,7 @@ public class UserManagerService extends IUserManager.Stub {
final boolean isManagedProfile = (flags & UserInfo.FLAG_MANAGED_PROFILE) != 0;
final long ident = Binder.clearCallingIdentity();
UserInfo userInfo = null;
+ final int userId;
try {
synchronized (mInstallLock) {
synchronized (mPackagesLock) {
@@ -1240,7 +1241,7 @@ public class UserManagerService extends IUserManager.Stub {
if (isGuest && findCurrentGuestUserLocked() != null) {
return null;
}
- int userId = getNextAvailableIdLocked();
+ userId = getNextAvailableIdLocked();
userInfo = new UserInfo(userId, name, null, flags);
userInfo.serialNumber = mNextSerialNumber++;
long now = System.currentTimeMillis();
@@ -1274,9 +1275,9 @@ public class UserManagerService extends IUserManager.Stub {
updateUserIdsLocked();
Bundle restrictions = new Bundle();
mUserRestrictions.append(userId, restrictions);
- mPm.newUserCreatedLILPw(userId);
}
}
+ mPm.newUserCreated(userId);
if (userInfo != null) {
Intent addedIntent = new Intent(Intent.ACTION_USER_ADDED);
addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userInfo.id);
@@ -2011,4 +2012,12 @@ public class UserManagerService extends IUserManager.Stub {
}
}
}
+
+ /**
+ * @param userId
+ * @return whether the user has been initialized yet
+ */
+ boolean isInitialized(int userId) {
+ return (getUserInfo(userId).flags & UserInfo.FLAG_INITIALIZED) != 0;
+ }
}