Clean up USER_OWNER references in settingslib.
Bug: 19913735 Change-Id: I0ccaed63c8fbc3bcbbd8d5cf8047e33c6e2edb5c
This commit is contained in:
@@ -595,14 +595,24 @@ public class UserManager {
|
||||
public boolean isSystemUser() {
|
||||
return UserHandle.myUserId() == UserHandle.USER_SYSTEM;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Returns whether the caller is running as an admin user. There can be more than one admin
|
||||
* user.
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
UserInfo user = getUserInfo(UserHandle.myUserId());
|
||||
return user != null ? user.isAdmin() : false;
|
||||
return isUserAdmin(UserHandle.myUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Returns whether the provided user is an admin user. There can be more than one admin
|
||||
* user.
|
||||
*/
|
||||
public boolean isUserAdmin(int userId) {
|
||||
UserInfo user = getUserInfo(userId);
|
||||
return user != null && user.isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1070,7 +1080,7 @@ public class UserManager {
|
||||
*/
|
||||
public List<UserHandle> getUserProfiles() {
|
||||
ArrayList<UserHandle> profiles = new ArrayList<UserHandle>();
|
||||
List<UserInfo> users = new ArrayList<UserInfo>();
|
||||
List<UserInfo> users;
|
||||
try {
|
||||
users = mService.getProfiles(UserHandle.myUserId(), true /* enabledOnly */);
|
||||
} catch (RemoteException re) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
public class TetherUtil {
|
||||
@@ -99,8 +99,9 @@ public class TetherUtil {
|
||||
public static boolean isTetheringSupported(Context context) {
|
||||
final ConnectivityManager cm =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
final boolean isSecondaryUser = ActivityManager.getCurrentUser() != UserHandle.USER_OWNER;
|
||||
return !isSecondaryUser && cm.isTetheringSupported();
|
||||
final boolean isAdminUser =
|
||||
UserManager.get(context).isUserAdmin(ActivityManager.getCurrentUser());
|
||||
return isAdminUser && cm.isTetheringSupported();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageStats;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
@@ -88,7 +89,7 @@ public class ApplicationsState {
|
||||
final PackageManager mPm;
|
||||
final IPackageManager mIpm;
|
||||
final UserManager mUm;
|
||||
final int mOwnerRetrieveFlags;
|
||||
final int mAdminRetrieveFlags;
|
||||
final int mRetrieveFlags;
|
||||
PackageIntentReceiver mPackageIntentReceiver;
|
||||
|
||||
@@ -131,7 +132,7 @@ public class ApplicationsState {
|
||||
mBackgroundHandler = new BackgroundHandler(mThread.getLooper());
|
||||
|
||||
// Only the owner can see all apps.
|
||||
mOwnerRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
|
||||
mAdminRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
|
||||
PackageManager.GET_DISABLED_COMPONENTS |
|
||||
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS;
|
||||
mRetrieveFlags = PackageManager.GET_DISABLED_COMPONENTS |
|
||||
@@ -181,17 +182,17 @@ public class ApplicationsState {
|
||||
mPackageIntentReceiver.registerReceiver();
|
||||
}
|
||||
mApplications = new ArrayList<ApplicationInfo>();
|
||||
for (UserHandle user : mUm.getUserProfiles()) {
|
||||
for (UserInfo user : mUm.getProfiles(UserHandle.myUserId())) {
|
||||
try {
|
||||
// If this user is new, it needs a map created.
|
||||
if (mEntriesMap.indexOfKey(user.getIdentifier()) < 0) {
|
||||
mEntriesMap.put(user.getIdentifier(), new HashMap<String, AppEntry>());
|
||||
if (mEntriesMap.indexOfKey(user.id) < 0) {
|
||||
mEntriesMap.put(user.id, new HashMap<String, AppEntry>());
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
ParceledListSlice<ApplicationInfo> list =
|
||||
mIpm.getInstalledApplications(
|
||||
user.isOwner() ? mOwnerRetrieveFlags : mRetrieveFlags,
|
||||
user.getIdentifier());
|
||||
user.isAdmin() ? mAdminRetrieveFlags : mRetrieveFlags,
|
||||
user.id);
|
||||
mApplications.addAll(list.getList());
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
@@ -363,7 +364,7 @@ public class ApplicationsState {
|
||||
return;
|
||||
}
|
||||
ApplicationInfo info = mIpm.getApplicationInfo(pkgName,
|
||||
userId == UserHandle.USER_OWNER ? mOwnerRetrieveFlags : mRetrieveFlags,
|
||||
mUm.isUserAdmin(userId) ? mAdminRetrieveFlags : mRetrieveFlags,
|
||||
userId);
|
||||
if (info == null) {
|
||||
return;
|
||||
|
||||
@@ -314,7 +314,7 @@ public class StorageMeasurement {
|
||||
} else {
|
||||
Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
|
||||
mContext.bindServiceAsUser(service, mDefContainerConn,
|
||||
Context.BIND_AUTO_CREATE, UserHandle.OWNER);
|
||||
Context.BIND_AUTO_CREATE, UserHandle.SYSTEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user