am aa96cbec
: am 0cc764be
: Merge "Watch out for deleted user when exiting async task" into lmp-mr1-dev
* commit 'aa96cbec46dc2fce7eabd660ad08c1ef8326dbb3': Watch out for deleted user when exiting async task
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -59,6 +59,7 @@ import android.widget.Switch;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.drawable.CircleFramedDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -644,12 +645,16 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
||||
if (context == null) return;
|
||||
final PackageManager pm = mPackageManager;
|
||||
final IPackageManager ipm = mIPm;
|
||||
final int userId = mUser.getIdentifier();
|
||||
|
||||
// Check if the user was removed in the meantime.
|
||||
if (Utils.getExistingUser(mUserManager, mUser) == null) {
|
||||
return;
|
||||
}
|
||||
mAppList.removeAll();
|
||||
Intent restrictionsIntent = new Intent(Intent.ACTION_GET_RESTRICTION_ENTRIES);
|
||||
final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(restrictionsIntent, 0);
|
||||
int i = 0;
|
||||
if (mVisibleApps.size() > 0) {
|
||||
for (SelectableAppInfo app : mVisibleApps) {
|
||||
String packageName = app.packageName;
|
||||
if (packageName == null) continue;
|
||||
@@ -672,10 +677,13 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
||||
try {
|
||||
pi = ipm.getPackageInfo(packageName,
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES
|
||||
| PackageManager.GET_SIGNATURES, mUser.getIdentifier());
|
||||
| PackageManager.GET_SIGNATURES, userId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
if (pi != null && (pi.requiredForAllUsers || isPlatformSigned(pi))) {
|
||||
if (pi == null) {
|
||||
continue;
|
||||
}
|
||||
if (pi.requiredForAllUsers || isPlatformSigned(pi)) {
|
||||
p.setChecked(true);
|
||||
p.setImmutable(true);
|
||||
// If the app is required and has no restrictions, skip showing it
|
||||
@@ -713,7 +721,6 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
||||
mAppListChanged = true;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// If this is the first time for a new profile, install/uninstall default apps for profile
|
||||
// to avoid taking the hit in onPause(), which can cause race conditions on user switch.
|
||||
if (mNewUser && mFirstTime) {
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user