diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 1b20eb06b99..75ad35debf6 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -339,9 +339,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); setIfOnlyAvailableForAdmins(true); - if (isUiRestricted() - || Settings.Global.getInt(getActivity().getContentResolver(), - Settings.Global.DEVICE_PROVISIONED, 0) == 0) { + if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) { // Block access to developer options if the user is not the owner, if user policy // restricts it, or if the device has not been provisioned mUnavailable = true; diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 0f510116905..ff7334bc344 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -231,8 +231,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In if (!mUm.isAdminUser()) return true; // Don't enable developer options until device has been provisioned - if (Settings.Global.getInt(getActivity().getContentResolver(), - Settings.Global.DEVICE_PROVISIONED, 0) == 0) { + if (!Utils.isDeviceProvisioned(getActivity())) { return true; } diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java index d521ded228f..393b76a31f4 100644 --- a/src/com/android/settings/MasterClearConfirm.java +++ b/src/com/android/settings/MasterClearConfirm.java @@ -68,8 +68,7 @@ public class MasterClearConfirm extends OptionsMenuFragment { getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE); if (pdbManager != null && !pdbManager.getOemUnlockEnabled() && - Settings.Global.getInt(getActivity().getContentResolver(), - Settings.Global.DEVICE_PROVISIONED, 0) != 0) { + Utils.isDeviceProvisioned(getActivity())) { // if OEM unlock is enabled, this will be wiped during FR process. If disabled, it // will be wiped here, unless the device is still being provisioned, in which case // the persistent data block will be preserved. diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 60973e143c0..84bb2ddc4a1 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -63,6 +63,7 @@ import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.Profile; import android.provider.ContactsContract.RawContacts; +import android.provider.Settings; import android.service.persistentdata.PersistentDataBlockManager; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; @@ -1100,5 +1101,10 @@ public final class Utils extends com.android.settingslib.Utils { } } } + + public static boolean isDeviceProvisioned(Context context) { + return Settings.Global.getInt(context.getContentResolver(), + Settings.Global.DEVICE_PROVISIONED, 0) != 0; + } } diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java index 29da205a7f9..67e423b3f9f 100644 --- a/src/com/android/settings/sim/SimSelectNotification.java +++ b/src/com/android/settings/sim/SimSelectNotification.java @@ -32,6 +32,7 @@ import android.util.Log; import com.android.internal.telephony.IccCardConstants; import com.android.settings.R; import com.android.settings.Settings.SimSettingsActivity; +import com.android.settings.Utils; import java.util.List; @@ -45,11 +46,9 @@ public class SimSelectNotification extends BroadcastReceiver { context.getSystemService(Context.TELEPHONY_SERVICE); final SubscriptionManager subscriptionManager = SubscriptionManager.from(context); final int numSlots = telephonyManager.getSimCount(); - final boolean isInProvisioning = Settings.Global.getInt(context.getContentResolver(), - Settings.Global.DEVICE_PROVISIONED, 0) == 0; - // Do not create notifications on single SIM devices or when provisiong i.e. Setup Wizard. - if (numSlots < 2 || isInProvisioning) { + // Do not create notifications on single SIM devices or when provisioning i.e. Setup Wizard. + if (numSlots < 2 || !Utils.isDeviceProvisioned(context)) { return; } diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java index e47a36e0c94..eb74c4bb699 100644 --- a/src/com/android/settings/users/UserSettings.java +++ b/src/com/android/settings/users/UserSettings.java @@ -224,7 +224,7 @@ public class UserSettings extends SettingsPreferenceFragment } mAddUser = (DimmableIconPreference) findPreference(KEY_ADD_USER); // Determine if add user/profile button should be visible - if (mUserCaps.mCanAddUser) { + if (mUserCaps.mCanAddUser && Utils.isDeviceProvisioned(getActivity())) { mAddUser.setOnPreferenceClickListener(this); // change label to only mention user, if restricted profiles are not supported if (!mUserCaps.mCanAddRestrictedProfile) { @@ -829,7 +829,8 @@ public class UserSettings extends SettingsPreferenceFragment } // Append Add user to the end of the list - if (mUserCaps.mCanAddUser || mUserCaps.mDisallowAddUserSetByAdmin) { + if ((mUserCaps.mCanAddUser || mUserCaps.mDisallowAddUserSetByAdmin) && + Utils.isDeviceProvisioned(getActivity())) { boolean moreUsers = mUserManager.canAddMoreUsers(); mAddUser.setOrder(Preference.DEFAULT_ORDER); preferenceScreen.addPreference(mAddUser);