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 | |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 19 | import android.accounts.Account; |
| 20 | import android.accounts.AccountManager; |
| 21 | import android.accounts.AuthenticatorDescription; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 22 | import android.app.Activity; |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 23 | import android.app.Fragment; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 24 | import android.content.Context; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 25 | import android.content.Intent; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 26 | import android.content.pm.PackageManager; |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 27 | import android.content.pm.UserInfo; |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 28 | import android.content.res.Resources; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 29 | import android.graphics.drawable.Drawable; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 30 | import android.os.Bundle; |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 31 | import android.os.Environment; |
Amith Yamasani | 4339a47 | 2014-10-22 13:51:53 -0700 | [diff] [blame] | 32 | import android.os.Process; |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 33 | import android.os.SystemProperties; |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 34 | import android.os.UserHandle; |
Amith Yamasani | 7eedcf4 | 2013-07-02 14:15:29 -0700 | [diff] [blame] | 35 | import android.os.UserManager; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 36 | import android.util.Log; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 37 | import android.view.LayoutInflater; |
| 38 | import android.view.View; |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 39 | import android.view.ViewGroup; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 40 | import android.widget.Button; |
Dianne Hackborn | 1337d0f | 2010-10-14 11:58:30 -0700 | [diff] [blame] | 41 | import android.widget.CheckBox; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 42 | import android.widget.LinearLayout; |
| 43 | import android.widget.TextView; |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 44 | import com.android.internal.logging.MetricsLogger; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 45 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 46 | import java.util.List; |
| 47 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 48 | /** |
| 49 | * Confirm and execute a reset of the device to a clean "just out of the box" |
| 50 | * state. Multiple confirmations are required: first, a general "are you sure |
| 51 | * you want to do this?" prompt, followed by a keyguard pattern trace if the user |
| 52 | * has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING |
| 53 | * ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is |
| 54 | * locked, et cetera, then the confirmation sequence is abandoned. |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 55 | * |
| 56 | * This is the initial screen. |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 57 | */ |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 58 | public class MasterClear extends InstrumentedFragment { |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 59 | private static final String TAG = "MasterClear"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 60 | |
| 61 | private static final int KEYGUARD_REQUEST = 55; |
| 62 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 63 | static final String ERASE_EXTERNAL_EXTRA = "erase_sd"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 64 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 65 | private View mContentView; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 66 | private Button mInitiateButton; |
Dianne Hackborn | 1337d0f | 2010-10-14 11:58:30 -0700 | [diff] [blame] | 67 | private View mExternalStorageContainer; |
| 68 | private CheckBox mExternalStorage; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 69 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 70 | /** |
Jim Miller | 2deec7e | 2010-04-13 17:43:36 -0700 | [diff] [blame] | 71 | * Keyguard validation is run using the standard {@link ConfirmLockPattern} |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 72 | * component as a subactivity |
Jim Miller | 2deec7e | 2010-04-13 17:43:36 -0700 | [diff] [blame] | 73 | * @param request the request code to be returned once confirmation finishes |
| 74 | * @return true if confirmation launched |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 75 | */ |
Jim Miller | 2deec7e | 2010-04-13 17:43:36 -0700 | [diff] [blame] | 76 | private boolean runKeyguardConfirmation(int request) { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 77 | Resources res = getActivity().getResources(); |
Jorim Jaggi | 8a09b61 | 2015-04-06 17:47:18 -0700 | [diff] [blame] | 78 | return new ChooseLockSettingsHelper(getActivity(), this).launchConfirmationActivity( |
| 79 | request, res.getText(R.string.master_clear_title)); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | @Override |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 83 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 84 | super.onActivityResult(requestCode, resultCode, data); |
| 85 | |
Julia Reynolds | 2c53933 | 2014-06-11 12:56:02 -0400 | [diff] [blame] | 86 | if (requestCode != KEYGUARD_REQUEST) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 87 | return; |
| 88 | } |
| 89 | |
| 90 | // If the user entered a valid keyguard trace, present the final |
| 91 | // confirmation prompt; otherwise, go back to the initial state. |
| 92 | if (resultCode == Activity.RESULT_OK) { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 93 | showFinalConfirmation(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 94 | } else { |
| 95 | establishInitialState(); |
| 96 | } |
| 97 | } |
| 98 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 99 | private void showFinalConfirmation() { |
Stuart Scott | be90341 | 2014-07-24 19:22:06 -0700 | [diff] [blame] | 100 | Bundle args = new Bundle(); |
| 101 | args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked()); |
| 102 | ((SettingsActivity) getActivity()).startPreferencePanel(MasterClearConfirm.class.getName(), |
| 103 | args, R.string.master_clear_confirm_title, null, null, 0); |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 104 | } |
| 105 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 106 | /** |
| 107 | * If the user clicks to begin the reset sequence, we next require a |
| 108 | * keyguard confirmation if the user has currently enabled one. If there |
| 109 | * is no keyguard available, we simply go to the final confirmation prompt. |
| 110 | */ |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 111 | private final Button.OnClickListener mInitiateListener = new Button.OnClickListener() { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 112 | |
| 113 | public void onClick(View v) { |
| 114 | if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) { |
| 115 | showFinalConfirmation(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 116 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 117 | } |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 118 | }; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * In its initial state, the activity presents a button for the user to |
| 122 | * click in order to initiate a confirmation sequence. This method is |
| 123 | * called from various other points in the code to reset the activity to |
| 124 | * this base state. |
Jim Miller | 47d380f | 2010-01-20 13:37:14 -0800 | [diff] [blame] | 125 | * |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 126 | * <p>Reinflating views from resources is expensive and prevents us from |
| 127 | * caching widget pointers, so we use a single-inflate pattern: we lazy- |
| 128 | * inflate each view, caching all of the widget pointers we'll need at the |
| 129 | * time, then simply reuse the inflated views directly whenever we need |
| 130 | * to change contents. |
| 131 | */ |
| 132 | private void establishInitialState() { |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 133 | mInitiateButton = (Button) mContentView.findViewById(R.id.initiate_master_clear); |
| 134 | mInitiateButton.setOnClickListener(mInitiateListener); |
| 135 | mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container); |
| 136 | mExternalStorage = (CheckBox) mContentView.findViewById(R.id.erase_external); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 137 | |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 138 | /* |
| 139 | * If the external storage is emulated, it will be erased with a factory |
| 140 | * reset at any rate. There is no need to have a separate option until |
| 141 | * we have a factory reset that only erases some directories and not |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 142 | * others. Likewise, if it's non-removable storage, it could potentially have been |
| 143 | * encrypted, and will also need to be wiped. |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 144 | */ |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 145 | boolean isExtStorageEmulated = Environment.isExternalStorageEmulated(); |
| 146 | if (isExtStorageEmulated |
| 147 | || (!Environment.isExternalStorageRemovable() && isExtStorageEncrypted())) { |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 148 | mExternalStorageContainer.setVisibility(View.GONE); |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 149 | |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 150 | final View externalOption = mContentView.findViewById(R.id.erase_external_option_text); |
| 151 | externalOption.setVisibility(View.GONE); |
| 152 | |
| 153 | final View externalAlsoErased = mContentView.findViewById(R.id.also_erases_external); |
| 154 | externalAlsoErased.setVisibility(View.VISIBLE); |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 155 | |
| 156 | // If it's not emulated, it is on a separate partition but it means we're doing |
| 157 | // a force wipe due to encryption. |
| 158 | mExternalStorage.setChecked(!isExtStorageEmulated); |
Kenny Root | 3785e39 | 2011-01-18 15:14:32 -0800 | [diff] [blame] | 159 | } else { |
| 160 | mExternalStorageContainer.setOnClickListener(new View.OnClickListener() { |
| 161 | |
| 162 | @Override |
| 163 | public void onClick(View v) { |
| 164 | mExternalStorage.toggle(); |
| 165 | } |
| 166 | }); |
| 167 | } |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 168 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 169 | final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); |
| 170 | loadAccountList(um); |
Julia Reynolds | ce25af4 | 2015-07-08 16:56:31 -0400 | [diff] [blame] | 171 | StringBuffer contentDescription = new StringBuffer(); |
| 172 | View masterClearContainer = mContentView.findViewById(R.id.master_clear_container); |
| 173 | getContentDescription(masterClearContainer, contentDescription); |
| 174 | masterClearContainer.setContentDescription(contentDescription); |
| 175 | } |
| 176 | |
| 177 | private void getContentDescription(View v, StringBuffer description) { |
| 178 | if (v instanceof ViewGroup) { |
| 179 | ViewGroup vGroup = (ViewGroup) v; |
| 180 | for (int i = 0; i < vGroup.getChildCount(); i++) { |
| 181 | View nextChild = vGroup.getChildAt(i); |
| 182 | getContentDescription(nextChild, description); |
| 183 | } |
| 184 | } else if (v instanceof TextView) { |
| 185 | TextView vText = (TextView) v; |
| 186 | description.append(vText.getText()); |
| 187 | description.append(","); // Allow Talkback to pause between sections. |
| 188 | } |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Ben Komalo | 2a32192 | 2011-09-07 16:42:34 -0700 | [diff] [blame] | 191 | private boolean isExtStorageEncrypted() { |
| 192 | String state = SystemProperties.get("vold.decrypt"); |
| 193 | return !"".equals(state); |
| 194 | } |
| 195 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 196 | private void loadAccountList(final UserManager um) { |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 197 | View accountsLabel = mContentView.findViewById(R.id.accounts_label); |
| 198 | LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts); |
Amith Yamasani | 3f45de5 | 2011-09-22 14:34:17 -0700 | [diff] [blame] | 199 | contents.removeAllViews(); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 200 | |
| 201 | Context context = getActivity(); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 202 | final List<UserInfo> profiles = um.getProfiles(UserHandle.myUserId()); |
| 203 | final int profilesSize = profiles.size(); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 204 | |
| 205 | AccountManager mgr = AccountManager.get(context); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 206 | |
| 207 | LayoutInflater inflater = (LayoutInflater)context.getSystemService( |
| 208 | Context.LAYOUT_INFLATER_SERVICE); |
| 209 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 210 | int accountsCount = 0; |
| 211 | for (int profileIndex = 0; profileIndex < profilesSize; profileIndex++) { |
| 212 | final UserInfo userInfo = profiles.get(profileIndex); |
| 213 | final int profileId = userInfo.id; |
| 214 | final UserHandle userHandle = new UserHandle(profileId); |
| 215 | Account[] accounts = mgr.getAccountsAsUser(profileId); |
| 216 | final int N = accounts.length; |
| 217 | if (N == 0) { |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 218 | continue; |
| 219 | } |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 220 | accountsCount += N; |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 221 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 222 | AuthenticatorDescription[] descs = AccountManager.get(context) |
| 223 | .getAuthenticatorTypesAsUser(profileId); |
| 224 | final int M = descs.length; |
| 225 | |
Zoltan Szatmary-Ban | 3af2e4c | 2014-12-19 17:17:23 +0000 | [diff] [blame] | 226 | View titleView = Utils.inflateCategoryHeader(inflater, contents); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 227 | final TextView titleText = (TextView) titleView.findViewById(android.R.id.title); |
| 228 | titleText.setText(userInfo.isManagedProfile() ? R.string.category_work |
| 229 | : R.string.category_personal); |
| 230 | contents.addView(titleView); |
| 231 | |
| 232 | for (int i = 0; i < N; i++) { |
| 233 | Account account = accounts[i]; |
| 234 | AuthenticatorDescription desc = null; |
| 235 | for (int j = 0; j < M; j++) { |
| 236 | if (account.type.equals(descs[j].type)) { |
| 237 | desc = descs[j]; |
| 238 | break; |
| 239 | } |
| 240 | } |
| 241 | if (desc == null) { |
| 242 | Log.w(TAG, "No descriptor for account name=" + account.name |
| 243 | + " type=" + account.type); |
| 244 | continue; |
| 245 | } |
| 246 | Drawable icon = null; |
| 247 | try { |
| 248 | if (desc.iconId != 0) { |
Zoltan Szatmary-Ban | 546790c | 2014-12-02 17:22:10 +0000 | [diff] [blame] | 249 | Context authContext = context.createPackageContextAsUser(desc.packageName, |
| 250 | 0, userHandle); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 251 | icon = context.getPackageManager().getUserBadgedIcon( |
| 252 | authContext.getDrawable(desc.iconId), userHandle); |
| 253 | } |
| 254 | } catch (PackageManager.NameNotFoundException e) { |
Rubin Xu | d1ce82a | 2015-06-08 17:21:19 +0100 | [diff] [blame] | 255 | Log.w(TAG, "Bad package name for account type " + desc.type); |
| 256 | } catch (Resources.NotFoundException e) { |
| 257 | Log.w(TAG, "Invalid icon id for account type " + desc.type, e); |
| 258 | } |
| 259 | if (icon == null) { |
| 260 | icon = context.getPackageManager().getDefaultActivityIcon(); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | TextView child = (TextView)inflater.inflate(R.layout.master_clear_account, |
| 264 | contents, false); |
| 265 | child.setText(account.name); |
Rubin Xu | d1ce82a | 2015-06-08 17:21:19 +0100 | [diff] [blame] | 266 | child.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 267 | contents.addView(child); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 268 | } |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 269 | } |
| 270 | |
Zoltan Szatmary-Ban | 7cc1b9e | 2014-10-24 18:03:18 +0100 | [diff] [blame] | 271 | if (accountsCount > 0) { |
| 272 | accountsLabel.setVisibility(View.VISIBLE); |
| 273 | contents.setVisibility(View.VISIBLE); |
| 274 | } |
| 275 | // Checking for all other users and their profiles if any. |
| 276 | View otherUsers = mContentView.findViewById(R.id.other_users_present); |
| 277 | final boolean hasOtherUsers = (um.getUserCount() - profilesSize) > 0; |
| 278 | otherUsers.setVisibility(hasOtherUsers ? View.VISIBLE : View.GONE); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | @Override |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 282 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| 283 | Bundle savedInstanceState) { |
Amith Yamasani | 4339a47 | 2014-10-22 13:51:53 -0700 | [diff] [blame] | 284 | if (!Process.myUserHandle().isOwner() |
| 285 | || UserManager.get(getActivity()).hasUserRestriction( |
Julia Reynolds | 2c53933 | 2014-06-11 12:56:02 -0400 | [diff] [blame] | 286 | UserManager.DISALLOW_FACTORY_RESET)) { |
| 287 | return inflater.inflate(R.layout.master_clear_disallowed_screen, null); |
| 288 | } |
| 289 | |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 290 | mContentView = inflater.inflate(R.layout.master_clear, null); |
Joe Onorato | b51886d | 2010-11-08 18:25:51 -0800 | [diff] [blame] | 291 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 292 | establishInitialState(); |
Amith Yamasani | b14e1e0 | 2010-11-02 09:52:29 -0700 | [diff] [blame] | 293 | return mContentView; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 294 | } |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 295 | |
| 296 | @Override |
| 297 | protected int getMetricsCategory() { |
| 298 | return MetricsLogger.MASTER_CLEAR; |
| 299 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 300 | } |