The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.settings; |
| 18 | |
Maurice Lam | 2eb170c | 2017-04-28 16:18:47 -0700 | [diff] [blame] | 19 | import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; |
| 20 | |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 21 | import android.accounts.Account; |
| 22 | import android.accounts.AccountManager; |
| 23 | import android.accounts.AuthenticatorDescription; |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 24 | import android.app.ActionBar; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 25 | import android.app.Activity; |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 26 | import android.content.ComponentName; |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 27 | import android.content.ContentResolver; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 28 | import android.content.Context; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 29 | import android.content.Intent; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 30 | import android.content.pm.PackageManager; |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 31 | import android.content.pm.ResolveInfo; |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 32 | import android.content.pm.UserInfo; |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 33 | import android.content.res.Resources; |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 34 | import android.graphics.Color; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 35 | import android.graphics.drawable.Drawable; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 36 | import android.os.Bundle; |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 37 | import android.os.Environment; |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 38 | import android.os.SystemProperties; |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 39 | import android.os.UserHandle; |
Amith Yamasani | 7eedcf4 | 2013-07-02 14:15:29 -0700 | [diff] [blame] | 40 | import android.os.UserManager; |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 41 | import android.provider.Settings; |
qingxi | 072f286 | 2017-04-11 18:28:40 -0700 | [diff] [blame] | 42 | import android.telephony.euicc.EuiccManager; |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 43 | import android.text.TextUtils; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 44 | import android.util.Log; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 45 | import android.view.LayoutInflater; |
| 46 | import android.view.View; |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 47 | import android.view.View.OnScrollChangeListener; |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 48 | import android.view.ViewGroup; |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 49 | import android.view.ViewTreeObserver.OnGlobalLayoutListener; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 50 | import android.widget.Button; |
Dianne Hackborn | 1337d0f | 2010-10-14 11:58:30 -0700 | [diff] [blame] | 51 | import android.widget.CheckBox; |
Fan Zhang | 6b2bb39 | 2016-09-28 09:07:44 -0700 | [diff] [blame] | 52 | import android.widget.ImageView; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 53 | import android.widget.LinearLayout; |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 54 | import android.widget.ScrollView; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 55 | import android.widget.TextView; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 56 | |
Fan Zhang | 23f8d59 | 2018-08-28 15:11:40 -0700 | [diff] [blame] | 57 | import androidx.annotation.VisibleForTesting; |
| 58 | |
Tamas Berghammer | 265d3c2 | 2016-06-22 15:34:45 +0100 | [diff] [blame] | 59 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Doris Ling | 7248972 | 2017-11-16 11:03:40 -0800 | [diff] [blame] | 60 | import com.android.settings.core.InstrumentedFragment; |
Fan Zhang | 7cf99f5 | 2018-02-16 10:37:37 -0800 | [diff] [blame] | 61 | import com.android.settings.core.SubSettingLauncher; |
arangelov | e35badd | 2017-10-27 13:51:28 +0100 | [diff] [blame] | 62 | import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper; |
Maurice Lam | 2eb170c | 2017-04-28 16:18:47 -0700 | [diff] [blame] | 63 | import com.android.settings.password.ChooseLockSettingsHelper; |
| 64 | import com.android.settings.password.ConfirmLockPattern; |
Philip P. Moltmann | e3f7211 | 2018-08-28 15:01:43 -0700 | [diff] [blame] | 65 | import com.android.settingslib.RestrictedLockUtilsInternal; |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 66 | import com.android.setupwizardlib.TemplateLayout; |
| 67 | import com.android.setupwizardlib.template.ButtonFooterMixin; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 68 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 69 | import java.util.List; |
| 70 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 71 | /** |
| 72 | * Confirm and execute a reset of the device to a clean "just out of the box" |
| 73 | * state. Multiple confirmations are required: first, a general "are you sure |
| 74 | * you want to do this?" prompt, followed by a keyguard pattern trace if the user |
| 75 | * has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING |
| 76 | * ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is |
| 77 | * locked, et cetera, then the confirmation sequence is abandoned. |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 78 | * |
| 79 | * This is the initial screen. |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | */ |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 81 | public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutListener { |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 82 | private static final String TAG = "MasterClear"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 83 | |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 84 | @VisibleForTesting |
| 85 | static final int KEYGUARD_REQUEST = 55; |
| 86 | @VisibleForTesting |
| 87 | static final int CREDENTIAL_CONFIRM_REQUEST = 56; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 88 | |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 89 | private static final String KEY_SHOW_ESIM_RESET_CHECKBOX |
| 90 | = "masterclear.allow_retain_esim_profiles_after_fdr"; |
| 91 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 92 | static final String ERASE_EXTERNAL_EXTRA = "erase_sd"; |
qingxi | 072f286 | 2017-04-11 18:28:40 -0700 | [diff] [blame] | 93 | static final String ERASE_ESIMS_EXTRA = "erase_esim"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 94 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 95 | private View mContentView; |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 96 | @VisibleForTesting |
| 97 | Button mInitiateButton; |
Dianne Hackborn | 1337d0f | 2010-10-14 11:58:30 -0700 | [diff] [blame] | 98 | private View mExternalStorageContainer; |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 99 | @VisibleForTesting |
| 100 | CheckBox mExternalStorage; |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 101 | private View mEsimStorageContainer; |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 102 | @VisibleForTesting |
| 103 | CheckBox mEsimStorage; |
| 104 | @VisibleForTesting |
| 105 | ScrollView mScrollView; |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 106 | |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 107 | @Override |
| 108 | public void onGlobalLayout() { |
| 109 | mInitiateButton.setEnabled(hasReachedBottom(mScrollView)); |
| 110 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 111 | |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 112 | private void setUpActionBarAndTitle() { |
| 113 | final Activity activity = getActivity(); |
| 114 | if (activity == null) { |
| 115 | Log.e(TAG, "No activity attached, skipping setUpActionBarAndTitle"); |
| 116 | return; |
| 117 | } |
| 118 | final ActionBar actionBar = activity.getActionBar(); |
| 119 | if (actionBar == null) { |
| 120 | Log.e(TAG, "No actionbar, skipping setUpActionBarAndTitle"); |
| 121 | return; |
| 122 | } |
| 123 | actionBar.hide(); |
| 124 | activity.getWindow().setStatusBarColor(Color.TRANSPARENT); |
Doris Ling | 03a3b51 | 2017-10-18 14:25:01 -0700 | [diff] [blame] | 125 | } |
| 126 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 127 | /** |
Jim Miller | 2deec7e | 2010-04-13 17:43:36 -0700 | [diff] [blame] | 128 | * Keyguard validation is run using the standard {@link ConfirmLockPattern} |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 129 | * component as a subactivity |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 130 | * |
Jim Miller | 2deec7e | 2010-04-13 17:43:36 -0700 | [diff] [blame] | 131 | * @param request the request code to be returned once confirmation finishes |
| 132 | * @return true if confirmation launched |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 133 | */ |
Jim Miller | 2deec7e | 2010-04-13 17:43:36 -0700 | [diff] [blame] | 134 | private boolean runKeyguardConfirmation(int request) { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 135 | Resources res = getActivity().getResources(); |
Jorim Jaggi | 8a09b61 | 2015-04-06 17:47:18 -0700 | [diff] [blame] | 136 | return new ChooseLockSettingsHelper(getActivity(), this).launchConfirmationActivity( |
Fan Zhang | dc00efa | 2018-05-10 15:10:19 -0700 | [diff] [blame] | 137 | request, res.getText(R.string.master_clear_short_title)); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Carlos Valdivia | 5dd6ed4 | 2018-01-23 09:12:59 -0800 | [diff] [blame] | 140 | @VisibleForTesting |
| 141 | boolean isValidRequestCode(int requestCode) { |
| 142 | return !((requestCode != KEYGUARD_REQUEST) && (requestCode != CREDENTIAL_CONFIRM_REQUEST)); |
| 143 | } |
| 144 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 145 | @Override |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 146 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 147 | super.onActivityResult(requestCode, resultCode, data); |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 148 | onActivityResultInternal(requestCode, resultCode, data); |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | * Internal method that allows easy testing without dealing with super references. |
| 153 | */ |
| 154 | @VisibleForTesting |
| 155 | void onActivityResultInternal(int requestCode, int resultCode, Intent data) { |
Carlos Valdivia | 5dd6ed4 | 2018-01-23 09:12:59 -0800 | [diff] [blame] | 156 | if (!isValidRequestCode(requestCode)) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 157 | return; |
| 158 | } |
| 159 | |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 160 | if (resultCode != Activity.RESULT_OK) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 161 | establishInitialState(); |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 162 | return; |
| 163 | } |
| 164 | |
| 165 | Intent intent = null; |
| 166 | // If returning from a Keyguard request, try to show an account confirmation request if |
| 167 | // applciable. |
| 168 | if (CREDENTIAL_CONFIRM_REQUEST != requestCode |
| 169 | && (intent = getAccountConfirmationIntent()) != null) { |
| 170 | showAccountCredentialConfirmation(intent); |
| 171 | } else { |
| 172 | showFinalConfirmation(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
qingxi | 072f286 | 2017-04-11 18:28:40 -0700 | [diff] [blame] | 176 | @VisibleForTesting |
| 177 | void showFinalConfirmation() { |
Fan Zhang | 7cf99f5 | 2018-02-16 10:37:37 -0800 | [diff] [blame] | 178 | final Bundle args = new Bundle(); |
Stuart Scott | be90341 | 2014-07-24 19:22:06 -0700 | [diff] [blame] | 179 | args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked()); |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 180 | args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked()); |
Fan Zhang | 7cf99f5 | 2018-02-16 10:37:37 -0800 | [diff] [blame] | 181 | new SubSettingLauncher(getContext()) |
| 182 | .setDestination(MasterClearConfirm.class.getName()) |
| 183 | .setArguments(args) |
hjchangliao | e86eec0 | 2018-05-02 13:01:07 +0800 | [diff] [blame] | 184 | .setTitleRes(R.string.master_clear_confirm_title) |
Fan Zhang | 7cf99f5 | 2018-02-16 10:37:37 -0800 | [diff] [blame] | 185 | .setSourceMetricsCategory(getMetricsCategory()) |
| 186 | .launch(); |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 189 | @VisibleForTesting |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 190 | void showAccountCredentialConfirmation(Intent intent) { |
| 191 | startActivityForResult(intent, CREDENTIAL_CONFIRM_REQUEST); |
| 192 | } |
| 193 | |
| 194 | @VisibleForTesting |
| 195 | Intent getAccountConfirmationIntent() { |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 196 | final Context context = getActivity(); |
| 197 | final String accountType = context.getString(R.string.account_type); |
| 198 | final String packageName = context.getString(R.string.account_confirmation_package); |
Carlos Valdivia | 5114604 | 2018-01-23 17:17:56 -0800 | [diff] [blame] | 199 | final String className = context.getString(R.string.account_confirmation_class); |
| 200 | if (TextUtils.isEmpty(accountType) |
| 201 | || TextUtils.isEmpty(packageName) |
| 202 | || TextUtils.isEmpty(className)) { |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 203 | Log.i(TAG, "Resources not set for account confirmation."); |
| 204 | return null; |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 205 | } |
| 206 | final AccountManager am = AccountManager.get(context); |
| 207 | Account[] accounts = am.getAccountsByType(accountType); |
| 208 | if (accounts != null && accounts.length > 0) { |
| 209 | final Intent requestAccountConfirmation = new Intent() |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 210 | .setPackage(packageName) |
| 211 | .setComponent(new ComponentName(packageName, className)); |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 212 | // Check to make sure that the intent is supported. |
| 213 | final PackageManager pm = context.getPackageManager(); |
Carlos Valdivia | 08c8820 | 2018-01-21 18:57:28 -0800 | [diff] [blame] | 214 | final ResolveInfo resolution = pm.resolveActivity(requestAccountConfirmation, 0); |
| 215 | if (resolution != null |
| 216 | && resolution.activityInfo != null |
| 217 | && packageName.equals(resolution.activityInfo.packageName)) { |
| 218 | // Note that we need to check the packagename to make sure that an Activity resolver |
| 219 | // wasn't returned. |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 220 | return requestAccountConfirmation; |
| 221 | } else { |
| 222 | Log.i(TAG, "Unable to resolve Activity: " + packageName + "/" + className); |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 223 | } |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 224 | } else { |
| 225 | Log.d(TAG, "No " + accountType + " accounts installed!"); |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 226 | } |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 227 | return null; |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 228 | } |
| 229 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 230 | /** |
| 231 | * If the user clicks to begin the reset sequence, we next require a |
| 232 | * keyguard confirmation if the user has currently enabled one. If there |
| 233 | * is no keyguard available, we simply go to the final confirmation prompt. |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 234 | * |
| 235 | * If the user is in demo mode, route to the demo mode app for confirmation. |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 236 | */ |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 237 | @VisibleForTesting |
| 238 | protected final Button.OnClickListener mInitiateListener = new Button.OnClickListener() { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 239 | |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 240 | public void onClick(View view) { |
| 241 | final Context context = view.getContext(); |
| 242 | if (Utils.isDemoUser(context)) { |
Justin Klaassen | 3025727 | 2017-08-08 21:58:05 -0700 | [diff] [blame] | 243 | final ComponentName componentName = Utils.getDeviceOwnerComponent(context); |
| 244 | if (componentName != null) { |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 245 | final Intent requestFactoryReset = new Intent() |
Justin Klaassen | 3025727 | 2017-08-08 21:58:05 -0700 | [diff] [blame] | 246 | .setPackage(componentName.getPackageName()) |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 247 | .setAction(Intent.ACTION_FACTORY_RESET); |
| 248 | context.startActivity(requestFactoryReset); |
Christine Franks | d7713c9 | 2017-01-20 11:24:14 -0800 | [diff] [blame] | 249 | } |
Carlos Valdivia | a9736ed | 2018-01-16 13:59:31 -0800 | [diff] [blame] | 250 | return; |
| 251 | } |
| 252 | |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 253 | if (runKeyguardConfirmation(KEYGUARD_REQUEST)) { |
| 254 | return; |
| 255 | } |
| 256 | |
| 257 | Intent intent = getAccountConfirmationIntent(); |
| 258 | if (intent != null) { |
| 259 | showAccountCredentialConfirmation(intent); |
| 260 | } else { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 261 | showFinalConfirmation(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 262 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 263 | } |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 264 | }; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 265 | |
| 266 | /** |
| 267 | * In its initial state, the activity presents a button for the user to |
| 268 | * click in order to initiate a confirmation sequence. This method is |
| 269 | * called from various other points in the code to reset the activity to |
| 270 | * this base state. |
Jim Miller | 47d380f | 2010-01-20 13:37:14 -0800 | [diff] [blame] | 271 | * |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 272 | * <p>Reinflating views from resources is expensive and prevents us from |
| 273 | * caching widget pointers, so we use a single-inflate pattern: we lazy- |
| 274 | * inflate each view, caching all of the widget pointers we'll need at the |
| 275 | * time, then simply reuse the inflated views directly whenever we need |
| 276 | * to change contents. |
| 277 | */ |
Carlos Valdivia | 4b34dad | 2018-01-29 18:30:33 -0800 | [diff] [blame] | 278 | @VisibleForTesting |
| 279 | void establishInitialState() { |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 280 | setUpActionBarAndTitle(); |
| 281 | setUpInitiateButton(); |
| 282 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 283 | mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container); |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 284 | mExternalStorage = mContentView.findViewById(R.id.erase_external); |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 285 | mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container); |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 286 | mEsimStorage = mContentView.findViewById(R.id.erase_esim); |
| 287 | if (mScrollView != null) { |
| 288 | mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this); |
| 289 | } |
| 290 | mScrollView = mContentView.findViewById(R.id.master_clear_scrollview); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 291 | |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 292 | /* |
| 293 | * If the external storage is emulated, it will be erased with a factory |
| 294 | * reset at any rate. There is no need to have a separate option until |
| 295 | * we have a factory reset that only erases some directories and not |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 296 | * others. Likewise, if it's non-removable storage, it could potentially have been |
| 297 | * encrypted, and will also need to be wiped. |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 298 | */ |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 299 | boolean isExtStorageEmulated = Environment.isExternalStorageEmulated(); |
| 300 | if (isExtStorageEmulated |
| 301 | || (!Environment.isExternalStorageRemovable() && isExtStorageEncrypted())) { |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 302 | mExternalStorageContainer.setVisibility(View.GONE); |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 303 | |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 304 | final View externalOption = mContentView.findViewById(R.id.erase_external_option_text); |
| 305 | externalOption.setVisibility(View.GONE); |
| 306 | |
| 307 | final View externalAlsoErased = mContentView.findViewById(R.id.also_erases_external); |
| 308 | externalAlsoErased.setVisibility(View.VISIBLE); |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 309 | |
| 310 | // If it's not emulated, it is on a separate partition but it means we're doing |
| 311 | // a force wipe due to encryption. |
| 312 | mExternalStorage.setChecked(!isExtStorageEmulated); |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 313 | } else { |
| 314 | mExternalStorageContainer.setOnClickListener(new View.OnClickListener() { |
| 315 | |
| 316 | @Override |
| 317 | public void onClick(View v) { |
| 318 | mExternalStorage.toggle(); |
| 319 | } |
| 320 | }); |
| 321 | } |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 322 | |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 323 | if (showWipeEuicc()) { |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 324 | if (showWipeEuiccCheckbox()) { |
| 325 | TextView title = mContentView.findViewById(R.id.erase_esim_title); |
| 326 | title.setText(R.string.erase_esim_storage); |
| 327 | mEsimStorageContainer.setVisibility(View.VISIBLE); |
| 328 | mEsimStorageContainer.setOnClickListener(new View.OnClickListener() { |
| 329 | @Override |
| 330 | public void onClick(View v) { |
| 331 | mEsimStorage.toggle(); |
| 332 | } |
| 333 | }); |
| 334 | } else { |
| 335 | final View esimAlsoErased = mContentView.findViewById(R.id.also_erases_esim); |
| 336 | esimAlsoErased.setVisibility(View.VISIBLE); |
qingxi | 072f286 | 2017-04-11 18:28:40 -0700 | [diff] [blame] | 337 | |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 338 | final View noCancelMobilePlan = mContentView.findViewById( |
| 339 | R.id.no_cancel_mobile_plan); |
| 340 | noCancelMobilePlan.setVisibility(View.VISIBLE); |
| 341 | mEsimStorage.setChecked(true /* checked */); |
| 342 | } |
qingxi | 072f286 | 2017-04-11 18:28:40 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 345 | final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); |
| 346 | loadAccountList(um); |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 347 | final StringBuffer contentDescription = new StringBuffer(); |
| 348 | final View masterClearContainer = mContentView.findViewById(R.id.master_clear_container); |
Julia Reynolds | ce25af4 | 2015-07-08 16:56:31 -0400 | [diff] [blame] | 349 | getContentDescription(masterClearContainer, contentDescription); |
| 350 | masterClearContainer.setContentDescription(contentDescription); |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 351 | |
| 352 | // Set the status of initiateButton based on scrollview |
| 353 | mScrollView.setOnScrollChangeListener(new OnScrollChangeListener() { |
| 354 | @Override |
| 355 | public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 356 | int oldScrollY) { |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 357 | if (v instanceof ScrollView && hasReachedBottom((ScrollView) v)) { |
| 358 | mInitiateButton.setEnabled(true); |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 359 | mScrollView.setOnScrollChangeListener(null); |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | }); |
| 363 | |
| 364 | // Set the initial state of the initiateButton |
Doris Ling | 1f49715 | 2018-02-22 16:33:07 -0800 | [diff] [blame] | 365 | mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(this); |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 366 | } |
| 367 | |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 368 | /** |
Jeff Davidson | a0b8472 | 2017-07-26 17:38:41 -0700 | [diff] [blame] | 369 | * Whether to show strings indicating that the eUICC will be wiped. |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 370 | * |
Jeff Davidson | a0b8472 | 2017-07-26 17:38:41 -0700 | [diff] [blame] | 371 | * <p>We show the strings on any device which supports eUICC as long as the eUICC was ever |
Jeff Davidson | 4ba7478 | 2017-06-30 18:02:13 -0700 | [diff] [blame] | 372 | * provisioned (that is, at least one profile was ever downloaded onto it). |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 373 | */ |
| 374 | @VisibleForTesting |
| 375 | boolean showWipeEuicc() { |
| 376 | Context context = getContext(); |
| 377 | if (!isEuiccEnabled(context)) { |
| 378 | return false; |
| 379 | } |
| 380 | ContentResolver cr = context.getContentResolver(); |
Qingxi Li | e0681db | 2018-03-14 16:00:47 -0700 | [diff] [blame] | 381 | return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0 |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 382 | || Settings.Global.getInt( |
| 383 | cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | @VisibleForTesting |
Qingxi Li | c8a2b04 | 2018-01-11 11:35:07 -0800 | [diff] [blame] | 387 | boolean showWipeEuiccCheckbox() { |
| 388 | return SystemProperties |
| 389 | .getBoolean(KEY_SHOW_ESIM_RESET_CHECKBOX, false /* def */); |
| 390 | } |
| 391 | |
| 392 | @VisibleForTesting |
Jeff Davidson | f1c13fa | 2017-05-19 17:03:32 -0700 | [diff] [blame] | 393 | protected boolean isEuiccEnabled(Context context) { |
| 394 | EuiccManager euiccManager = (EuiccManager) context.getSystemService(Context.EUICC_SERVICE); |
| 395 | return euiccManager.isEnabled(); |
| 396 | } |
| 397 | |
jackqdyulei | 0b3edc7 | 2016-12-13 17:07:08 -0800 | [diff] [blame] | 398 | @VisibleForTesting |
| 399 | boolean hasReachedBottom(final ScrollView scrollView) { |
| 400 | if (scrollView.getChildCount() < 1) { |
| 401 | return true; |
| 402 | } |
| 403 | |
| 404 | final View view = scrollView.getChildAt(0); |
| 405 | final int diff = view.getBottom() - (scrollView.getHeight() + scrollView.getScrollY()); |
| 406 | |
| 407 | return diff <= 0; |
Julia Reynolds | ce25af4 | 2015-07-08 16:56:31 -0400 | [diff] [blame] | 408 | } |
| 409 | |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 410 | private void setUpInitiateButton() { |
| 411 | if (mInitiateButton != null) { |
| 412 | return; |
| 413 | } |
| 414 | |
| 415 | final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout); |
| 416 | final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class); |
| 417 | buttonFooterMixin.removeAllViews(); |
| 418 | buttonFooterMixin.addSpace(); |
| 419 | buttonFooterMixin.addSpace(); |
| 420 | mInitiateButton = buttonFooterMixin.addButton(R.string.master_clear_button_text, |
| 421 | R.style.SuwGlifButton_Primary); |
| 422 | mInitiateButton.setOnClickListener(mInitiateListener); |
| 423 | } |
| 424 | |
Julia Reynolds | ce25af4 | 2015-07-08 16:56:31 -0400 | [diff] [blame] | 425 | private void getContentDescription(View v, StringBuffer description) { |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 426 | if (v.getVisibility() != View.VISIBLE) { |
| 427 | return; |
| 428 | } |
| 429 | if (v instanceof ViewGroup) { |
| 430 | ViewGroup vGroup = (ViewGroup) v; |
| 431 | for (int i = 0; i < vGroup.getChildCount(); i++) { |
| 432 | View nextChild = vGroup.getChildAt(i); |
| 433 | getContentDescription(nextChild, description); |
| 434 | } |
| 435 | } else if (v instanceof TextView) { |
| 436 | TextView vText = (TextView) v; |
| 437 | description.append(vText.getText()); |
| 438 | description.append(","); // Allow Talkback to pause between sections. |
| 439 | } |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 440 | } |
| 441 | |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 442 | private boolean isExtStorageEncrypted() { |
| 443 | String state = SystemProperties.get("vold.decrypt"); |
| 444 | return !"".equals(state); |
| 445 | } |
| 446 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 447 | private void loadAccountList(final UserManager um) { |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 448 | View accountsLabel = mContentView.findViewById(R.id.accounts_label); |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 449 | LinearLayout contents = (LinearLayout) mContentView.findViewById(R.id.accounts); |
Amith Yamasani | 3f45de5 | 2011-09-22 14:34:17 -0700 | [diff] [blame] | 450 | contents.removeAllViews(); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 451 | |
| 452 | Context context = getActivity(); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 453 | final List<UserInfo> profiles = um.getProfiles(UserHandle.myUserId()); |
| 454 | final int profilesSize = profiles.size(); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 455 | |
| 456 | AccountManager mgr = AccountManager.get(context); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 457 | |
felkachang | a6cec47 | 2018-03-29 12:08:20 +0800 | [diff] [blame] | 458 | LayoutInflater inflater = (LayoutInflater) context.getSystemService( |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 459 | Context.LAYOUT_INFLATER_SERVICE); |
| 460 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 461 | int accountsCount = 0; |
| 462 | for (int profileIndex = 0; profileIndex < profilesSize; profileIndex++) { |
| 463 | final UserInfo userInfo = profiles.get(profileIndex); |
| 464 | final int profileId = userInfo.id; |
| 465 | final UserHandle userHandle = new UserHandle(profileId); |
| 466 | Account[] accounts = mgr.getAccountsAsUser(profileId); |
| 467 | final int N = accounts.length; |
| 468 | if (N == 0) { |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 469 | continue; |
| 470 | } |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 471 | accountsCount += N; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 472 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 473 | AuthenticatorDescription[] descs = AccountManager.get(context) |
| 474 | .getAuthenticatorTypesAsUser(profileId); |
| 475 | final int M = descs.length; |
| 476 | |
Bartosz Fabianowski | 30ba868 | 2017-04-19 11:51:43 +0200 | [diff] [blame] | 477 | if (profilesSize > 1) { |
| 478 | View titleView = Utils.inflateCategoryHeader(inflater, contents); |
| 479 | final TextView titleText = (TextView) titleView.findViewById(android.R.id.title); |
| 480 | titleText.setText(userInfo.isManagedProfile() ? R.string.category_work |
| 481 | : R.string.category_personal); |
| 482 | contents.addView(titleView); |
| 483 | } |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 484 | |
| 485 | for (int i = 0; i < N; i++) { |
| 486 | Account account = accounts[i]; |
| 487 | AuthenticatorDescription desc = null; |
| 488 | for (int j = 0; j < M; j++) { |
| 489 | if (account.type.equals(descs[j].type)) { |
| 490 | desc = descs[j]; |
| 491 | break; |
| 492 | } |
| 493 | } |
| 494 | if (desc == null) { |
| 495 | Log.w(TAG, "No descriptor for account name=" + account.name |
| 496 | + " type=" + account.type); |
| 497 | continue; |
| 498 | } |
| 499 | Drawable icon = null; |
| 500 | try { |
| 501 | if (desc.iconId != 0) { |
Zoltan Szatmary-Ban | 546790c | 2014-12-02 17:22:10 +0000 | [diff] [blame] | 502 | Context authContext = context.createPackageContextAsUser(desc.packageName, |
| 503 | 0, userHandle); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 504 | icon = context.getPackageManager().getUserBadgedIcon( |
| 505 | authContext.getDrawable(desc.iconId), userHandle); |
| 506 | } |
| 507 | } catch (PackageManager.NameNotFoundException e) { |
Rubin Xu | d1ce82a | 2015-06-08 17:21:19 +0100 | [diff] [blame] | 508 | Log.w(TAG, "Bad package name for account type " + desc.type); |
| 509 | } catch (Resources.NotFoundException e) { |
| 510 | Log.w(TAG, "Invalid icon id for account type " + desc.type, e); |
| 511 | } |
| 512 | if (icon == null) { |
| 513 | icon = context.getPackageManager().getDefaultActivityIcon(); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 514 | } |
| 515 | |
Fan Zhang | 6b2bb39 | 2016-09-28 09:07:44 -0700 | [diff] [blame] | 516 | View child = inflater.inflate(R.layout.master_clear_account, contents, false); |
| 517 | ((ImageView) child.findViewById(android.R.id.icon)).setImageDrawable(icon); |
| 518 | ((TextView) child.findViewById(android.R.id.title)).setText(account.name); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 519 | contents.addView(child); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 520 | } |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 521 | } |
| 522 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 523 | if (accountsCount > 0) { |
| 524 | accountsLabel.setVisibility(View.VISIBLE); |
| 525 | contents.setVisibility(View.VISIBLE); |
| 526 | } |
| 527 | // Checking for all other users and their profiles if any. |
| 528 | View otherUsers = mContentView.findViewById(R.id.other_users_present); |
| 529 | final boolean hasOtherUsers = (um.getUserCount() - profilesSize) > 0; |
| 530 | otherUsers.setVisibility(hasOtherUsers ? View.VISIBLE : View.GONE); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | @Override |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 534 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| 535 | Bundle savedInstanceState) { |
Christine Franks | 1478222 | 2017-01-23 16:44:02 -0800 | [diff] [blame] | 536 | final Context context = getContext(); |
Philip P. Moltmann | e3f7211 | 2018-08-28 15:01:43 -0700 | [diff] [blame] | 537 | final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfRestrictionEnforced(context, |
Christine Franks | 1478222 | 2017-01-23 16:44:02 -0800 | [diff] [blame] | 538 | UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId()); |
| 539 | final UserManager um = UserManager.get(context); |
Philip P. Moltmann | e3f7211 | 2018-08-28 15:01:43 -0700 | [diff] [blame] | 540 | final boolean disallow = !um.isAdminUser() || RestrictedLockUtilsInternal |
| 541 | .hasBaseUserRestriction(context, UserManager.DISALLOW_FACTORY_RESET, |
| 542 | UserHandle.myUserId()); |
Christine Franks | a09eb38 | 2017-06-23 14:28:21 -0700 | [diff] [blame] | 543 | if (disallow && !Utils.isDemoUser(context)) { |
Julia Reynolds | 2c53933 | 2014-06-11 12:56:02 -0400 | [diff] [blame] | 544 | return inflater.inflate(R.layout.master_clear_disallowed_screen, null); |
Sudheer Shanka | 7dbbe13 | 2016-02-16 14:19:32 +0000 | [diff] [blame] | 545 | } else if (admin != null) { |
arangelov | e35badd | 2017-10-27 13:51:28 +0100 | [diff] [blame] | 546 | new ActionDisabledByAdminDialogHelper(getActivity()) |
| 547 | .prepareDialogBuilder(UserManager.DISALLOW_FACTORY_RESET, admin) |
| 548 | .setOnDismissListener(__ -> getActivity().finish()) |
| 549 | .show(); |
| 550 | return new View(getContext()); |
Julia Reynolds | 2c53933 | 2014-06-11 12:56:02 -0400 | [diff] [blame] | 551 | } |
| 552 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 553 | mContentView = inflater.inflate(R.layout.master_clear, null); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 554 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 555 | establishInitialState(); |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 556 | return mContentView; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 557 | } |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 558 | |
| 559 | @Override |
Fan Zhang | 6507613 | 2016-08-08 10:25:13 -0700 | [diff] [blame] | 560 | public int getMetricsCategory() { |
Chris Wren | 9d1bfd1 | 2016-01-26 18:04:01 -0500 | [diff] [blame] | 561 | return MetricsEvent.MASTER_CLEAR; |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 562 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 563 | } |