Allow factory reset in carrier demo mode
Bug: 34341567 Test: manual - in carrier demo mode, go to Settings > Backup and Reset > Factory data reset > Reset phone > Erase everything and this entire path is viewable. Change-Id: Ia5491765241adad97ecdb0a5bfd86a8371b8e4fe
This commit is contained in:
@@ -326,11 +326,13 @@ public class MasterClear extends OptionsMenuFragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(
|
final Context context = getContext();
|
||||||
getActivity(), UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
|
final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(context,
|
||||||
final UserManager um = UserManager.get(getActivity());
|
UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
|
||||||
if (!um.isAdminUser() || RestrictedLockUtils.hasBaseUserRestriction(getActivity(),
|
final UserManager um = UserManager.get(context);
|
||||||
UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
|
final boolean disallow = !um.isAdminUser() || RestrictedLockUtils.hasBaseUserRestriction(
|
||||||
|
context, UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
|
||||||
|
if (disallow && !Utils.isCarrierDemoUser(context)) {
|
||||||
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
|
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
|
||||||
} else if (admin != null) {
|
} else if (admin != null) {
|
||||||
View view = inflater.inflate(R.layout.admin_support_details_empty_view, null);
|
View view = inflater.inflate(R.layout.admin_support_details_empty_view, null);
|
||||||
|
@@ -968,7 +968,8 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
|
|
||||||
// Enable/disable backup settings depending on whether the user is admin.
|
// Enable/disable backup settings depending on whether the user is admin.
|
||||||
setTileEnabled(new ComponentName(packageName,
|
setTileEnabled(new ComponentName(packageName,
|
||||||
BackupSettingsActivity.class.getName()), true, isAdmin);
|
BackupSettingsActivity.class.getName()), true,
|
||||||
|
isAdmin || Utils.isCarrierDemoUser(this));
|
||||||
setTileEnabled(new ComponentName(packageName,
|
setTileEnabled(new ComponentName(packageName,
|
||||||
"com.android.settings.BackupResetDashboardAlias"), true, isAdmin);
|
"com.android.settings.BackupResetDashboardAlias"), true, isAdmin);
|
||||||
|
|
||||||
|
@@ -1245,4 +1245,13 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCarrierDemoUser(Context context) {
|
||||||
|
final String carrierDemoModeSetting =
|
||||||
|
context.getString(com.android.internal.R.string.config_carrierDemoModeSetting);
|
||||||
|
return UserManager.isDeviceInDemoMode(context)
|
||||||
|
&& getUserManager(context).isDemoUser()
|
||||||
|
&& !TextUtils.isEmpty(carrierDemoModeSetting)
|
||||||
|
&& (Settings.Secure.getInt(context.getContentResolver(),
|
||||||
|
carrierDemoModeSetting, 0) == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user