diff options
| author | 2015-07-09 14:16:27 -0700 | |
|---|---|---|
| committer | 2015-07-09 14:16:27 -0700 | |
| commit | bb054c9dcc68d24e1d2ded709b721948b939018c (patch) | |
| tree | 56f34da97eb89ac6cc02968b7358c2c2c0153510 | |
| parent | 607a040dae1b8fde0f9ea9f1723e0721f891f3dd (diff) | |
Fix new user creation regression due to vold remount calls
When creating a new user, there's no need to call into vold when
setting up default system permissions for storage. This was otherwise
adding 2 seconds to the user creation time, causing a frozen screen
before showing "Switching to user ...".
Fix is to call the permission setup code synchronously and not
call into vold if the user hasn't been initialized yet.
Bug: 22356546
Change-Id: I4c8632813e8c0f2ac90da386691af439521bb25a
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 20 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/UserManagerService.java | 13 |
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 3c117aa2a61c..efea8fad5798 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3429,8 +3429,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); @@ -15924,16 +15928,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 1a79b4eff6ed..23cb76771b58 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); @@ -2015,4 +2016,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; + } } |