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
This commit is contained in:
Amith Yamasani
2014-11-19 17:12:46 -08:00
parent 3a84d40133
commit 45f86236e4
3 changed files with 88 additions and 74 deletions

View File

@@ -87,7 +87,7 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
super.onResume();
// Check if user still exists
UserInfo info = getExistingUser(mUser);
UserInfo info = Utils.getExistingUser(mUserManager, mUser);
if (info == null) {
finishFragment();
} else {
@@ -97,16 +97,6 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
}
}
private UserInfo getExistingUser(UserHandle thisUser) {
final List<UserInfo> users = mUserManager.getUsers(true); // Only get non-dying
for (UserInfo user : users) {
if (user.id == thisUser.getIdentifier()) {
return user;
}
}
return null;
}
@Override
public void startActivityForResult(Intent intent, int requestCode) {
mEditUserInfoController.startingActivityForResult();