diff options
author | Amith Yamasani <yamasani@google.com> | 2014-11-19 17:12:46 -0800 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2014-11-20 13:19:18 -0800 |
commit | 45f86236e4d771f9d6c464f1e54be7fb813f4ceb (patch) | |
tree | 1ce7b8d0563f27fd583a13acf5c77f8818c3de58 /src/com/android/settings/Utils.java | |
parent | 3a84d40133e7a4f74fd1df091ba43fb85859b169 (diff) | |
download | packages_apps_Settings-45f86236e4d771f9d6c464f1e54be7fb813f4ceb.zip packages_apps_Settings-45f86236e4d771f9d6c464f1e54be7fb813f4ceb.tar.gz packages_apps_Settings-45f86236e4d771f9d6c464f1e54be7fb813f4ceb.tar.bz2 |
Watch out for deleted user when exiting async task
Fixes a problem where the async task can take a while to execute
and in the meantime the user can be removed. On exiting the async
task and updating the UI, make sure the user hasn't been deleted.
Bug: 18411181
Change-Id: I1831f3e53084c49e27557cb7aacec78c753a611b
Diffstat (limited to 'src/com/android/settings/Utils.java')
-rw-r--r-- | src/com/android/settings/Utils.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index e687beb..dc9e8a2 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -1023,4 +1023,21 @@ public final class Utils { return null; } + /** + * Queries for the UserInfo of a user. Returns null if the user doesn't exist (was removed). + * @param userManager Instance of UserManager + * @param checkUser The user to check the existence of. + * @return UserInfo of the user or null for non-existent user. + */ + public static UserInfo getExistingUser(UserManager userManager, UserHandle checkUser) { + final List<UserInfo> users = userManager.getUsers(true /* excludeDying */); + final int checkUserId = checkUser.getIdentifier(); + for (UserInfo user : users) { + if (user.id == checkUserId) { + return user; + } + } + return null; + } + } |