Cleanup remaining USER_OWNER in Settings

Bug: 19913735
Change-Id: I6894a7c81ed7504b02d533d9e9f65f800dbca895
This commit is contained in:
Xiaohui Chen
2015-09-02 16:54:00 -07:00
parent 98e3af770d
commit 6f03829e74
6 changed files with 20 additions and 18 deletions

View File

@@ -70,8 +70,9 @@ public final class ActiveNetworkScorerDialog extends AlertActivity implements
}
private boolean buildDialog() {
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
Log.i(TAG, "Can only set scorer for owner user.");
// TOOD: http://b/23422763
if (UserHandle.myUserId() != UserHandle.USER_SYSTEM) {
Log.i(TAG, "Can only set scorer for owner/system user.");
return false;
}
NetworkScorerAppData newScorer = NetworkScorerAppManager.getScorer(this, mNewPackageName);

View File

@@ -193,7 +193,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
public PrivacySearchIndexProvider() {
super();
mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER;
mIsPrimary = UserHandle.myUserId() == UserHandle.USER_SYSTEM;
}
@Override
@@ -203,6 +203,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>();
// For non-primary user, no backup or reset is available
// TODO: http://b/22388012
if (!mIsPrimary) {
return result;
}

View File

@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@@ -225,8 +226,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
addPreferencesFromResource(R.xml.wireless_settings);
final int myUserId = UserHandle.myUserId();
final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
final boolean isAdmin = mUm.isAdminUser();
final Activity activity = getActivity();
mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
@@ -247,17 +247,17 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
//enable/disable wimax depending on the value in config.xml
final boolean isWimaxEnabled = !isSecondaryUser && this.getResources().getBoolean(
final boolean isWimaxEnabled = isAdmin && this.getResources().getBoolean(
com.android.internal.R.bool.config_wimaxEnabled);
if (!isWimaxEnabled
|| mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
PreferenceScreen root = getPreferenceScreen();
Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
Preference ps = findPreference(KEY_WIMAX_SETTINGS);
if (ps != null) root.removePreference(ps);
} else {
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIMAX )
&& isWimaxEnabled) {
Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
Preference ps = findPreference(KEY_WIMAX_SETTINGS);
ps.setDependency(KEY_TOGGLE_AIRPLANE);
}
}
@@ -267,7 +267,8 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
}
// Disable VPN.
if (isSecondaryUser || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) {
// TODO: http://b/23693383
if (!isAdmin || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) {
removePreference(KEY_VPN_SETTINGS);
}
@@ -292,7 +293,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
// Remove Mobile Network Settings and Manage Mobile Plan for secondary users,
// if it's a wifi-only device, or if the settings are restricted.
if (isSecondaryUser || Utils.isWifiOnly(getActivity())
if (!isAdmin || Utils.isWifiOnly(getActivity())
|| mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
removePreference(KEY_MOBILE_NETWORK_SETTINGS);
removePreference(KEY_MANAGE_MOBILE_PLAN);
@@ -324,7 +325,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
// Disable Tethering if it's not allowed or if it's a wifi-only device
final ConnectivityManager cm =
(ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
if (isSecondaryUser || !cm.isTetheringSupported()
if (!isAdmin || !cm.isTetheringSupported()
|| mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
} else {
@@ -349,7 +350,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
} catch (IllegalArgumentException ignored) {
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
}
if (isSecondaryUser || !isCellBroadcastAppLinkEnabled
if (!isAdmin || !isCellBroadcastAppLinkEnabled
|| mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) {
PreferenceScreen root = getPreferenceScreen();
Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);

View File

@@ -24,8 +24,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.telephony.CellBroadcastMessage;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
@@ -43,7 +43,6 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.settings.InstrumentedPreferenceActivity;
import com.android.settings.R;
import com.android.settings.Utils;
import android.view.View;
import android.widget.ListView;
@@ -53,7 +52,6 @@ import android.widget.TabHost.TabContentFactory;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import java.util.ArrayList;
import java.util.List;
@@ -379,9 +377,10 @@ public class SimStatus extends InstrumentedPreferenceActivity {
private void updatePhoneInfos() {
if (mSir != null) {
// TODO: http://b/23763013
final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(
mSir.getSubscriptionId()));
if (UserHandle.myUserId() == UserHandle.USER_OWNER
if (UserManager.get(this).isAdminUser()
&& SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
if (phone == null) {
Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");

View File

@@ -238,7 +238,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
if (pkg != null) {
try {
if (userId == UserHandle.USER_ALL) {
userId = UserHandle.USER_OWNER;
userId = UserHandle.USER_SYSTEM;
}
r = mPm.getResourcesForApplicationAsUser(pkg, userId);
} catch (PackageManager.NameNotFoundException ex) {

View File

@@ -1004,7 +1004,7 @@ public class WifiSettings extends RestrictedSettingsFragment
if (deviceOwnerPackageName != null) {
try {
final int deviceOwnerUid = pm.getPackageUid(deviceOwnerPackageName,
UserHandle.USER_OWNER);
UserHandle.USER_SYSTEM);
isConfigEligibleForLockdown = deviceOwnerUid == config.creatorUid;
} catch (NameNotFoundException e) {
// don't care