Prevents users from being added if device is not provisioned
Also added a utility function for checking provisioning, instead of repeating code for this check in several places. bug:26156445 Change-Id: I9f4a280dd0cdf889f892e386dbf6a3fdb2a052ef
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -68,8 +68,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
||||
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.
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -223,7 +223,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) {
|
||||
@@ -826,7 +826,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);
|
||||
|
Reference in New Issue
Block a user