From 91293794bfe2ed9ac7bbb7b652d3fb78665d3b0f Mon Sep 17 00:00:00 2001 From: Paul Crowley Date: Fri, 25 Mar 2016 15:23:07 -0700 Subject: [PATCH] Continue to remove users when destroyUserKey fails. destroyUserKey can fail if the user is partially created; even when something fails it still destroys all it can. Its failure shouldn't halt user removal. Bug: 26847403 Change-Id: Iab1f551d19fd777198387b463b270c2508d07fd5 --- .../java/com/android/server/pm/UserManagerService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index ac19e24ba0100..102a67c8ee075 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -2189,7 +2189,13 @@ public class UserManagerService extends IUserManager.Stub { } private void removeUserState(final int userHandle) { - mContext.getSystemService(StorageManager.class).destroyUserKey(userHandle); + try { + mContext.getSystemService(StorageManager.class).destroyUserKey(userHandle); + } catch (IllegalStateException e) { + // This may be simply because the user was partially created. + Slog.i(LOG_TAG, + "Destroying key for user " + userHandle + " failed, continuing anyway", e); + } // Cleanup package manager settings mPm.cleanUpUser(this, userHandle);