2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.Manifest;
20 import android.app.Activity;
21 import android.app.ActivityManagerNative;
22 import android.app.AlertDialog;
23 import android.app.AppOpsManager;
24 import android.app.AppOpsManager.PackageOps;
25 import android.app.Dialog;
26 import android.app.admin.DevicePolicyManager;
27 import android.app.backup.IBackupManager;
28 import android.bluetooth.BluetoothAdapter;
29 import android.content.BroadcastReceiver;
30 import android.content.ComponentName;
31 import android.content.ContentResolver;
32 import android.content.Context;
33 import android.content.DialogInterface;
34 import android.content.Intent;
35 import android.content.IntentFilter;
36 import android.content.pm.ApplicationInfo;
37 import android.content.pm.IShortcutService;
38 import android.content.pm.PackageManager;
39 import android.content.pm.PackageManager.NameNotFoundException;
40 import android.content.pm.ResolveInfo;
41 import android.content.res.Resources;
42 import android.hardware.usb.IUsbManager;
43 import android.hardware.usb.UsbManager;
44 import android.net.wifi.WifiManager;
45 import android.os.AsyncTask;
46 import android.os.BatteryManager;
47 import android.os.Build;
48 import android.os.Bundle;
49 import android.os.IBinder;
50 import android.os.Parcel;
51 import android.os.RemoteException;
52 import android.os.ServiceManager;
53 import android.os.StrictMode;
54 import android.os.SystemProperties;
55 import android.os.UserHandle;
56 import android.os.UserManager;
57 import android.os.storage.IMountService;
58 import android.provider.SearchIndexableResource;
59 import android.provider.Settings;
60 import android.service.persistentdata.PersistentDataBlockManager;
61 import android.support.v14.preference.SwitchPreference;
62 import android.support.v7.preference.ListPreference;
63 import android.support.v7.preference.Preference;
64 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
65 import android.support.v7.preference.PreferenceGroup;
66 import android.support.v7.preference.PreferenceScreen;
67 import android.telephony.TelephonyManager;
68 import android.text.TextUtils;
69 import android.util.Log;
70 import android.view.IWindowManager;
71 import android.view.LayoutInflater;
72 import android.view.ThreadedRenderer;
73 import android.view.View;
74 import android.view.ViewGroup;
75 import android.view.accessibility.AccessibilityManager;
76 import android.webkit.IWebViewUpdateService;
77 import android.webkit.WebViewProviderInfo;
78 import android.widget.Switch;
79 import android.widget.Toast;
81 import com.android.internal.app.LocalePicker;
82 import com.android.internal.logging.MetricsProto.MetricsEvent;
83 import com.android.settings.applications.BackgroundCheckSummary;
84 import com.android.settings.fuelgauge.InactiveApps;
85 import com.android.settings.search.BaseSearchIndexProvider;
86 import com.android.settings.search.Indexable;
87 import com.android.settings.widget.SwitchBar;
88 import com.android.settingslib.RestrictedLockUtils;
89 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
90 import com.android.settingslib.RestrictedSwitchPreference;
92 import java.util.ArrayList;
93 import java.util.Arrays;
94 import java.util.HashSet;
95 import java.util.List;
98 * Displays preferences for application developers.
100 public class DevelopmentSettings extends RestrictedSettingsFragment
101 implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
102 OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable {
103 private static final String TAG = "DevelopmentSettings";
106 * Preference file were development settings prefs are stored.
108 public static final String PREF_FILE = "development";
111 * Whether to show the development settings to the user. Default is false.
113 public static final String PREF_SHOW = "show";
115 private static final String ENABLE_ADB = "enable_adb";
116 private static final String CLEAR_ADB_KEYS = "clear_adb_keys";
117 private static final String ENABLE_TERMINAL = "enable_terminal";
118 private static final String KEEP_SCREEN_ON = "keep_screen_on";
119 private static final String BT_HCI_SNOOP_LOG = "bt_hci_snoop_log";
120 private static final String WEBVIEW_PROVIDER_KEY = "select_webview_provider";
121 private static final String WEBVIEW_MULTIPROCESS_KEY = "enable_webview_multiprocess";
122 private static final String ENABLE_OEM_UNLOCK = "oem_unlock_enable";
123 private static final String HDCP_CHECKING_KEY = "hdcp_checking";
124 private static final String HDCP_CHECKING_PROPERTY = "persist.sys.hdcp_checking";
125 private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";
126 private static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw";
127 private static final String MSAA_PROPERTY = "debug.egl.force_msaa";
128 private static final String BUGREPORT = "bugreport";
129 private static final String BUGREPORT_IN_POWER_KEY = "bugreport_in_power";
130 private static final String OPENGL_TRACES_PROPERTY = "debug.egl.trace";
131 private static final String TUNER_UI_KEY = "tuner_ui";
132 private static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp";
134 private static final String DEBUG_APP_KEY = "debug_app";
135 private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
136 private static final String MOCK_LOCATION_APP_KEY = "mock_location_app";
137 private static final String VERIFY_APPS_OVER_USB_KEY = "verify_apps_over_usb";
138 private static final String DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
139 private static final String FORCE_ALLOW_ON_EXTERNAL_KEY = "force_allow_on_external";
140 private static final String STRICT_MODE_KEY = "strict_mode";
141 private static final String POINTER_LOCATION_KEY = "pointer_location";
142 private static final String SHOW_TOUCHES_KEY = "show_touches";
143 private static final String SHOW_SCREEN_UPDATES_KEY = "show_screen_updates";
144 private static final String DISABLE_OVERLAYS_KEY = "disable_overlays";
145 private static final String SIMULATE_COLOR_SPACE = "simulate_color_space";
146 private static final String USB_AUDIO_KEY = "usb_audio";
147 private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
148 private static final String FORCE_MSAA_KEY = "force_msaa";
149 private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
150 private static final String SHOW_NON_RECTANGULAR_CLIP_KEY = "show_non_rect_clip";
151 private static final String SHOW_HW_SCREEN_UPDATES_KEY = "show_hw_screen_udpates";
152 private static final String SHOW_HW_LAYERS_UPDATES_KEY = "show_hw_layers_udpates";
153 private static final String DEBUG_HW_OVERDRAW_KEY = "debug_hw_overdraw";
154 private static final String DEBUG_LAYOUT_KEY = "debug_layout";
155 private static final String FORCE_RTL_LAYOUT_KEY = "force_rtl_layout_all_locales";
156 private static final String WINDOW_ANIMATION_SCALE_KEY = "window_animation_scale";
157 private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
158 private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
159 private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
160 private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
161 private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
162 private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
163 private static final String SELECT_LOGD_TAG_PROPERTY = "persist.log.tag";
164 // Tricky, isLoggable only checks for first character, assumes silence
165 private static final String SELECT_LOGD_TAG_SILENCE = "Settings";
166 private static final String SELECT_LOGD_SNET_TAG_PROPERTY = "persist.log.tag.snet_event_log";
167 private static final String SELECT_LOGD_RUNTIME_SNET_TAG_PROPERTY = "log.tag.snet_event_log";
168 private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
169 private static final String SELECT_LOGD_DEFAULT_SIZE_VALUE = "262144";
170 private static final String SELECT_LOGD_SVELTE_DEFAULT_SIZE_VALUE = "65536";
171 // 32768 is merely a menu marker, 64K is our lowest log buffer size we replace it with.
172 private static final String SELECT_LOGD_MINIMUM_SIZE_VALUE = "65536";
173 private static final String SELECT_LOGD_OFF_SIZE_MARKER_VALUE = "32768";
174 private static final String SELECT_LOGPERSIST_KEY = "select_logpersist";
175 private static final String SELECT_LOGPERSIST_PROPERTY = "persist.logd.logpersistd";
176 private static final String ACTUAL_LOGPERSIST_PROPERTY = "logd.logpersistd";
177 private static final String SELECT_LOGPERSIST_PROPERTY_SERVICE = "logcatd";
178 private static final String SELECT_LOGPERSIST_PROPERTY_CLEAR = "clear";
179 private static final String SELECT_LOGPERSIST_PROPERTY_STOP = "stop";
180 private static final String SELECT_LOGPERSIST_PROPERTY_BUFFER = "persist.logd.logpersistd.buffer";
181 private static final String ACTUAL_LOGPERSIST_PROPERTY_BUFFER = "logd.logpersistd.buffer";
182 private static final String ACTUAL_LOGPERSIST_PROPERTY_ENABLE = "logd.logpersistd.enable";
184 private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification";
185 private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
186 private static final String WIFI_AGGRESSIVE_HANDOVER_KEY = "wifi_aggressive_handover";
187 private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic";
188 private static final String USB_CONFIGURATION_KEY = "select_usb_configuration";
189 private static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
190 private static final String KEY_COLOR_MODE = "color_mode";
191 private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
192 private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
194 private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY =
195 "bluetooth_disable_absolute_volume";
196 private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
197 "persist.bluetooth.disableabsvol";
199 private static final String INACTIVE_APPS_KEY = "inactive_apps";
201 private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY
202 = "immediately_destroy_activities";
203 private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit";
205 private static final String BACKGROUND_CHECK_KEY = "background_check";
207 private static final String SHOW_ALL_ANRS_KEY = "show_all_anrs";
209 private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
211 private static final String TERMINAL_APP_PACKAGE = "com.android.terminal";
213 private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
215 private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update";
217 private static final int RESULT_DEBUG_APP = 1000;
218 private static final int RESULT_MOCK_LOCATION_APP = 1001;
220 private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
221 private static final String FLASH_LOCKED_PROP = "ro.boot.flash.locked";
223 private static final String SHORTCUT_MANAGER_RESET_KEY = "reset_shortcut_manager_throttling";
225 private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
227 private static final int[] MOCK_LOCATION_APP_OPS = new int[] {AppOpsManager.OP_MOCK_LOCATION};
229 private IWindowManager mWindowManager;
230 private IBackupManager mBackupManager;
231 private IWebViewUpdateService mWebViewUpdateService;
232 private DevicePolicyManager mDpm;
233 private UserManager mUm;
234 private WifiManager mWifiManager;
235 private PersistentDataBlockManager mOemUnlockManager;
236 private TelephonyManager mTelephonyManager;
238 private SwitchBar mSwitchBar;
239 private boolean mLastEnabledState;
240 private boolean mHaveDebugSettings;
241 private boolean mDontPokeProperties;
243 private SwitchPreference mEnableAdb;
244 private Preference mClearAdbKeys;
245 private SwitchPreference mEnableTerminal;
246 private Preference mBugreport;
247 private SwitchPreference mBugreportInPower;
248 private RestrictedSwitchPreference mKeepScreenOn;
249 private SwitchPreference mBtHciSnoopLog;
250 private RestrictedSwitchPreference mEnableOemUnlock;
251 private SwitchPreference mDebugViewAttributes;
252 private SwitchPreference mForceAllowOnExternal;
254 private PreferenceScreen mPassword;
255 private String mDebugApp;
256 private Preference mDebugAppPref;
258 private String mMockLocationApp;
259 private Preference mMockLocationAppPref;
261 private SwitchPreference mWaitForDebugger;
262 private SwitchPreference mVerifyAppsOverUsb;
263 private SwitchPreference mWifiDisplayCertification;
264 private SwitchPreference mWifiVerboseLogging;
265 private SwitchPreference mWifiAggressiveHandover;
266 private SwitchPreference mMobileDataAlwaysOn;
267 private SwitchPreference mBluetoothDisableAbsVolume;
268 private SwitchPreference mOtaDisableAutomaticUpdate;
270 private SwitchPreference mWifiAllowScansWithTraffic;
271 private SwitchPreference mStrictMode;
272 private SwitchPreference mPointerLocation;
273 private SwitchPreference mShowTouches;
274 private SwitchPreference mShowScreenUpdates;
275 private SwitchPreference mDisableOverlays;
276 private SwitchPreference mForceHardwareUi;
277 private SwitchPreference mForceMsaa;
278 private SwitchPreference mShowHwScreenUpdates;
279 private SwitchPreference mShowHwLayersUpdates;
280 private SwitchPreference mDebugLayout;
281 private SwitchPreference mForceRtlLayout;
282 private ListPreference mDebugHwOverdraw;
283 private ListPreference mLogdSize;
284 private ListPreference mLogpersist;
285 private ListPreference mUsbConfiguration;
286 private ListPreference mTrackFrameTime;
287 private ListPreference mShowNonRectClip;
288 private ListPreference mWindowAnimationScale;
289 private ListPreference mTransitionAnimationScale;
290 private ListPreference mAnimatorDurationScale;
291 private ListPreference mOverlayDisplayDevices;
293 private SwitchPreference mWebViewMultiprocess;
294 private ListPreference mWebViewProvider;
296 private ListPreference mSimulateColorSpace;
298 private SwitchPreference mUSBAudio;
299 private SwitchPreference mImmediatelyDestroyActivities;
301 private ListPreference mAppProcessLimit;
303 private SwitchPreference mShowAllANRs;
305 private ColorModePreference mColorModePreference;
307 private SwitchPreference mForceResizable;
309 private SwitchPreference mColorTemperaturePreference;
311 private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
313 private final ArrayList<SwitchPreference> mResetSwitchPrefs
314 = new ArrayList<SwitchPreference>();
316 private final HashSet<Preference> mDisabledPrefs = new HashSet<Preference>();
317 // To track whether a confirmation dialog was clicked.
318 private boolean mDialogClicked;
319 private Dialog mEnableDialog;
320 private Dialog mAdbDialog;
322 private Dialog mAdbKeysDialog;
323 private boolean mUnavailable;
325 private boolean mLogpersistCleared;
326 private Dialog mLogpersistClearDialog;
328 public DevelopmentSettings() {
329 super(UserManager.DISALLOW_DEBUGGING_FEATURES);
333 protected int getMetricsCategory() {
334 return MetricsEvent.DEVELOPMENT;
338 public void onCreate(Bundle icicle) {
339 super.onCreate(icicle);
341 mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
342 mBackupManager = IBackupManager.Stub.asInterface(
343 ServiceManager.getService(Context.BACKUP_SERVICE));
344 mWebViewUpdateService =
345 IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
346 mOemUnlockManager = (PersistentDataBlockManager)getActivity()
347 .getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
348 mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
350 mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
351 mUm = (UserManager) getSystemService(Context.USER_SERVICE);
353 mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
355 setIfOnlyAvailableForAdmins(true);
356 if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
357 // Block access to developer options if the user is not the owner, if user policy
358 // restricts it, or if the device has not been provisioned
360 setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
364 addPreferencesFromResource(R.xml.development_prefs);
366 final PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
367 findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
368 mEnableAdb = findAndInitSwitchPref(ENABLE_ADB);
369 mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
370 if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
371 if (debugDebuggingCategory != null) {
372 debugDebuggingCategory.removePreference(mClearAdbKeys);
375 mAllPrefs.add(mClearAdbKeys);
376 mEnableTerminal = findAndInitSwitchPref(ENABLE_TERMINAL);
377 if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
378 debugDebuggingCategory.removePreference(mEnableTerminal);
379 mEnableTerminal = null;
382 mBugreport = findPreference(BUGREPORT);
383 mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY);
384 mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
385 mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
386 mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
387 if (!showEnableOemUnlockPreference()) {
388 removePreference(mEnableOemUnlock);
389 mEnableOemUnlock = null;
392 mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
393 mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
394 mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
395 mAllPrefs.add(mPassword);
397 if (!mUm.isAdminUser()) {
398 disableForUser(mEnableAdb);
399 disableForUser(mClearAdbKeys);
400 disableForUser(mEnableTerminal);
401 disableForUser(mPassword);
404 mDebugAppPref = findPreference(DEBUG_APP_KEY);
405 mAllPrefs.add(mDebugAppPref);
406 mWaitForDebugger = findAndInitSwitchPref(WAIT_FOR_DEBUGGER_KEY);
408 mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
409 mAllPrefs.add(mMockLocationAppPref);
411 mVerifyAppsOverUsb = findAndInitSwitchPref(VERIFY_APPS_OVER_USB_KEY);
412 if (!showVerifierSetting()) {
413 if (debugDebuggingCategory != null) {
414 debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
416 mVerifyAppsOverUsb.setEnabled(false);
419 mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
420 mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
421 mShowTouches = findAndInitSwitchPref(SHOW_TOUCHES_KEY);
422 mShowScreenUpdates = findAndInitSwitchPref(SHOW_SCREEN_UPDATES_KEY);
423 mDisableOverlays = findAndInitSwitchPref(DISABLE_OVERLAYS_KEY);
424 mForceHardwareUi = findAndInitSwitchPref(FORCE_HARDWARE_UI_KEY);
425 mForceMsaa = findAndInitSwitchPref(FORCE_MSAA_KEY);
426 mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
427 mShowNonRectClip = addListPreference(SHOW_NON_RECTANGULAR_CLIP_KEY);
428 mShowHwScreenUpdates = findAndInitSwitchPref(SHOW_HW_SCREEN_UPDATES_KEY);
429 mShowHwLayersUpdates = findAndInitSwitchPref(SHOW_HW_LAYERS_UPDATES_KEY);
430 mDebugLayout = findAndInitSwitchPref(DEBUG_LAYOUT_KEY);
431 mForceRtlLayout = findAndInitSwitchPref(FORCE_RTL_LAYOUT_KEY);
432 mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
433 mWifiDisplayCertification = findAndInitSwitchPref(WIFI_DISPLAY_CERTIFICATION_KEY);
434 mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
435 mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
436 mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
437 mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
438 mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
439 if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
440 mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
442 mLogpersist = (ListPreference) findPreference(SELECT_LOGPERSIST_KEY);
443 if (mLogpersist != null) {
444 mLogpersist.setEnabled(false);
445 if (debugDebuggingCategory != null) {
446 debugDebuggingCategory.removePreference(mLogpersist);
451 mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
452 mWebViewProvider = addListPreference(WEBVIEW_PROVIDER_KEY);
453 mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
454 mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
456 mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
457 mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
458 mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
459 mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
460 mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
461 mUSBAudio = findAndInitSwitchPref(USB_AUDIO_KEY);
462 mForceResizable = findAndInitSwitchPref(FORCE_RESIZABLE_KEY);
464 mImmediatelyDestroyActivities = (SwitchPreference) findPreference(
465 IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
466 mAllPrefs.add(mImmediatelyDestroyActivities);
467 mResetSwitchPrefs.add(mImmediatelyDestroyActivities);
469 mAppProcessLimit = addListPreference(APP_PROCESS_LIMIT_KEY);
471 mShowAllANRs = (SwitchPreference) findPreference(
473 mAllPrefs.add(mShowAllANRs);
474 mResetSwitchPrefs.add(mShowAllANRs);
476 Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
477 if (hdcpChecking != null) {
478 mAllPrefs.add(hdcpChecking);
479 removePreferenceForProduction(hdcpChecking);
482 PreferenceScreen convertFbePreference =
483 (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
486 IBinder service = ServiceManager.getService("mount");
487 IMountService mountService = IMountService.Stub.asInterface(service);
488 if (!mountService.isConvertibleToFBE()) {
489 removePreference(KEY_CONVERT_FBE);
490 } else if ("file".equals(SystemProperties.get("ro.crypto.type", "none"))) {
491 convertFbePreference.setEnabled(false);
492 convertFbePreference.setSummary(getResources()
493 .getString(R.string.convert_to_file_encryption_done));
495 } catch(RemoteException e) {
496 removePreference(KEY_CONVERT_FBE);
499 mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);
501 mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
502 mColorModePreference.updateCurrentAndSupported();
503 if (mColorModePreference.getColorModeCount() < 2) {
504 removePreference(KEY_COLOR_MODE);
505 mColorModePreference = null;
507 updateWebViewProviderOptions();
509 mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
510 if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
511 mAllPrefs.add(mColorTemperaturePreference);
512 mResetSwitchPrefs.add(mColorTemperaturePreference);
514 removePreference(COLOR_TEMPERATURE_KEY);
515 mColorTemperaturePreference = null;
519 private ListPreference addListPreference(String prefKey) {
520 ListPreference pref = (ListPreference) findPreference(prefKey);
522 pref.setOnPreferenceChangeListener(this);
526 private void disableForUser(Preference pref) {
528 pref.setEnabled(false);
529 mDisabledPrefs.add(pref);
533 private SwitchPreference findAndInitSwitchPref(String key) {
534 SwitchPreference pref = (SwitchPreference) findPreference(key);
536 throw new IllegalArgumentException("Cannot find preference with key = " + key);
539 mResetSwitchPrefs.add(pref);
544 public void onActivityCreated(Bundle savedInstanceState) {
545 super.onActivityCreated(savedInstanceState);
547 final SettingsActivity activity = (SettingsActivity) getActivity();
549 mSwitchBar = activity.getSwitchBar();
551 mSwitchBar.setEnabled(false);
555 mSwitchBar.addOnSwitchChangeListener(this);
558 private boolean removePreferenceForProduction(Preference preference) {
559 if ("user".equals(Build.TYPE)) {
560 removePreference(preference);
566 private void removePreference(Preference preference) {
567 getPreferenceScreen().removePreference(preference);
568 mAllPrefs.remove(preference);
569 mResetSwitchPrefs.remove(preference);
572 private void setPrefsEnabledState(boolean enabled) {
573 for (int i = 0; i < mAllPrefs.size(); i++) {
574 Preference pref = mAllPrefs.get(i);
575 pref.setEnabled(enabled && !mDisabledPrefs.contains(pref));
581 public void onResume() {
585 // Show error message
586 if (!isUiRestrictedByOnlyAdmin()) {
587 getEmptyTextView().setText(R.string.development_settings_not_available);
589 getPreferenceScreen().removeAll();
593 // A DeviceAdmin has specified a maximum time until the device
594 // will lock... in this case we can't allow the user to turn
595 // on "stay awake when plugged in" because that would defeat the
597 final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
599 mKeepScreenOn.setDisabledByAdmin(admin);
601 mDisabledPrefs.remove(mKeepScreenOn);
603 mDisabledPrefs.add(mKeepScreenOn);
606 final ContentResolver cr = getActivity().getContentResolver();
607 mLastEnabledState = Settings.Global.getInt(cr,
608 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
609 mSwitchBar.setChecked(mLastEnabledState);
610 setPrefsEnabledState(mLastEnabledState);
612 if (mHaveDebugSettings && !mLastEnabledState) {
613 // Overall debugging is disabled, but there are some debug
614 // settings that are enabled. This is an invalid state. Switch
615 // to debug settings being enabled, so the user knows there is
616 // stuff enabled and can turn it all off if they want.
617 Settings.Global.putInt(getActivity().getContentResolver(),
618 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
619 mLastEnabledState = true;
620 mSwitchBar.setChecked(mLastEnabledState);
621 setPrefsEnabledState(mLastEnabledState);
625 if (mColorModePreference != null) {
626 mColorModePreference.startListening();
627 mColorModePreference.updateCurrentAndSupported();
632 public void onPause() {
634 if (mColorModePreference != null) {
635 mColorModePreference.stopListening();
640 public View onCreateView(LayoutInflater inflater, ViewGroup container,
641 Bundle savedInstanceState) {
642 IntentFilter filter = new IntentFilter();
643 filter.addAction(UsbManager.ACTION_USB_STATE);
644 if (getActivity().registerReceiver(mUsbReceiver, filter) == null) {
645 updateUsbConfigurationValues();
647 return super.onCreateView(inflater, container, savedInstanceState);
651 public void onDestroyView() {
652 super.onDestroyView();
657 mSwitchBar.removeOnSwitchChangeListener(this);
659 getActivity().unregisterReceiver(mUsbReceiver);
662 void updateSwitchPreference(SwitchPreference switchPreference, boolean value) {
663 switchPreference.setChecked(value);
664 mHaveDebugSettings |= value;
667 private void updateAllOptions() {
668 final Context context = getActivity();
669 final ContentResolver cr = context.getContentResolver();
670 mHaveDebugSettings = false;
671 updateSwitchPreference(mEnableAdb, Settings.Global.getInt(cr,
672 Settings.Global.ADB_ENABLED, 0) != 0);
673 if (mEnableTerminal != null) {
674 updateSwitchPreference(mEnableTerminal,
675 context.getPackageManager().getApplicationEnabledSetting(TERMINAL_APP_PACKAGE)
676 == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
678 updateSwitchPreference(mBugreportInPower, Settings.Secure.getInt(cr,
679 Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0);
680 updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr,
681 Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
682 updateSwitchPreference(mBtHciSnoopLog, Settings.Secure.getInt(cr,
683 Settings.Secure.BLUETOOTH_HCI_LOG, 0) != 0);
684 updateSwitchPreference(mDebugViewAttributes, Settings.Global.getInt(cr,
685 Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0) != 0);
686 updateSwitchPreference(mForceAllowOnExternal, Settings.Global.getInt(cr,
687 Settings.Global.FORCE_ALLOW_ON_EXTERNAL, 0) != 0);
689 updatePasswordSummary();
690 updateDebuggerOptions();
691 updateMockLocation();
692 updateStrictModeVisualOptions();
693 updatePointerLocationOptions();
694 updateShowTouchesOptions();
695 updateFlingerOptions();
696 updateHardwareUiOptions();
698 updateTrackFrameTimeOptions();
699 updateShowNonRectClipOptions();
700 updateShowHwScreenUpdatesOptions();
701 updateShowHwLayersUpdatesOptions();
702 updateDebugHwOverdrawOptions();
703 updateDebugLayoutOptions();
704 updateAnimationScaleOptions();
705 updateOverlayDisplayDevicesOptions();
706 updateImmediatelyDestroyActivitiesOptions();
707 updateAppProcessLimitOptions();
708 updateShowAllANRsOptions();
709 updateVerifyAppsOverUsbOptions();
710 updateOtaDisableAutomaticUpdateOptions();
711 updateBugreportOptions();
712 updateForceRtlOptions();
713 updateLogdSizeValues();
714 updateLogpersistValues();
715 updateWifiDisplayCertificationOptions();
716 updateWifiVerboseLoggingOptions();
717 updateWifiAggressiveHandoverOptions();
718 updateWifiAllowScansWithTrafficOptions();
719 updateMobileDataAlwaysOnOptions();
720 updateSimulateColorSpace();
721 updateUSBAudioOptions();
722 updateForceResizableOptions();
723 updateWebViewMultiprocessOptions();
724 updateWebViewProviderOptions();
725 updateOemUnlockOptions();
726 if (mColorTemperaturePreference != null) {
727 updateColorTemperature();
729 updateBluetoothDisableAbsVolumeOptions();
732 private void resetDangerousOptions() {
733 mDontPokeProperties = true;
734 for (int i=0; i< mResetSwitchPrefs.size(); i++) {
735 SwitchPreference cb = mResetSwitchPrefs.get(i);
736 if (cb.isChecked()) {
737 cb.setChecked(false);
738 onPreferenceTreeClick(cb);
741 resetDebuggerOptions();
742 writeLogpersistOption(null, true);
743 writeLogdSizeOption(null);
744 writeAnimationScaleOption(0, mWindowAnimationScale, null);
745 writeAnimationScaleOption(1, mTransitionAnimationScale, null);
746 writeAnimationScaleOption(2, mAnimatorDurationScale, null);
747 // Only poke the color space setting if we control it.
748 if (usingDevelopmentColorSpace()) {
749 writeSimulateColorSpace(-1);
751 writeOverlayDisplayDevicesOptions(null);
752 writeAppProcessLimitOptions(null);
753 mHaveDebugSettings = false;
755 mDontPokeProperties = false;
756 pokeSystemProperties();
759 private void updateWebViewProviderOptions() {
761 WebViewProviderInfo[] providers = mWebViewUpdateService.getValidWebViewPackages();
762 if (providers == null) {
763 Log.e(TAG, "No WebView providers available");
766 ArrayList<String> options = new ArrayList<String>();
767 ArrayList<String> values = new ArrayList<String>();
768 for(int n = 0; n < providers.length; n++) {
769 if (Utils.isPackageEnabled(getActivity(), providers[n].packageName)) {
770 options.add(providers[n].description);
771 values.add(providers[n].packageName);
774 mWebViewProvider.setEntries(options.toArray(new String[options.size()]));
775 mWebViewProvider.setEntryValues(values.toArray(new String[values.size()]));
777 String value = mWebViewUpdateService.getCurrentWebViewPackageName();
782 for (int i = 0; i < values.size(); i++) {
783 if (value.contentEquals(values.get(i))) {
784 mWebViewProvider.setValueIndex(i);
788 } catch(RemoteException e) {
792 private void updateWebViewMultiprocessOptions() {
793 updateSwitchPreference(mWebViewMultiprocess,
794 Settings.Global.getInt(getActivity().getContentResolver(),
795 Settings.Global.WEBVIEW_MULTIPROCESS, 0) != 0);
798 private void writeWebViewMultiprocessOptions() {
799 boolean value = mWebViewMultiprocess.isChecked();
800 Settings.Global.putInt(getActivity().getContentResolver(),
801 Settings.Global.WEBVIEW_MULTIPROCESS, value ? 1 : 0);
804 String wv_package = mWebViewUpdateService.getCurrentWebViewPackageName();
805 ActivityManagerNative.getDefault().killPackageDependents(
806 wv_package, UserHandle.USER_ALL);
807 } catch(RemoteException e) {
811 private void updateHdcpValues() {
812 ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY);
813 if (hdcpChecking != null) {
814 String currentValue = SystemProperties.get(HDCP_CHECKING_PROPERTY);
815 String[] values = getResources().getStringArray(R.array.hdcp_checking_values);
816 String[] summaries = getResources().getStringArray(R.array.hdcp_checking_summaries);
817 int index = 1; // Defaults to drm-only. Needs to match with R.array.hdcp_checking_values
818 for (int i = 0; i < values.length; i++) {
819 if (currentValue.equals(values[i])) {
824 hdcpChecking.setValue(values[index]);
825 hdcpChecking.setSummary(summaries[index]);
826 hdcpChecking.setOnPreferenceChangeListener(this);
830 private void updatePasswordSummary() {
832 if (mBackupManager.hasBackupPassword()) {
833 mPassword.setSummary(R.string.local_backup_password_summary_change);
835 mPassword.setSummary(R.string.local_backup_password_summary_none);
837 } catch (RemoteException e) {
838 // Not much we can do here
842 private void writeBtHciSnoopLogOptions() {
843 BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
844 adapter.configHciSnoopLog(mBtHciSnoopLog.isChecked());
845 Settings.Secure.putInt(getActivity().getContentResolver(),
846 Settings.Secure.BLUETOOTH_HCI_LOG,
847 mBtHciSnoopLog.isChecked() ? 1 : 0);
850 private boolean writeWebViewProviderOptions(Object newValue) {
852 String updatedProvider = mWebViewUpdateService.changeProviderAndSetting(
853 newValue == null ? "" : newValue.toString());
854 updateWebViewProviderOptions();
855 return newValue != null && newValue.equals(updatedProvider);
856 } catch(RemoteException e) {
861 private void writeDebuggerOptions() {
863 ActivityManagerNative.getDefault().setDebugApp(
864 mDebugApp, mWaitForDebugger.isChecked(), true);
865 } catch (RemoteException ex) {
869 private void writeMockLocation() {
870 AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
872 // Disable the app op of the previous mock location app if such.
873 List<PackageOps> packageOps = appOpsManager.getPackagesForOps(MOCK_LOCATION_APP_OPS);
874 if (packageOps != null) {
875 // Should be one but in case we are in a bad state due to use of command line tools.
876 for (PackageOps packageOp : packageOps) {
877 if (packageOp.getOps().get(0).getMode() != AppOpsManager.MODE_ERRORED) {
878 String oldMockLocationApp = packageOp.getPackageName();
880 ApplicationInfo ai = getActivity().getPackageManager().getApplicationInfo(
881 oldMockLocationApp, PackageManager.GET_DISABLED_COMPONENTS);
882 appOpsManager.setMode(AppOpsManager.OP_MOCK_LOCATION, ai.uid,
883 oldMockLocationApp, AppOpsManager.MODE_ERRORED);
884 } catch (NameNotFoundException e) {
891 // Enable the app op of the new mock location app if such.
892 if (!TextUtils.isEmpty(mMockLocationApp)) {
894 ApplicationInfo ai = getActivity().getPackageManager().getApplicationInfo(
895 mMockLocationApp, PackageManager.GET_DISABLED_COMPONENTS);
896 appOpsManager.setMode(AppOpsManager.OP_MOCK_LOCATION, ai.uid,
897 mMockLocationApp, AppOpsManager.MODE_ALLOWED);
898 } catch (NameNotFoundException e) {
904 private static void resetDebuggerOptions() {
906 ActivityManagerNative.getDefault().setDebugApp(
908 } catch (RemoteException ex) {
912 private void updateDebuggerOptions() {
913 mDebugApp = Settings.Global.getString(
914 getActivity().getContentResolver(), Settings.Global.DEBUG_APP);
915 updateSwitchPreference(mWaitForDebugger, Settings.Global.getInt(
916 getActivity().getContentResolver(), Settings.Global.WAIT_FOR_DEBUGGER, 0) != 0);
917 if (mDebugApp != null && mDebugApp.length() > 0) {
920 ApplicationInfo ai = getActivity().getPackageManager().getApplicationInfo(mDebugApp,
921 PackageManager.GET_DISABLED_COMPONENTS);
922 CharSequence lab = getActivity().getPackageManager().getApplicationLabel(ai);
923 label = lab != null ? lab.toString() : mDebugApp;
924 } catch (PackageManager.NameNotFoundException e) {
927 mDebugAppPref.setSummary(getResources().getString(R.string.debug_app_set, label));
928 mWaitForDebugger.setEnabled(true);
929 mHaveDebugSettings = true;
931 mDebugAppPref.setSummary(getResources().getString(R.string.debug_app_not_set));
932 mWaitForDebugger.setEnabled(false);
936 private void updateMockLocation() {
937 AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
939 List<PackageOps> packageOps = appOpsManager.getPackagesForOps(MOCK_LOCATION_APP_OPS);
940 if (packageOps != null) {
941 for (PackageOps packageOp : packageOps) {
942 if (packageOp.getOps().get(0).getMode() == AppOpsManager.MODE_ALLOWED) {
943 mMockLocationApp = packageOps.get(0).getPackageName();
949 if (!TextUtils.isEmpty(mMockLocationApp)) {
950 String label = mMockLocationApp;
952 ApplicationInfo ai = getActivity().getPackageManager().getApplicationInfo(
953 mMockLocationApp, PackageManager.GET_DISABLED_COMPONENTS);
954 CharSequence appLabel = getPackageManager().getApplicationLabel(ai);
955 if (appLabel != null) {
956 label = appLabel.toString();
958 } catch (PackageManager.NameNotFoundException e) {
962 mMockLocationAppPref.setSummary(getString(R.string.mock_location_app_set, label));
963 mHaveDebugSettings = true;
965 mMockLocationAppPref.setSummary(getString(R.string.mock_location_app_not_set));
969 private void updateVerifyAppsOverUsbOptions() {
970 updateSwitchPreference(mVerifyAppsOverUsb, Settings.Global.getInt(getActivity().getContentResolver(),
971 Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0);
972 mVerifyAppsOverUsb.setEnabled(enableVerifierSetting());
975 private void writeVerifyAppsOverUsbOptions() {
976 Settings.Global.putInt(getActivity().getContentResolver(),
977 Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB,
978 mVerifyAppsOverUsb.isChecked() ? 1 : 0);
981 private void updateOtaDisableAutomaticUpdateOptions() {
982 // We use the "disabled status" in code, but show the opposite text
983 // "Automatic system updates" on screen. So a value 0 indicates the
984 // automatic update is enabled.
985 updateSwitchPreference(mOtaDisableAutomaticUpdate, Settings.Global.getInt(
986 getActivity().getContentResolver(),
987 Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, 0) != 1);
990 private void writeOtaDisableAutomaticUpdateOptions() {
991 // We use the "disabled status" in code, but show the opposite text
992 // "Automatic system updates" on screen. So a value 0 indicates the
993 // automatic update is enabled.
994 Settings.Global.putInt(getActivity().getContentResolver(),
995 Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
996 mOtaDisableAutomaticUpdate.isChecked() ? 0 : 1);
999 private boolean enableVerifierSetting() {
1000 final ContentResolver cr = getActivity().getContentResolver();
1001 if (Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) == 0) {
1004 if (Settings.Global.getInt(cr, Settings.Global.PACKAGE_VERIFIER_ENABLE, 1) == 0) {
1007 final PackageManager pm = getActivity().getPackageManager();
1008 final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
1009 verification.setType(PACKAGE_MIME_TYPE);
1010 verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
1011 final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(verification, 0);
1012 if (receivers.size() == 0) {
1019 private boolean showVerifierSetting() {
1020 return Settings.Global.getInt(getActivity().getContentResolver(),
1021 Settings.Global.PACKAGE_VERIFIER_SETTING_VISIBLE, 1) > 0;
1024 private static boolean showEnableOemUnlockPreference() {
1025 return !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("");
1028 private boolean enableOemUnlockPreference() {
1029 return !isBootloaderUnlocked() && isOemUnlockAllowed();
1032 private void updateOemUnlockOptions() {
1033 if (mEnableOemUnlock != null) {
1034 updateSwitchPreference(mEnableOemUnlock, Utils.isOemUnlockEnabled(getActivity()));
1035 updateOemUnlockSettingDescription();
1036 // Showing mEnableOemUnlock preference as device has persistent data block.
1037 mEnableOemUnlock.setDisabledByAdmin(null);
1038 mEnableOemUnlock.setEnabled(enableOemUnlockPreference());
1039 if (mEnableOemUnlock.isEnabled()) {
1040 // Check restriction, disable mEnableOemUnlock and apply policy transparency.
1041 mEnableOemUnlock.checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
1043 if (mEnableOemUnlock.isEnabled()) {
1044 // Check restriction, disable mEnableOemUnlock and apply policy transparency.
1045 mEnableOemUnlock.checkRestrictionAndSetDisabled(UserManager.DISALLOW_OEM_UNLOCK);
1050 private void updateBugreportOptions() {
1051 mBugreport.setEnabled(true);
1052 mBugreportInPower.setEnabled(true);
1053 setBugreportStorageProviderStatus();
1056 private void setBugreportStorageProviderStatus() {
1057 final ComponentName componentName = new ComponentName("com.android.shell",
1058 "com.android.shell.BugreportStorageProvider");
1059 final boolean enabled = mBugreportInPower.isChecked();
1060 getPackageManager().setComponentEnabledSetting(componentName,
1061 enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
1062 : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
1066 // Returns the current state of the system property that controls
1067 // strictmode flashes. One of:
1068 // 0: not explicitly set one way or another
1071 private static int currentStrictModeActiveIndex() {
1072 if (TextUtils.isEmpty(SystemProperties.get(StrictMode.VISUAL_PROPERTY))) {
1075 boolean enabled = SystemProperties.getBoolean(StrictMode.VISUAL_PROPERTY, false);
1076 return enabled ? 1 : 2;
1079 private void writeStrictModeVisualOptions() {
1081 mWindowManager.setStrictModeVisualIndicatorPreference(mStrictMode.isChecked()
1083 } catch (RemoteException e) {
1087 private void updateStrictModeVisualOptions() {
1088 updateSwitchPreference(mStrictMode, currentStrictModeActiveIndex() == 1);
1091 private void writePointerLocationOptions() {
1092 Settings.System.putInt(getActivity().getContentResolver(),
1093 Settings.System.POINTER_LOCATION, mPointerLocation.isChecked() ? 1 : 0);
1096 private void updatePointerLocationOptions() {
1097 updateSwitchPreference(mPointerLocation,
1098 Settings.System.getInt(getActivity().getContentResolver(),
1099 Settings.System.POINTER_LOCATION, 0) != 0);
1102 private void writeShowTouchesOptions() {
1103 Settings.System.putInt(getActivity().getContentResolver(),
1104 Settings.System.SHOW_TOUCHES, mShowTouches.isChecked() ? 1 : 0);
1107 private void updateShowTouchesOptions() {
1108 updateSwitchPreference(mShowTouches,
1109 Settings.System.getInt(getActivity().getContentResolver(),
1110 Settings.System.SHOW_TOUCHES, 0) != 0);
1113 private void updateFlingerOptions() {
1114 // magic communication with surface flinger.
1116 IBinder flinger = ServiceManager.getService("SurfaceFlinger");
1117 if (flinger != null) {
1118 Parcel data = Parcel.obtain();
1119 Parcel reply = Parcel.obtain();
1120 data.writeInterfaceToken("android.ui.ISurfaceComposer");
1121 flinger.transact(1010, data, reply, 0);
1122 @SuppressWarnings("unused")
1123 int showCpu = reply.readInt();
1124 @SuppressWarnings("unused")
1125 int enableGL = reply.readInt();
1126 int showUpdates = reply.readInt();
1127 updateSwitchPreference(mShowScreenUpdates, showUpdates != 0);
1128 @SuppressWarnings("unused")
1129 int showBackground = reply.readInt();
1130 int disableOverlays = reply.readInt();
1131 updateSwitchPreference(mDisableOverlays, disableOverlays != 0);
1135 } catch (RemoteException ex) {
1139 private void writeShowUpdatesOption() {
1141 IBinder flinger = ServiceManager.getService("SurfaceFlinger");
1142 if (flinger != null) {
1143 Parcel data = Parcel.obtain();
1144 data.writeInterfaceToken("android.ui.ISurfaceComposer");
1145 final int showUpdates = mShowScreenUpdates.isChecked() ? 1 : 0;
1146 data.writeInt(showUpdates);
1147 flinger.transact(1002, data, null, 0);
1150 updateFlingerOptions();
1152 } catch (RemoteException ex) {
1156 private void writeDisableOverlaysOption() {
1158 IBinder flinger = ServiceManager.getService("SurfaceFlinger");
1159 if (flinger != null) {
1160 Parcel data = Parcel.obtain();
1161 data.writeInterfaceToken("android.ui.ISurfaceComposer");
1162 final int disableOverlays = mDisableOverlays.isChecked() ? 1 : 0;
1163 data.writeInt(disableOverlays);
1164 flinger.transact(1008, data, null, 0);
1167 updateFlingerOptions();
1169 } catch (RemoteException ex) {
1173 private void updateHardwareUiOptions() {
1174 updateSwitchPreference(mForceHardwareUi,
1175 SystemProperties.getBoolean(HARDWARE_UI_PROPERTY, false));
1178 private void writeHardwareUiOptions() {
1179 SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
1180 pokeSystemProperties();
1183 private void updateMsaaOptions() {
1184 updateSwitchPreference(mForceMsaa, SystemProperties.getBoolean(MSAA_PROPERTY, false));
1187 private void writeMsaaOptions() {
1188 SystemProperties.set(MSAA_PROPERTY, mForceMsaa.isChecked() ? "true" : "false");
1189 pokeSystemProperties();
1192 private void updateTrackFrameTimeOptions() {
1193 String value = SystemProperties.get(ThreadedRenderer.PROFILE_PROPERTY);
1194 if (value == null) {
1198 CharSequence[] values = mTrackFrameTime.getEntryValues();
1199 for (int i = 0; i < values.length; i++) {
1200 if (value.contentEquals(values[i])) {
1201 mTrackFrameTime.setValueIndex(i);
1202 mTrackFrameTime.setSummary(mTrackFrameTime.getEntries()[i]);
1206 mTrackFrameTime.setValueIndex(0);
1207 mTrackFrameTime.setSummary(mTrackFrameTime.getEntries()[0]);
1210 private void writeTrackFrameTimeOptions(Object newValue) {
1211 SystemProperties.set(ThreadedRenderer.PROFILE_PROPERTY,
1212 newValue == null ? "" : newValue.toString());
1213 pokeSystemProperties();
1214 updateTrackFrameTimeOptions();
1217 private void updateShowNonRectClipOptions() {
1218 String value = SystemProperties.get(
1219 ThreadedRenderer.DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY);
1220 if (value == null) {
1224 CharSequence[] values = mShowNonRectClip.getEntryValues();
1225 for (int i = 0; i < values.length; i++) {
1226 if (value.contentEquals(values[i])) {
1227 mShowNonRectClip.setValueIndex(i);
1228 mShowNonRectClip.setSummary(mShowNonRectClip.getEntries()[i]);
1232 mShowNonRectClip.setValueIndex(0);
1233 mShowNonRectClip.setSummary(mShowNonRectClip.getEntries()[0]);
1236 private void writeShowNonRectClipOptions(Object newValue) {
1237 SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY,
1238 newValue == null ? "" : newValue.toString());
1239 pokeSystemProperties();
1240 updateShowNonRectClipOptions();
1243 private void updateShowHwScreenUpdatesOptions() {
1244 updateSwitchPreference(mShowHwScreenUpdates,
1245 SystemProperties.getBoolean(ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false));
1248 private void writeShowHwScreenUpdatesOptions() {
1249 SystemProperties.set(ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY,
1250 mShowHwScreenUpdates.isChecked() ? "true" : null);
1251 pokeSystemProperties();
1254 private void updateShowHwLayersUpdatesOptions() {
1255 updateSwitchPreference(mShowHwLayersUpdates, SystemProperties.getBoolean(
1256 ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, false));
1259 private void writeShowHwLayersUpdatesOptions() {
1260 SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY,
1261 mShowHwLayersUpdates.isChecked() ? "true" : null);
1262 pokeSystemProperties();
1265 private void updateDebugHwOverdrawOptions() {
1266 String value = SystemProperties.get(ThreadedRenderer.DEBUG_OVERDRAW_PROPERTY);
1267 if (value == null) {
1271 CharSequence[] values = mDebugHwOverdraw.getEntryValues();
1272 for (int i = 0; i < values.length; i++) {
1273 if (value.contentEquals(values[i])) {
1274 mDebugHwOverdraw.setValueIndex(i);
1275 mDebugHwOverdraw.setSummary(mDebugHwOverdraw.getEntries()[i]);
1279 mDebugHwOverdraw.setValueIndex(0);
1280 mDebugHwOverdraw.setSummary(mDebugHwOverdraw.getEntries()[0]);
1283 private void writeDebugHwOverdrawOptions(Object newValue) {
1284 SystemProperties.set(ThreadedRenderer.DEBUG_OVERDRAW_PROPERTY,
1285 newValue == null ? "" : newValue.toString());
1286 pokeSystemProperties();
1287 updateDebugHwOverdrawOptions();
1290 private void updateDebugLayoutOptions() {
1291 updateSwitchPreference(mDebugLayout,
1292 SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false));
1295 private void writeDebugLayoutOptions() {
1296 SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
1297 mDebugLayout.isChecked() ? "true" : "false");
1298 pokeSystemProperties();
1301 private void updateSimulateColorSpace() {
1302 final ContentResolver cr = getContentResolver();
1303 final boolean enabled = Settings.Secure.getInt(
1304 cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0) != 0;
1306 final String mode = Integer.toString(Settings.Secure.getInt(
1307 cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
1308 AccessibilityManager.DALTONIZER_DISABLED));
1309 mSimulateColorSpace.setValue(mode);
1310 final int index = mSimulateColorSpace.findIndexOfValue(mode);
1312 // We're using a mode controlled by accessibility preferences.
1313 mSimulateColorSpace.setSummary(getString(R.string.daltonizer_type_overridden,
1314 getString(R.string.accessibility_display_daltonizer_preference_title)));
1316 mSimulateColorSpace.setSummary("%s");
1319 mSimulateColorSpace.setValue(
1320 Integer.toString(AccessibilityManager.DALTONIZER_DISABLED));
1325 * @return <code>true</code> if the color space preference is currently
1326 * controlled by development settings
1328 private boolean usingDevelopmentColorSpace() {
1329 final ContentResolver cr = getContentResolver();
1330 final boolean enabled = Settings.Secure.getInt(
1331 cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0) != 0;
1333 final String mode = Integer.toString(Settings.Secure.getInt(
1334 cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
1335 AccessibilityManager.DALTONIZER_DISABLED));
1336 final int index = mSimulateColorSpace.findIndexOfValue(mode);
1338 // We're using a mode controlled by developer preferences.
1345 private void writeSimulateColorSpace(Object value) {
1346 final ContentResolver cr = getContentResolver();
1347 final int newMode = Integer.parseInt(value.toString());
1349 Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
1351 Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 1);
1352 Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, newMode);
1356 private void updateColorTemperature() {
1357 updateSwitchPreference(mColorTemperaturePreference,
1358 SystemProperties.getBoolean(COLOR_TEMPERATURE_PROPERTY, false));
1361 private void writeColorTemperature() {
1362 SystemProperties.set(COLOR_TEMPERATURE_PROPERTY,
1363 mColorTemperaturePreference.isChecked() ? "1" : "0");
1364 pokeSystemProperties();
1365 Toast.makeText(getActivity(), R.string.color_temperature_toast, Toast.LENGTH_LONG).show();
1368 private void updateUSBAudioOptions() {
1369 updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
1370 Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
1373 private void writeUSBAudioOptions() {
1374 Settings.Secure.putInt(getContentResolver(),
1375 Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED,
1376 mUSBAudio.isChecked() ? 1 : 0);
1379 private void updateForceResizableOptions() {
1380 updateSwitchPreference(mForceResizable, Settings.Global.getInt(getContentResolver(),
1381 Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, 0) != 0);
1384 private void writeForceResizableOptions() {
1385 Settings.Global.putInt(getContentResolver(),
1386 Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES,
1387 mForceResizable.isChecked() ? 1 : 0);
1390 private void updateForceRtlOptions() {
1391 updateSwitchPreference(mForceRtlLayout,
1392 Settings.Global.getInt(getActivity().getContentResolver(),
1393 Settings.Global.DEVELOPMENT_FORCE_RTL, 0) != 0);
1396 private void writeForceRtlOptions() {
1397 boolean value = mForceRtlLayout.isChecked();
1398 Settings.Global.putInt(getActivity().getContentResolver(),
1399 Settings.Global.DEVELOPMENT_FORCE_RTL, value ? 1 : 0);
1400 SystemProperties.set(Settings.Global.DEVELOPMENT_FORCE_RTL, value ? "1" : "0");
1401 LocalePicker.updateLocale(getActivity().getResources().getConfiguration().locale);
1404 private void updateWifiDisplayCertificationOptions() {
1405 updateSwitchPreference(mWifiDisplayCertification, Settings.Global.getInt(
1406 getActivity().getContentResolver(),
1407 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, 0) != 0);
1410 private void writeWifiDisplayCertificationOptions() {
1411 Settings.Global.putInt(getActivity().getContentResolver(),
1412 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON,
1413 mWifiDisplayCertification.isChecked() ? 1 : 0);
1416 private void updateWifiVerboseLoggingOptions() {
1417 boolean enabled = mWifiManager.getVerboseLoggingLevel() > 0;
1418 updateSwitchPreference(mWifiVerboseLogging, enabled);
1421 private void writeWifiVerboseLoggingOptions() {
1422 mWifiManager.enableVerboseLogging(mWifiVerboseLogging.isChecked() ? 1 : 0);
1425 private void updateWifiAggressiveHandoverOptions() {
1426 boolean enabled = mWifiManager.getAggressiveHandover() > 0;
1427 updateSwitchPreference(mWifiAggressiveHandover, enabled);
1430 private void writeWifiAggressiveHandoverOptions() {
1431 mWifiManager.enableAggressiveHandover(mWifiAggressiveHandover.isChecked() ? 1 : 0);
1434 private void updateWifiAllowScansWithTrafficOptions() {
1435 boolean enabled = mWifiManager.getAllowScansWithTraffic() > 0;
1436 updateSwitchPreference(mWifiAllowScansWithTraffic, enabled);
1439 private void writeWifiAllowScansWithTrafficOptions() {
1440 mWifiManager.setAllowScansWithTraffic(mWifiAllowScansWithTraffic.isChecked() ? 1 : 0);
1443 private void updateBluetoothDisableAbsVolumeOptions() {
1444 updateSwitchPreference(mBluetoothDisableAbsVolume,
1445 SystemProperties.getBoolean(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, false));
1448 private void writeBluetoothDisableAbsVolumeOptions() {
1449 SystemProperties.set(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY,
1450 mBluetoothDisableAbsVolume.isChecked() ? "true" : "false");
1453 private void updateMobileDataAlwaysOnOptions() {
1454 updateSwitchPreference(mMobileDataAlwaysOn, Settings.Global.getInt(
1455 getActivity().getContentResolver(),
1456 Settings.Global.MOBILE_DATA_ALWAYS_ON, 0) != 0);
1459 private void writeMobileDataAlwaysOnOptions() {
1460 Settings.Global.putInt(getActivity().getContentResolver(),
1461 Settings.Global.MOBILE_DATA_ALWAYS_ON,
1462 mMobileDataAlwaysOn.isChecked() ? 1 : 0);
1465 private String defaultLogdSizeValue() {
1466 String defaultValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY);
1467 if ((defaultValue == null) || (defaultValue.length() == 0)) {
1468 if (SystemProperties.get("ro.config.low_ram").equals("true")) {
1469 defaultValue = SELECT_LOGD_SVELTE_DEFAULT_SIZE_VALUE;
1471 defaultValue = SELECT_LOGD_DEFAULT_SIZE_VALUE;
1474 return defaultValue;
1477 private void updateLogdSizeValues() {
1478 if (mLogdSize != null) {
1479 String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
1480 String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
1481 if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {
1482 currentValue = SELECT_LOGD_OFF_SIZE_MARKER_VALUE;
1484 if (mLogpersist != null) {
1485 String currentLogpersistEnable
1486 = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_ENABLE);
1487 if ((currentLogpersistEnable == null)
1488 || !currentLogpersistEnable.equals("true")
1489 || currentValue.equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE)) {
1490 writeLogpersistOption(null, true);
1491 mLogpersist.setEnabled(false);
1492 } else if (mLastEnabledState) {
1493 mLogpersist.setEnabled(true);
1496 if ((currentValue == null) || (currentValue.length() == 0)) {
1497 currentValue = defaultLogdSizeValue();
1499 String[] values = getResources().getStringArray(R.array.select_logd_size_values);
1500 String[] titles = getResources().getStringArray(R.array.select_logd_size_titles);
1501 int index = 2; // punt to second entry if not found
1502 if (SystemProperties.get("ro.config.low_ram").equals("true")) {
1503 mLogdSize.setEntries(R.array.select_logd_size_lowram_titles);
1504 titles = getResources().getStringArray(R.array.select_logd_size_lowram_titles);
1507 String[] summaries = getResources().getStringArray(R.array.select_logd_size_summaries);
1508 for (int i = 0; i < titles.length; i++) {
1509 if (currentValue.equals(values[i])
1510 || currentValue.equals(titles[i])) {
1515 mLogdSize.setValue(values[index]);
1516 mLogdSize.setSummary(summaries[index]);
1517 mLogdSize.setOnPreferenceChangeListener(this);
1521 private void writeLogdSizeOption(Object newValue) {
1522 boolean disable = (newValue != null) &&
1523 (newValue.toString().equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE));
1524 String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
1525 if (currentTag == null) {
1528 // filter clean and unstack all references to our setting
1529 String newTag = currentTag.replaceAll(
1530 ",+" + SELECT_LOGD_TAG_SILENCE, "").replaceFirst(
1531 "^" + SELECT_LOGD_TAG_SILENCE + ",*", "").replaceAll(
1532 ",+", ",").replaceFirst(
1535 newValue = SELECT_LOGD_MINIMUM_SIZE_VALUE;
1536 // Make sure snet_event_log get through first, but do not override
1537 String snetValue = SystemProperties.get(SELECT_LOGD_SNET_TAG_PROPERTY);
1538 if ((snetValue == null) || (snetValue.length() == 0)) {
1539 snetValue = SystemProperties.get(SELECT_LOGD_RUNTIME_SNET_TAG_PROPERTY);
1540 if ((snetValue == null) || (snetValue.length() == 0)) {
1541 SystemProperties.set(SELECT_LOGD_SNET_TAG_PROPERTY, "I");
1544 // Silence all log sources, security logs notwithstanding
1545 if (newTag.length() != 0) {
1546 newTag = "," + newTag;
1548 // Stack settings, stack to help preserve original value
1549 newTag = SELECT_LOGD_TAG_SILENCE + newTag;
1551 if (!newTag.equals(currentTag)) {
1552 SystemProperties.set(SELECT_LOGD_TAG_PROPERTY, newTag);
1554 String defaultValue = defaultLogdSizeValue();
1555 final String size = ((newValue != null) && (newValue.toString().length() != 0)) ?
1556 newValue.toString() : defaultValue;
1557 SystemProperties.set(SELECT_LOGD_SIZE_PROPERTY, defaultValue.equals(size) ? "" : size);
1558 SystemProperties.set("ctl.start", "logd-reinit");
1559 pokeSystemProperties();
1560 updateLogdSizeValues();
1563 private void updateLogpersistValues() {
1564 if (mLogpersist == null) {
1567 String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
1568 if (currentValue == null) {
1571 String currentBuffers = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_BUFFER);
1572 if ((currentBuffers == null) || (currentBuffers.length() == 0)) {
1573 currentBuffers = "all";
1576 if (currentValue.equals(SELECT_LOGPERSIST_PROPERTY_SERVICE)) {
1578 if (currentBuffers.equals("kernel")) {
1580 } else if (!currentBuffers.equals("all") &&
1581 !currentBuffers.contains("radio") &&
1582 currentBuffers.contains("security") &&
1583 currentBuffers.contains("kernel")) {
1585 if (!currentBuffers.contains("default")) {
1586 String[] contains = { "main", "events", "system", "crash" };
1587 for (int i = 0; i < contains.length; i++) {
1588 if (!currentBuffers.contains(contains[i])) {
1596 mLogpersist.setValue(getResources().getStringArray(R.array.select_logpersist_values)[index]);
1597 mLogpersist.setSummary(getResources().getStringArray(R.array.select_logpersist_summaries)[index]);
1598 mLogpersist.setOnPreferenceChangeListener(this);
1600 mLogpersistCleared = false;
1601 } else if (!mLogpersistCleared) {
1602 // would File.delete() directly but need to switch uid/gid to access
1603 SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY, SELECT_LOGPERSIST_PROPERTY_CLEAR);
1604 pokeSystemProperties();
1605 mLogpersistCleared = true;
1609 private void setLogpersistOff(boolean update) {
1610 SystemProperties.set(SELECT_LOGPERSIST_PROPERTY_BUFFER, "");
1611 // deal with trampoline of empty properties
1612 SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY_BUFFER, "");
1613 SystemProperties.set(SELECT_LOGPERSIST_PROPERTY, "");
1614 SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY,
1615 update ? "" : SELECT_LOGPERSIST_PROPERTY_STOP);
1616 pokeSystemProperties();
1618 updateLogpersistValues();
1620 for (int i = 0; i < 3; i++) {
1621 String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
1622 if ((currentValue == null) || currentValue.equals("")) {
1627 } catch (InterruptedException e) {
1633 private void writeLogpersistOption(Object newValue, boolean skipWarning) {
1634 if (mLogpersist == null) {
1637 String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
1638 if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {
1643 if ((newValue == null) || newValue.toString().equals("")) {
1645 mLogpersistCleared = false;
1646 } else if (!mLogpersistCleared) {
1647 // if transitioning from on to off, pop up an are you sure?
1648 String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
1649 if ((currentValue != null) &&
1650 currentValue.equals(SELECT_LOGPERSIST_PROPERTY_SERVICE)) {
1651 if (mLogpersistClearDialog != null) dismissDialogs();
1652 mLogpersistClearDialog = new AlertDialog.Builder(getActivity()).setMessage(
1653 getActivity().getResources().getString(
1654 R.string.dev_logpersist_clear_warning_message))
1655 .setTitle(R.string.dev_logpersist_clear_warning_title)
1656 .setPositiveButton(android.R.string.yes, this)
1657 .setNegativeButton(android.R.string.no, this)
1659 mLogpersistClearDialog.setOnDismissListener(this);
1663 setLogpersistOff(true);
1667 String currentBuffer = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_BUFFER);
1668 if ((currentBuffer != null) && !currentBuffer.equals(newValue.toString())) {
1669 setLogpersistOff(false);
1671 SystemProperties.set(SELECT_LOGPERSIST_PROPERTY_BUFFER, newValue.toString());
1672 SystemProperties.set(SELECT_LOGPERSIST_PROPERTY, SELECT_LOGPERSIST_PROPERTY_SERVICE);
1673 pokeSystemProperties();
1674 for (int i = 0; i < 3; i++) {
1675 String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
1676 if ((currentValue != null)
1677 && currentValue.equals(SELECT_LOGPERSIST_PROPERTY_SERVICE)) {
1682 } catch (InterruptedException e) {
1685 updateLogpersistValues();
1688 private void updateUsbConfigurationValues() {
1689 if (mUsbConfiguration != null) {
1690 UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
1692 String[] values = getResources().getStringArray(R.array.usb_configuration_values);
1693 String[] titles = getResources().getStringArray(R.array.usb_configuration_titles);
1695 for (int i = 0; i < titles.length; i++) {
1696 if (manager.isFunctionEnabled(values[i])) {
1701 mUsbConfiguration.setValue(values[index]);
1702 mUsbConfiguration.setSummary(titles[index]);
1703 mUsbConfiguration.setOnPreferenceChangeListener(this);
1707 private void writeUsbConfigurationOption(Object newValue) {
1708 UsbManager manager = (UsbManager)getActivity().getSystemService(Context.USB_SERVICE);
1709 String function = newValue.toString();
1710 if (function.equals("none")) {
1711 manager.setCurrentFunction(function, false);
1713 manager.setCurrentFunction(function, true);
1717 private void writeImmediatelyDestroyActivitiesOptions() {
1719 ActivityManagerNative.getDefault().setAlwaysFinish(
1720 mImmediatelyDestroyActivities.isChecked());
1721 } catch (RemoteException ex) {
1725 private void updateImmediatelyDestroyActivitiesOptions() {
1726 updateSwitchPreference(mImmediatelyDestroyActivities, Settings.Global.getInt(
1727 getActivity().getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0) != 0);
1730 private void updateAnimationScaleValue(int which, ListPreference pref) {
1732 float scale = mWindowManager.getAnimationScale(which);
1734 mHaveDebugSettings = true;
1736 CharSequence[] values = pref.getEntryValues();
1737 for (int i=0; i<values.length; i++) {
1738 float val = Float.parseFloat(values[i].toString());
1740 pref.setValueIndex(i);
1741 pref.setSummary(pref.getEntries()[i]);
1745 pref.setValueIndex(values.length-1);
1746 pref.setSummary(pref.getEntries()[0]);
1747 } catch (RemoteException e) {
1751 private void updateAnimationScaleOptions() {
1752 updateAnimationScaleValue(0, mWindowAnimationScale);
1753 updateAnimationScaleValue(1, mTransitionAnimationScale);
1754 updateAnimationScaleValue(2, mAnimatorDurationScale);
1757 private void writeAnimationScaleOption(int which, ListPreference pref, Object newValue) {
1759 float scale = newValue != null ? Float.parseFloat(newValue.toString()) : 1;
1760 mWindowManager.setAnimationScale(which, scale);
1761 updateAnimationScaleValue(which, pref);
1762 } catch (RemoteException e) {
1766 private void updateOverlayDisplayDevicesOptions() {
1767 String value = Settings.Global.getString(getActivity().getContentResolver(),
1768 Settings.Global.OVERLAY_DISPLAY_DEVICES);
1769 if (value == null) {
1773 CharSequence[] values = mOverlayDisplayDevices.getEntryValues();
1774 for (int i = 0; i < values.length; i++) {
1775 if (value.contentEquals(values[i])) {
1776 mOverlayDisplayDevices.setValueIndex(i);
1777 mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[i]);
1781 mOverlayDisplayDevices.setValueIndex(0);
1782 mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[0]);
1785 private void writeOverlayDisplayDevicesOptions(Object newValue) {
1786 Settings.Global.putString(getActivity().getContentResolver(),
1787 Settings.Global.OVERLAY_DISPLAY_DEVICES, (String) newValue);
1788 updateOverlayDisplayDevicesOptions();
1791 private void updateAppProcessLimitOptions() {
1793 int limit = ActivityManagerNative.getDefault().getProcessLimit();
1794 CharSequence[] values = mAppProcessLimit.getEntryValues();
1795 for (int i=0; i<values.length; i++) {
1796 int val = Integer.parseInt(values[i].toString());
1799 mHaveDebugSettings = true;
1801 mAppProcessLimit.setValueIndex(i);
1802 mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[i]);
1806 mAppProcessLimit.setValueIndex(0);
1807 mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[0]);
1808 } catch (RemoteException e) {
1812 private void writeAppProcessLimitOptions(Object newValue) {
1814 int limit = newValue != null ? Integer.parseInt(newValue.toString()) : -1;
1815 ActivityManagerNative.getDefault().setProcessLimit(limit);
1816 updateAppProcessLimitOptions();
1817 } catch (RemoteException e) {
1821 private void writeShowAllANRsOptions() {
1822 Settings.Secure.putInt(getActivity().getContentResolver(),
1823 Settings.Secure.ANR_SHOW_BACKGROUND,
1824 mShowAllANRs.isChecked() ? 1 : 0);
1827 private void updateShowAllANRsOptions() {
1828 updateSwitchPreference(mShowAllANRs, Settings.Secure.getInt(
1829 getActivity().getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0);
1832 private void confirmEnableOemUnlock() {
1833 DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
1835 public void onClick(DialogInterface dialog, int which) {
1836 if (which == DialogInterface.BUTTON_POSITIVE) {
1837 Utils.setOemUnlockEnabled(getActivity(), true);
1842 DialogInterface.OnDismissListener onDismissListener = new DialogInterface.OnDismissListener() {
1844 public void onDismiss(DialogInterface dialog) {
1845 if (getActivity() == null) {
1852 new AlertDialog.Builder(getActivity())
1853 .setTitle(R.string.confirm_enable_oem_unlock_title)
1854 .setMessage(R.string.confirm_enable_oem_unlock_text)
1855 .setPositiveButton(R.string.enable_text, onClickListener)
1856 .setNegativeButton(android.R.string.cancel, null)
1857 .setOnDismissListener(onDismissListener)
1863 public void onSwitchChanged(Switch switchView, boolean isChecked) {
1864 if (switchView != mSwitchBar.getSwitch()) {
1867 if (isChecked != mLastEnabledState) {
1869 mDialogClicked = false;
1870 if (mEnableDialog != null) dismissDialogs();
1871 mEnableDialog = new AlertDialog.Builder(getActivity()).setMessage(
1872 getActivity().getResources().getString(
1873 R.string.dev_settings_warning_message))
1874 .setTitle(R.string.dev_settings_warning_title)
1875 .setPositiveButton(android.R.string.yes, this)
1876 .setNegativeButton(android.R.string.no, this)
1878 mEnableDialog.setOnDismissListener(this);
1880 resetDangerousOptions();
1881 Settings.Global.putInt(getActivity().getContentResolver(),
1882 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
1883 mLastEnabledState = isChecked;
1884 setPrefsEnabledState(mLastEnabledState);
1890 public void onActivityResult(int requestCode, int resultCode, Intent data) {
1891 if (requestCode == RESULT_DEBUG_APP) {
1892 if (resultCode == Activity.RESULT_OK) {
1893 mDebugApp = data.getAction();
1894 writeDebuggerOptions();
1895 updateDebuggerOptions();
1897 } else if (requestCode == RESULT_MOCK_LOCATION_APP) {
1898 if (resultCode == Activity.RESULT_OK) {
1899 mMockLocationApp = data.getAction();
1900 writeMockLocation();
1901 updateMockLocation();
1903 } else if (requestCode == REQUEST_CODE_ENABLE_OEM_UNLOCK) {
1904 if (resultCode == Activity.RESULT_OK) {
1905 if (mEnableOemUnlock.isChecked()) {
1906 confirmEnableOemUnlock();
1908 Utils.setOemUnlockEnabled(getActivity(), false);
1912 super.onActivityResult(requestCode, resultCode, data);
1917 public boolean onPreferenceTreeClick(Preference preference) {
1918 if (Utils.isMonkeyRunning()) {
1922 if (preference == mEnableAdb) {
1923 if (mEnableAdb.isChecked()) {
1924 mDialogClicked = false;
1925 if (mAdbDialog != null) dismissDialogs();
1926 mAdbDialog = new AlertDialog.Builder(getActivity()).setMessage(
1927 getActivity().getResources().getString(R.string.adb_warning_message))
1928 .setTitle(R.string.adb_warning_title)
1929 .setPositiveButton(android.R.string.yes, this)
1930 .setNegativeButton(android.R.string.no, this)
1932 mAdbDialog.setOnDismissListener(this);
1934 Settings.Global.putInt(getActivity().getContentResolver(),
1935 Settings.Global.ADB_ENABLED, 0);
1936 mVerifyAppsOverUsb.setEnabled(false);
1937 mVerifyAppsOverUsb.setChecked(false);
1938 updateBugreportOptions();
1940 } else if (preference == mClearAdbKeys) {
1941 if (mAdbKeysDialog != null) dismissDialogs();
1942 mAdbKeysDialog = new AlertDialog.Builder(getActivity())
1943 .setMessage(R.string.adb_keys_warning_message)
1944 .setPositiveButton(android.R.string.ok, this)
1945 .setNegativeButton(android.R.string.cancel, null)
1947 } else if (preference == mEnableTerminal) {
1948 final PackageManager pm = getActivity().getPackageManager();
1949 pm.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE,
1950 mEnableTerminal.isChecked() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
1951 : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
1952 } else if (preference == mBugreportInPower) {
1953 Settings.Secure.putInt(getActivity().getContentResolver(),
1954 Settings.Global.BUGREPORT_IN_POWER_MENU,
1955 mBugreportInPower.isChecked() ? 1 : 0);
1956 setBugreportStorageProviderStatus();
1957 } else if (preference == mKeepScreenOn) {
1958 Settings.Global.putInt(getActivity().getContentResolver(),
1959 Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
1960 mKeepScreenOn.isChecked() ?
1961 (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
1962 } else if (preference == mBtHciSnoopLog) {
1963 writeBtHciSnoopLogOptions();
1964 } else if (preference == mEnableOemUnlock && mEnableOemUnlock.isEnabled()) {
1965 if (mEnableOemUnlock.isChecked()) {
1966 if (!showKeyguardConfirmation(getResources(), REQUEST_CODE_ENABLE_OEM_UNLOCK)) {
1967 confirmEnableOemUnlock();
1970 Utils.setOemUnlockEnabled(getActivity(), false);
1972 } else if (preference == mMockLocationAppPref) {
1973 Intent intent = new Intent(getActivity(), AppPicker.class);
1974 intent.putExtra(AppPicker.EXTRA_REQUESTIING_PERMISSION,
1975 Manifest.permission.ACCESS_MOCK_LOCATION);
1976 startActivityForResult(intent, RESULT_MOCK_LOCATION_APP);
1977 } else if (preference == mDebugViewAttributes) {
1978 Settings.Global.putInt(getActivity().getContentResolver(),
1979 Settings.Global.DEBUG_VIEW_ATTRIBUTES,
1980 mDebugViewAttributes.isChecked() ? 1 : 0);
1981 } else if (preference == mForceAllowOnExternal) {
1982 Settings.Global.putInt(getActivity().getContentResolver(),
1983 Settings.Global.FORCE_ALLOW_ON_EXTERNAL,
1984 mForceAllowOnExternal.isChecked() ? 1 : 0);
1985 } else if (preference == mDebugAppPref) {
1986 Intent intent = new Intent(getActivity(), AppPicker.class);
1987 intent.putExtra(AppPicker.EXTRA_DEBUGGABLE, true);
1988 startActivityForResult(intent, RESULT_DEBUG_APP);
1989 } else if (preference == mWaitForDebugger) {
1990 writeDebuggerOptions();
1991 } else if (preference == mVerifyAppsOverUsb) {
1992 writeVerifyAppsOverUsbOptions();
1993 } else if (preference == mOtaDisableAutomaticUpdate) {
1994 writeOtaDisableAutomaticUpdateOptions();
1995 } else if (preference == mStrictMode) {
1996 writeStrictModeVisualOptions();
1997 } else if (preference == mPointerLocation) {
1998 writePointerLocationOptions();
1999 } else if (preference == mShowTouches) {
2000 writeShowTouchesOptions();
2001 } else if (preference == mShowScreenUpdates) {
2002 writeShowUpdatesOption();
2003 } else if (preference == mDisableOverlays) {
2004 writeDisableOverlaysOption();
2005 } else if (preference == mImmediatelyDestroyActivities) {
2006 writeImmediatelyDestroyActivitiesOptions();
2007 } else if (preference == mShowAllANRs) {
2008 writeShowAllANRsOptions();
2009 } else if (preference == mForceHardwareUi) {
2010 writeHardwareUiOptions();
2011 } else if (preference == mForceMsaa) {
2013 } else if (preference == mShowHwScreenUpdates) {
2014 writeShowHwScreenUpdatesOptions();
2015 } else if (preference == mShowHwLayersUpdates) {
2016 writeShowHwLayersUpdatesOptions();
2017 } else if (preference == mDebugLayout) {
2018 writeDebugLayoutOptions();
2019 } else if (preference == mForceRtlLayout) {
2020 writeForceRtlOptions();
2021 } else if (preference == mWifiDisplayCertification) {
2022 writeWifiDisplayCertificationOptions();
2023 } else if (preference == mWifiVerboseLogging) {
2024 writeWifiVerboseLoggingOptions();
2025 } else if (preference == mWifiAggressiveHandover) {
2026 writeWifiAggressiveHandoverOptions();
2027 } else if (preference == mWifiAllowScansWithTraffic) {
2028 writeWifiAllowScansWithTrafficOptions();
2029 } else if (preference == mMobileDataAlwaysOn) {
2030 writeMobileDataAlwaysOnOptions();
2031 } else if (preference == mColorTemperaturePreference) {
2032 writeColorTemperature();
2033 } else if (preference == mUSBAudio) {
2034 writeUSBAudioOptions();
2035 } else if (preference == mForceResizable) {
2036 writeForceResizableOptions();
2037 } else if (INACTIVE_APPS_KEY.equals(preference.getKey())) {
2038 startInactiveAppsFragment();
2039 } else if (BACKGROUND_CHECK_KEY.equals(preference.getKey())) {
2040 startBackgroundCheckFragment();
2041 } else if (preference == mBluetoothDisableAbsVolume) {
2042 writeBluetoothDisableAbsVolumeOptions();
2043 } else if (preference == mWebViewMultiprocess) {
2044 writeWebViewMultiprocessOptions();
2045 } else if (SHORTCUT_MANAGER_RESET_KEY.equals(preference.getKey())) {
2046 resetShortcutManagerThrottling();
2048 return super.onPreferenceTreeClick(preference);
2054 private void startInactiveAppsFragment() {
2055 ((SettingsActivity) getActivity()).startPreferencePanel(
2056 InactiveApps.class.getName(),
2057 null, R.string.inactive_apps_title, null, null, 0);
2060 private void startBackgroundCheckFragment() {
2061 ((SettingsActivity) getActivity()).startPreferencePanel(
2062 BackgroundCheckSummary.class.getName(),
2063 null, R.string.background_check_title, null, null, 0);
2066 private boolean showKeyguardConfirmation(Resources resources, int requestCode) {
2067 return new ChooseLockSettingsHelper(getActivity(), this).launchConfirmationActivity(
2068 requestCode, resources.getString(R.string.oem_unlock_enable));
2072 public boolean onPreferenceChange(Preference preference, Object newValue) {
2073 if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
2074 SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
2076 pokeSystemProperties();
2078 } else if (preference == mWebViewProvider) {
2079 if (newValue == null) {
2080 Log.e(TAG, "Tried to set a null WebView provider");
2083 if (writeWebViewProviderOptions(newValue)) {
2086 // The user chose a package that became invalid since the list was last updated,
2087 // show a Toast to explain the situation.
2088 Toast toast = Toast.makeText(getActivity(),
2089 R.string.select_webview_provider_toast_text, Toast.LENGTH_SHORT);
2093 } else if (preference == mLogdSize) {
2094 writeLogdSizeOption(newValue);
2096 } else if (preference == mLogpersist) {
2097 writeLogpersistOption(newValue, false);
2099 } else if (preference == mUsbConfiguration) {
2100 writeUsbConfigurationOption(newValue);
2102 } else if (preference == mWindowAnimationScale) {
2103 writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
2105 } else if (preference == mTransitionAnimationScale) {
2106 writeAnimationScaleOption(1, mTransitionAnimationScale, newValue);
2108 } else if (preference == mAnimatorDurationScale) {
2109 writeAnimationScaleOption(2, mAnimatorDurationScale, newValue);
2111 } else if (preference == mOverlayDisplayDevices) {
2112 writeOverlayDisplayDevicesOptions(newValue);
2114 } else if (preference == mTrackFrameTime) {
2115 writeTrackFrameTimeOptions(newValue);
2117 } else if (preference == mDebugHwOverdraw) {
2118 writeDebugHwOverdrawOptions(newValue);
2120 } else if (preference == mShowNonRectClip) {
2121 writeShowNonRectClipOptions(newValue);
2123 } else if (preference == mAppProcessLimit) {
2124 writeAppProcessLimitOptions(newValue);
2126 } else if (preference == mSimulateColorSpace) {
2127 writeSimulateColorSpace(newValue);
2133 private void dismissDialogs() {
2134 if (mAdbDialog != null) {
2135 mAdbDialog.dismiss();
2138 if (mAdbKeysDialog != null) {
2139 mAdbKeysDialog.dismiss();
2140 mAdbKeysDialog = null;
2142 if (mEnableDialog != null) {
2143 mEnableDialog.dismiss();
2144 mEnableDialog = null;
2146 if (mLogpersistClearDialog != null) {
2147 mLogpersistClearDialog.dismiss();
2148 mLogpersistClearDialog = null;
2152 public void onClick(DialogInterface dialog, int which) {
2153 if (dialog == mAdbDialog) {
2154 if (which == DialogInterface.BUTTON_POSITIVE) {
2155 mDialogClicked = true;
2156 Settings.Global.putInt(getActivity().getContentResolver(),
2157 Settings.Global.ADB_ENABLED, 1);
2158 mVerifyAppsOverUsb.setEnabled(true);
2159 updateVerifyAppsOverUsbOptions();
2160 updateBugreportOptions();
2163 mEnableAdb.setChecked(false);
2165 } else if (dialog == mAdbKeysDialog) {
2166 if (which == DialogInterface.BUTTON_POSITIVE) {
2168 IBinder b = ServiceManager.getService(Context.USB_SERVICE);
2169 IUsbManager service = IUsbManager.Stub.asInterface(b);
2170 service.clearUsbDebuggingKeys();
2171 } catch (RemoteException e) {
2172 Log.e(TAG, "Unable to clear adb keys", e);
2175 } else if (dialog == mEnableDialog) {
2176 if (which == DialogInterface.BUTTON_POSITIVE) {
2177 mDialogClicked = true;
2178 Settings.Global.putInt(getActivity().getContentResolver(),
2179 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
2180 mLastEnabledState = true;
2181 setPrefsEnabledState(mLastEnabledState);
2184 mSwitchBar.setChecked(false);
2186 } else if (dialog == mLogpersistClearDialog) {
2187 if (which == DialogInterface.BUTTON_POSITIVE) {
2188 setLogpersistOff(true);
2190 updateLogpersistValues();
2195 public void onDismiss(DialogInterface dialog) {
2196 // Assuming that onClick gets called first
2197 if (dialog == mAdbDialog) {
2198 if (!mDialogClicked) {
2199 mEnableAdb.setChecked(false);
2202 } else if (dialog == mEnableDialog) {
2203 if (!mDialogClicked) {
2204 mSwitchBar.setChecked(false);
2206 mEnableDialog = null;
2207 } else if (dialog == mLogpersistClearDialog) {
2208 mLogpersistClearDialog = null;
2213 public void onDestroy() {
2218 void pokeSystemProperties() {
2219 if (!mDontPokeProperties) {
2220 //noinspection unchecked
2221 (new SystemPropPoker()).execute();
2225 private BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
2227 public void onReceive(Context context, Intent intent) {
2228 updateUsbConfigurationValues();
2232 public static class SystemPropPoker extends AsyncTask<Void, Void, Void> {
2234 protected Void doInBackground(Void... params) {
2235 String[] services = ServiceManager.listServices();
2236 for (String service : services) {
2237 IBinder obj = ServiceManager.checkService(service);
2239 Parcel data = Parcel.obtain();
2241 obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
2242 } catch (RemoteException e) {
2243 } catch (Exception e) {
2244 Log.i(TAG, "Someone wrote a bad service '" + service
2245 + "' that doesn't like to be poked: " + e);
2254 private static boolean isPackageInstalled(Context context, String packageName) {
2256 return context.getPackageManager().getPackageInfo(packageName, 0) != null;
2257 } catch (NameNotFoundException e) {
2266 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
2267 new BaseSearchIndexProvider() {
2269 private boolean isShowingDeveloperOptions(Context context) {
2270 return context.getSharedPreferences(DevelopmentSettings.PREF_FILE,
2271 Context.MODE_PRIVATE).getBoolean(
2272 DevelopmentSettings.PREF_SHOW,
2273 android.os.Build.TYPE.equals("eng"));
2277 public List<SearchIndexableResource> getXmlResourcesToIndex(
2278 Context context, boolean enabled) {
2280 if (!isShowingDeveloperOptions(context)) {
2284 final SearchIndexableResource sir = new SearchIndexableResource(context);
2285 sir.xmlResId = R.xml.development_prefs;
2286 return Arrays.asList(sir);
2290 public List<String> getNonIndexableKeys(Context context) {
2291 if (!isShowingDeveloperOptions(context)) {
2295 final List<String> keys = new ArrayList<String>();
2296 if (!showEnableOemUnlockPreference()) {
2297 keys.add(ENABLE_OEM_UNLOCK);
2303 private void resetShortcutManagerThrottling() {
2304 final IShortcutService service = IShortcutService.Stub.asInterface(
2305 ServiceManager.getService(Context.SHORTCUT_SERVICE));
2306 if (service != null) {
2308 service.resetThrottling();
2309 Toast.makeText(getActivity(), R.string.reset_shortcut_manager_throttling_complete,
2310 Toast.LENGTH_SHORT).show();
2311 } catch (RemoteException e) {
2312 Log.e(TAG, "Failed to reset rate limiting", e);
2317 private void updateOemUnlockSettingDescription() {
2318 if (mEnableOemUnlock != null) {
2319 int oemUnlockSummary = R.string.oem_unlock_enable_summary;
2320 if (isBootloaderUnlocked()) {
2321 oemUnlockSummary = R.string.oem_unlock_enable_disabled_summary_bootloader_unlocked;
2322 } else if (isSimLockedDevice()) {
2323 oemUnlockSummary = R.string.oem_unlock_enable_disabled_summary_sim_locked_device;
2324 } else if (!isOemUnlockAllowed()) {
2325 // If the device isn't SIM-locked but OEM unlock is disabled by the system via the
2326 // user restriction, this means either some other carrier restriction is in place or
2327 // the device hasn't been able to confirm which restrictions (SIM-lock or otherwise)
2330 R.string.oem_unlock_enable_disabled_summary_connectivity_or_locked;
2332 mEnableOemUnlock.setSummary(getString(oemUnlockSummary));
2336 /** Returns {@code true} if the device is SIM-locked. Otherwise, returns {@code false}. */
2337 private boolean isSimLockedDevice() {
2338 int phoneCount = mTelephonyManager.getPhoneCount();
2339 for (int i = 0; i < phoneCount; i++) {
2340 if (mTelephonyManager.getAllowedCarriers(i).size() > 0) {
2348 * Returns {@code true} if the bootloader has been unlocked. Otherwise, returns {code false}.
2350 private boolean isBootloaderUnlocked() {
2351 int flashLockState = PersistentDataBlockManager.FLASH_LOCK_UNKNOWN;
2352 if (mOemUnlockManager != null) {
2353 flashLockState = mOemUnlockManager.getFlashLockState();
2356 return flashLockState == PersistentDataBlockManager.FLASH_LOCK_UNLOCKED;
2360 * Returns {@code true} if OEM unlock is disallowed by user restriction
2361 * {@link UserManager#DISALLOW_FACTORY_RESET} or {@link UserManager#DISALLOW_OEM_UNLOCK}.
2362 * Otherwise, returns {@code false}.
2364 private boolean isOemUnlockAllowed() {
2365 UserHandle userHandle = UserHandle.of(UserHandle.myUserId());
2366 return !(mUm.hasBaseUserRestriction(UserManager.DISALLOW_OEM_UNLOCK, userHandle)
2367 || mUm.hasBaseUserRestriction(UserManager.DISALLOW_FACTORY_RESET, userHandle));