Merge "Use user restriction instead of pin to guard factory reset in Settings."
This commit is contained in:
committed by
Android (Google) Code Review
commit
4ea24ecfbf
39
res/layout/master_clear_disallowed_screen.xml
Normal file
39
res/layout/master_clear_disallowed_screen.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/listContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ListView android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:drawSelectorOnTop="false"
|
||||||
|
android:scrollbarStyle="insideOverlay"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:cacheColorHint="@android:color/white"
|
||||||
|
android:fadingEdgeLength="16dip" />
|
||||||
|
|
||||||
|
<TextView android:id="@android:id/empty"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/master_clear_not_available"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
</FrameLayout>
|
@@ -2275,6 +2275,8 @@
|
|||||||
<string name="master_clear_failed">No reset was performed because the System Clear service isn\'t available.</string>
|
<string name="master_clear_failed">No reset was performed because the System Clear service isn\'t available.</string>
|
||||||
<!-- Master clear confirmation screen title [CHAR LIMIT=30] -->
|
<!-- Master clear confirmation screen title [CHAR LIMIT=30] -->
|
||||||
<string name="master_clear_confirm_title">Reset?</string>
|
<string name="master_clear_confirm_title">Reset?</string>
|
||||||
|
<!-- Error message for users that aren't allowed to factory reset [CHAR LIMIT=none] -->
|
||||||
|
<string name="master_clear_not_available">Factory reset is not available for this user</string>
|
||||||
|
|
||||||
<!-- Media Format -->
|
<!-- Media Format -->
|
||||||
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
||||||
|
@@ -40,12 +40,13 @@
|
|||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory android:key="personal_data_category"
|
||||||
android:title="@string/personal_data_section_title"/>
|
android:title="@string/personal_data_section_title">
|
||||||
<!-- Factory reset -->
|
<!-- Factory reset -->
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/master_clear_title"
|
android:title="@string/master_clear_title"
|
||||||
android:summary="@string/master_clear_summary"
|
android:summary="@string/master_clear_summary"
|
||||||
android:fragment="com.android.settings.MasterClear" />
|
android:fragment="com.android.settings.MasterClear" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -54,7 +54,6 @@ public class MasterClear extends Fragment {
|
|||||||
private static final String TAG = "MasterClear";
|
private static final String TAG = "MasterClear";
|
||||||
|
|
||||||
private static final int KEYGUARD_REQUEST = 55;
|
private static final int KEYGUARD_REQUEST = 55;
|
||||||
private static final int PIN_REQUEST = 56;
|
|
||||||
|
|
||||||
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
|
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
|
||||||
|
|
||||||
@@ -62,7 +61,6 @@ public class MasterClear extends Fragment {
|
|||||||
private Button mInitiateButton;
|
private Button mInitiateButton;
|
||||||
private View mExternalStorageContainer;
|
private View mExternalStorageContainer;
|
||||||
private CheckBox mExternalStorage;
|
private CheckBox mExternalStorage;
|
||||||
private boolean mPinConfirmed;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||||
@@ -78,25 +76,11 @@ public class MasterClear extends Fragment {
|
|||||||
res.getText(R.string.master_clear_gesture_explanation));
|
res.getText(R.string.master_clear_gesture_explanation));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean runRestrictionsChallenge() {
|
|
||||||
if (UserManager.get(getActivity()).hasRestrictionsChallenge()) {
|
|
||||||
startActivityForResult(
|
|
||||||
new Intent(Intent.ACTION_RESTRICTIONS_CHALLENGE), PIN_REQUEST);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
if (requestCode == PIN_REQUEST) {
|
if (requestCode != KEYGUARD_REQUEST) {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
|
||||||
mPinConfirmed = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (requestCode != KEYGUARD_REQUEST) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,10 +109,6 @@ public class MasterClear extends Fragment {
|
|||||||
private final Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
|
private final Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mPinConfirmed = false;
|
|
||||||
if (runRestrictionsChallenge()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
||||||
showFinalConfirmation();
|
showFinalConfirmation();
|
||||||
}
|
}
|
||||||
@@ -254,22 +234,14 @@ public class MasterClear extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
if (UserManager.get(getActivity()).hasUserRestriction(
|
||||||
|
UserManager.DISALLOW_FACTORY_RESET)) {
|
||||||
|
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
|
||||||
|
}
|
||||||
|
|
||||||
mContentView = inflater.inflate(R.layout.master_clear, null);
|
mContentView = inflater.inflate(R.layout.master_clear, null);
|
||||||
|
|
||||||
establishInitialState();
|
establishInitialState();
|
||||||
return mContentView;
|
return mContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
// If this is the second step after restrictions pin challenge
|
|
||||||
if (mPinConfirmed) {
|
|
||||||
mPinConfirmed = false;
|
|
||||||
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
|
||||||
showFinalConfirmation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import android.app.Fragment;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -80,6 +81,10 @@ public class MasterClearConfirm extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
if (UserManager.get(getActivity()).hasUserRestriction(
|
||||||
|
UserManager.DISALLOW_FACTORY_RESET)) {
|
||||||
|
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
|
||||||
|
}
|
||||||
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
|
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
|
||||||
establishFinalConfirmationState();
|
establishFinalConfirmationState();
|
||||||
return mContentView;
|
return mContentView;
|
||||||
|
@@ -26,6 +26,7 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
@@ -43,6 +44,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
private static final String BACKUP_DATA = "backup_data";
|
private static final String BACKUP_DATA = "backup_data";
|
||||||
private static final String AUTO_RESTORE = "auto_restore";
|
private static final String AUTO_RESTORE = "auto_restore";
|
||||||
private static final String CONFIGURE_ACCOUNT = "configure_account";
|
private static final String CONFIGURE_ACCOUNT = "configure_account";
|
||||||
|
private static final String PERSONAL_DATA_CATEGORY = "personal_data_category";
|
||||||
private IBackupManager mBackupManager;
|
private IBackupManager mBackupManager;
|
||||||
private CheckBoxPreference mBackup;
|
private CheckBoxPreference mBackup;
|
||||||
private CheckBoxPreference mAutoRestore;
|
private CheckBoxPreference mAutoRestore;
|
||||||
@@ -65,6 +67,11 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
mAutoRestore = (CheckBoxPreference) screen.findPreference(AUTO_RESTORE);
|
mAutoRestore = (CheckBoxPreference) screen.findPreference(AUTO_RESTORE);
|
||||||
mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
|
mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
|
||||||
|
|
||||||
|
if (UserManager.get(getActivity()).hasUserRestriction(
|
||||||
|
UserManager.DISALLOW_FACTORY_RESET)) {
|
||||||
|
screen.removePreference(findPreference(PERSONAL_DATA_CATEGORY));
|
||||||
|
}
|
||||||
|
|
||||||
// Vendor specific
|
// Vendor specific
|
||||||
if (getActivity().getPackageManager().
|
if (getActivity().getPackageManager().
|
||||||
resolveContentProvider(GSETTINGS_PROVIDER, 0) == null) {
|
resolveContentProvider(GSETTINGS_PROVIDER, 0) == null) {
|
||||||
|
Reference in New Issue
Block a user