sys user split: first pass updating Settings
Update various places in Settings to use "admin" ueser flag instead of checking user id "0". This should be no-op in single user mode since the only admin user would be user 0. In split system user mode, this will correctly ACL admin user instead of non-interactive system user. Bug: 19913735 Change-Id: Ida4d59c5f689ea0dc34b3b3ff0822b087fa0afd6
This commit is contained in:
@@ -175,7 +175,7 @@ public class ApnSettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)
|
||||
|| UserHandle.myUserId()!= UserHandle.USER_OWNER) {
|
||||
|| !mUm.isAdminUser()) {
|
||||
mUnavailable = true;
|
||||
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
|
||||
return;
|
||||
|
@@ -200,6 +200,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
private NetworkPolicyManager mPolicyManager;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private UserManager mUserManager;
|
||||
|
||||
private INetworkStatsSession mStatsSession;
|
||||
|
||||
@@ -307,6 +308,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
mPolicyManager = NetworkPolicyManager.from(context);
|
||||
mTelephonyManager = TelephonyManager.from(context);
|
||||
mSubscriptionManager = SubscriptionManager.from(context);
|
||||
mUserManager = UserManager.get(context);
|
||||
|
||||
mPrefs = getActivity().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
|
||||
|
||||
@@ -548,7 +550,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
final Context context = getActivity();
|
||||
final boolean appDetailMode = isAppDetailMode();
|
||||
final boolean isOwner = ActivityManager.getCurrentUser() == UserHandle.USER_OWNER;
|
||||
final boolean isAdmin = mUserManager.isAdminUser();
|
||||
|
||||
mMenuShowWifi = menu.findItem(R.id.data_usage_menu_show_wifi);
|
||||
if (hasWifiRadio(context) && hasReadyMobileRadio(context)) {
|
||||
@@ -566,7 +568,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
|
||||
mMenuRestrictBackground = menu.findItem(R.id.data_usage_menu_restrict_background);
|
||||
mMenuRestrictBackground.setVisible(
|
||||
hasReadyMobileRadio(context) && isOwner && !appDetailMode);
|
||||
hasReadyMobileRadio(context) && isAdmin && !appDetailMode);
|
||||
|
||||
final MenuItem metered = menu.findItem(R.id.data_usage_menu_metered);
|
||||
if (hasReadyMobileRadio(context) || hasWifiRadio(context)) {
|
||||
@@ -581,7 +583,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
|
||||
mMenuCellularNetworks = menu.findItem(R.id.data_usage_menu_cellular_networks);
|
||||
mMenuCellularNetworks.setVisible(hasReadyMobileRadio(context)
|
||||
&& !appDetailMode && isOwner);
|
||||
&& !appDetailMode && isAdmin);
|
||||
|
||||
final MenuItem help = menu.findItem(R.id.data_usage_menu_help);
|
||||
String helpUrl;
|
||||
@@ -796,9 +798,8 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
if (!isAdded()) return;
|
||||
|
||||
final Context context = getActivity();
|
||||
final Resources resources = context.getResources();
|
||||
final String currentTab = mTabHost.getCurrentTabTag();
|
||||
final boolean isOwner = ActivityManager.getCurrentUser() == UserHandle.USER_OWNER;
|
||||
final boolean isAdmin = mUserManager.isAdminUser();
|
||||
|
||||
if (currentTab == null) {
|
||||
Log.w(TAG, "no tab selected; hiding body");
|
||||
@@ -812,7 +813,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
|
||||
if (LOGD) Log.d(TAG, "updateBody() with currentTab=" + currentTab);
|
||||
|
||||
mDataEnabledSupported = isOwner;
|
||||
mDataEnabledSupported = isAdmin;
|
||||
mDisableAtLimitSupported = true;
|
||||
|
||||
// TODO: remove mobile tabs when SIM isn't ready probably by
|
||||
@@ -1077,7 +1078,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
||||
|
||||
private boolean isNetworkPolicyModifiable(NetworkPolicy policy) {
|
||||
return policy != null && isBandwidthControlEnabled() && mDataEnabled.isChecked()
|
||||
&& ActivityManager.getCurrentUser() == UserHandle.USER_OWNER;
|
||||
&& mUserManager.isAdminUser();
|
||||
}
|
||||
|
||||
private boolean isBandwidthControlEnabled() {
|
||||
|
@@ -289,7 +289,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
||||
|
||||
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
|
||||
if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER
|
||||
if (!mUm.isAdminUser()
|
||||
|| mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
||||
mUnavailable = true;
|
||||
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
|
||||
@@ -328,8 +328,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
||||
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
|
||||
mAllPrefs.add(mPassword);
|
||||
|
||||
|
||||
if (!android.os.Process.myUserHandle().equals(UserHandle.OWNER)) {
|
||||
if (!mUm.isAdminUser()) {
|
||||
disableForUser(mEnableAdb);
|
||||
disableForUser(mClearAdbKeys);
|
||||
disableForUser(mEnableTerminal);
|
||||
|
@@ -81,6 +81,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
int mDevHitCountdown;
|
||||
Toast mDevHitToast;
|
||||
|
||||
private UserManager mUm;
|
||||
|
||||
@Override
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsLogger.DEVICEINFO;
|
||||
@@ -94,6 +96,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
mUm = UserManager.get(getActivity());
|
||||
|
||||
addPreferencesFromResource(R.xml.device_info_settings);
|
||||
|
||||
@@ -145,7 +148,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
|
||||
// These are contained by the root preference screen
|
||||
PreferenceGroup parentPreference = getPreferenceScreen();
|
||||
if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
|
||||
|
||||
if (mUm.isAdminUser()) {
|
||||
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference,
|
||||
KEY_SYSTEM_UPDATE_SETTINGS,
|
||||
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
|
||||
@@ -183,8 +187,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
|
||||
mHits[mHits.length-1] = SystemClock.uptimeMillis();
|
||||
if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
|
||||
UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||
if (um.hasUserRestriction(UserManager.DISALLOW_FUN)) {
|
||||
if (mUm.hasUserRestriction(UserManager.DISALLOW_FUN)) {
|
||||
Log.d(LOG_TAG, "Sorry, no fun for you!");
|
||||
return false;
|
||||
}
|
||||
@@ -200,10 +203,9 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
}
|
||||
} else if (preference.getKey().equals(KEY_BUILD_NUMBER)) {
|
||||
// Don't enable developer options for secondary users.
|
||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) return true;
|
||||
if (!mUm.isAdminUser()) return true;
|
||||
|
||||
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||
if (um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) return true;
|
||||
if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) return true;
|
||||
|
||||
if (mDevHitCountdown > 0) {
|
||||
mDevHitCountdown--;
|
||||
@@ -472,7 +474,9 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
if (TextUtils.isEmpty(getFeedbackReporterPackage(context))) {
|
||||
keys.add(KEY_DEVICE_FEEDBACK);
|
||||
}
|
||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||
final UserManager um = UserManager.get(context);
|
||||
// TODO: system update needs to be fixed for non-owner user b/22760654
|
||||
if (!um.isAdminUser()) {
|
||||
keys.add(KEY_SYSTEM_UPDATE_SETTINGS);
|
||||
}
|
||||
if (!context.getResources().getBoolean(
|
||||
|
@@ -281,9 +281,9 @@ public class MasterClear extends InstrumentedFragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
if (!Process.myUserHandle().isOwner()
|
||||
|| UserManager.get(getActivity()).hasUserRestriction(
|
||||
UserManager.DISALLOW_FACTORY_RESET)) {
|
||||
final UserManager um = UserManager.get(getActivity());
|
||||
if (!um.isAdminUser()
|
||||
|| um.hasUserRestriction(UserManager.DISALLOW_FACTORY_RESET)) {
|
||||
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
|
||||
}
|
||||
|
||||
|
@@ -71,8 +71,9 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Don't allow any access if this is a secondary user
|
||||
mEnabled = Process.myUserHandle().isOwner();
|
||||
// Don't allow any access if this is not an admin user.
|
||||
// TODO: backup/restore currently only works with owner user b/22760572
|
||||
mEnabled = UserManager.get(getActivity()).isAdminUser();
|
||||
if (!mEnabled) {
|
||||
return;
|
||||
}
|
||||
|
@@ -192,9 +192,9 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
if (!Process.myUserHandle().isOwner()
|
||||
|| UserManager.get(getActivity()).hasUserRestriction(
|
||||
UserManager.DISALLOW_NETWORK_RESET)) {
|
||||
final UserManager um = UserManager.get(getActivity());
|
||||
if (!um.isAdminUser()
|
||||
|| um.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) {
|
||||
return inflater.inflate(R.layout.network_reset_disallowed_screen, null);
|
||||
}
|
||||
|
||||
|
@@ -116,6 +116,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
|
||||
private DevicePolicyManager mDPM;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private UserManager mUm;
|
||||
|
||||
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
|
||||
private LockPatternUtils mLockPatternUtils;
|
||||
@@ -132,7 +133,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
private DialogInterface mWarnInstallApps;
|
||||
private SwitchPreference mPowerButtonInstantlyLocks;
|
||||
|
||||
private boolean mIsPrimary;
|
||||
private boolean mIsAdmin;
|
||||
|
||||
private Intent mTrustAgentClickIntent;
|
||||
private Preference mOwnerInfoPref;
|
||||
@@ -152,6 +153,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
|
||||
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
|
||||
mUm = UserManager.get(getActivity());
|
||||
|
||||
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
|
||||
|
||||
if (savedInstanceState != null
|
||||
@@ -207,7 +210,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
addPreferencesFromResource(resid);
|
||||
|
||||
// Add options for device encryption
|
||||
mIsPrimary = MY_USER_ID == UserHandle.USER_OWNER;
|
||||
mIsAdmin = mUm.isAdminUser();
|
||||
|
||||
mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
|
||||
if (mOwnerInfoPref != null) {
|
||||
@@ -220,7 +223,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
});
|
||||
}
|
||||
|
||||
if (mIsPrimary) {
|
||||
if (mIsAdmin) {
|
||||
if (LockPatternUtils.isDeviceEncryptionEnabled()) {
|
||||
// The device is currently encrypted.
|
||||
addPreferencesFromResource(R.xml.security_settings_encrypted);
|
||||
@@ -268,7 +271,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
CarrierConfigManager cfgMgr = (CarrierConfigManager)
|
||||
getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||
PersistableBundle b = cfgMgr.getConfig();
|
||||
if (!mIsPrimary || !isSimIccReady() ||
|
||||
if (!mIsAdmin || !isSimIccReady() ||
|
||||
b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
|
||||
root.removePreference(root.findPreference(KEY_SIM_LOCK));
|
||||
} else {
|
||||
@@ -719,14 +722,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
|
||||
private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider {
|
||||
|
||||
boolean mIsPrimary;
|
||||
|
||||
public SecuritySearchIndexProvider() {
|
||||
super();
|
||||
|
||||
mIsPrimary = MY_USER_ID == UserHandle.USER_OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
@@ -741,7 +736,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
sir.xmlResId = resId;
|
||||
result.add(sir);
|
||||
|
||||
if (mIsPrimary) {
|
||||
final UserManager um = UserManager.get(context);
|
||||
if (um.isAdminUser()) {
|
||||
DevicePolicyManager dpm = (DevicePolicyManager)
|
||||
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
|
||||
@@ -781,8 +777,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
|
||||
if (!mIsPrimary) {
|
||||
int resId = (UserManager.get(context).isLinkedUser()) ?
|
||||
final UserManager um = UserManager.get(context);
|
||||
if (!um.isAdminUser()) {
|
||||
int resId = um.isLinkedUser() ?
|
||||
R.string.profile_info_settings_title : R.string.user_info_settings_title;
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
@@ -802,8 +799,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
// Credential storage
|
||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
|
||||
if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
|
||||
KeyStore keyStore = KeyStore.getInstance();
|
||||
|
||||
@@ -839,16 +834,14 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
|
||||
LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
||||
// Add options for lock/unlock screen
|
||||
int resId = getResIdForLockUnlockScreen(context, lockPatternUtils);
|
||||
|
||||
// Do not display SIM lock for devices without an Icc card
|
||||
TelephonyManager tm = TelephonyManager.getDefault();
|
||||
if (!mIsPrimary || !tm.hasIccCard()) {
|
||||
final UserManager um = UserManager.get(context);
|
||||
final TelephonyManager tm = TelephonyManager.from(context);
|
||||
if (!um.isAdminUser() || !tm.hasIccCard()) {
|
||||
keys.add(KEY_SIM_LOCK);
|
||||
}
|
||||
|
||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
|
||||
keys.add(KEY_CREDENTIALS_MANAGER);
|
||||
}
|
||||
|
@@ -439,13 +439,6 @@ public class SettingsActivity extends Activity
|
||||
int titleRes = pref.getTitleRes();
|
||||
if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) {
|
||||
titleRes = R.string.wallpaper_settings_fragment_title;
|
||||
} else if (pref.getFragment().equals(OwnerInfoSettings.class.getName())
|
||||
&& UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||
if (UserManager.get(this).isLinkedUser()) {
|
||||
titleRes = R.string.profile_info_settings_title;
|
||||
} else {
|
||||
titleRes = R.string.user_info_settings_title;
|
||||
}
|
||||
}
|
||||
startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(),
|
||||
null, 0);
|
||||
@@ -1219,7 +1212,8 @@ public class SettingsActivity extends Activity
|
||||
DevelopmentSettings.PREF_SHOW,
|
||||
android.os.Build.TYPE.equals("eng"));
|
||||
|
||||
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||
final UserManager um = UserManager.get(this);
|
||||
final boolean isAdmin = um.isAdminUser();
|
||||
|
||||
final int size = target.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
@@ -1264,9 +1258,6 @@ public class SettingsActivity extends Activity
|
||||
removeTile = true;
|
||||
}
|
||||
} else if (id == R.id.user_settings) {
|
||||
boolean hasMultipleUsers =
|
||||
((UserManager) getSystemService(Context.USER_SERVICE))
|
||||
.getUserCount() > 1;
|
||||
if (!UserHandle.MU_ENABLED
|
||||
|| !UserManager.supportsMultipleUsers()
|
||||
|| Utils.isMonkeyRunning()) {
|
||||
@@ -1297,7 +1288,7 @@ public class SettingsActivity extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
|
||||
if (UserHandle.MU_ENABLED && !isAdmin
|
||||
&& !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
|
||||
removeTile = true;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package com.android.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
@@ -29,7 +29,8 @@ public class TestingSettings extends PreferenceActivity {
|
||||
|
||||
addPreferencesFromResource(R.xml.testing_settings);
|
||||
|
||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||
final UserManager um = UserManager.get(this);
|
||||
if (!um.isAdminUser()) {
|
||||
PreferenceScreen preferenceScreen = (PreferenceScreen)
|
||||
findPreference("radio_info_settings");
|
||||
getPreferenceScreen().removePreference(preferenceScreen);
|
||||
|
@@ -125,7 +125,7 @@ public class TetherSettings extends SettingsPreferenceFragment
|
||||
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||
|
||||
if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)
|
||||
|| UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||
|| !mUm.isAdminUser()) {
|
||||
mUnavailable = true;
|
||||
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
|
||||
return;
|
||||
|
@@ -439,8 +439,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
result.add(KEY_TOGGLE_NSD);
|
||||
|
||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
final int myUserId = UserHandle.myUserId();
|
||||
final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
|
||||
final boolean isSecondaryUser = !um.isAdminUser();
|
||||
final boolean isWimaxEnabled = !isSecondaryUser
|
||||
&& context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_wimaxEnabled);
|
||||
|
@@ -32,9 +32,8 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
@@ -206,7 +205,8 @@ public class Status extends InstrumentedPreferenceActivity {
|
||||
}
|
||||
|
||||
//Remove SimStatus and Imei for Secondary user as it access Phone b/19165700
|
||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||
//TODO: the bug above will surface in split system user mode.
|
||||
if (!UserManager.get(this).isAdminUser()) {
|
||||
removePreferenceFromScreen(KEY_SIM_STATUS);
|
||||
removePreferenceFromScreen(KEY_IMEI_INFO);
|
||||
}
|
||||
|
@@ -201,7 +201,7 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
sipper.getUid() <= Process.LAST_SHARED_APPLICATION_GID) {
|
||||
// This is a shared gid being used to do work on behalf of an app across all
|
||||
// users. But we'll blame the power on the device OWNER.
|
||||
realUid = UserHandle.getUid(UserHandle.USER_OWNER,
|
||||
realUid = UserHandle.getUid(UserHandle.USER_SYSTEM,
|
||||
UserHandle.getAppIdFromSharedAppGid(sipper.getUid()));
|
||||
}
|
||||
|
||||
|
@@ -111,8 +111,8 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference == mRemoveUserPref) {
|
||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||
throw new RuntimeException("Only the owner can remove a user");
|
||||
if (mUserManager.isAdminUser()) {
|
||||
throw new RuntimeException("Only admins can remove a user");
|
||||
}
|
||||
showDialog(DIALOG_CONFIRM_REMOVE);
|
||||
return true;
|
||||
|
@@ -30,6 +30,7 @@ import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WpsInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
@@ -135,7 +136,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
mWifiAssistantPreference = (AppListSwitchPreference) findPreference(KEY_WIFI_ASSISTANT);
|
||||
Collection<NetworkScorerAppData> scorers =
|
||||
NetworkScorerAppManager.getAllValidScorers(context);
|
||||
if (UserHandle.myUserId() == UserHandle.USER_OWNER && !scorers.isEmpty()) {
|
||||
if (UserManager.get(context).isAdminUser() && !scorers.isEmpty()) {
|
||||
mWifiAssistantPreference.setOnPreferenceChangeListener(this);
|
||||
initWifiAssistantPreference(scorers);
|
||||
} else if (mWifiAssistantPreference != null) {
|
||||
|
Reference in New Issue
Block a user