Prevent user ID reuse until after reboot.

We're still seeing rare cases where a device struggles to create a
new user, probably because of a subtle bug in the FUSE daemon.  To
work around this, only allow user IDs reuse after reboot.

Bug: 8302014
Change-Id: Id7f9fb539c6d6d1ff3d47d941af1d9e6b93eca03
This commit is contained in:
Jeff Sharkey
2014-11-14 15:57:59 -08:00
parent 2cffc7dafd
commit 6eb093909c

View File

@@ -1298,7 +1298,12 @@ public class UserManagerService extends IUserManager.Stub {
if (userHandle == 0 || user == null || mRemovingUserIds.get(userHandle)) {
return false;
}
// We remember deleted user IDs to prevent them from being
// reused during the current boot; they can still be reused
// after a reboot.
mRemovingUserIds.put(userHandle, true);
try {
mAppOpsService.removeUser(userHandle);
} catch (RemoteException e) {
@@ -1387,18 +1392,6 @@ public class UserManagerService extends IUserManager.Stub {
// Remove this user from the list
mUsers.remove(userHandle);
// Have user ID linger for several seconds to let external storage VFS
// cache entries expire. This must be greater than the 'entry_valid'
// timeout used by the FUSE daemon.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
synchronized (mPackagesLock) {
mRemovingUserIds.delete(userHandle);
}
}
}, MINUTE_IN_MILLIS);
mRestrictionsPinStates.remove(userHandle);
// Remove user file
AtomicFile userFile = new AtomicFile(new File(mUsersDir, userHandle + XML_SUFFIX));