summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DevelopmentSettings.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/DevelopmentSettings.java')
-rw-r--r--src/com/android/settings/DevelopmentSettings.java508
1 files changed, 352 insertions, 156 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index f3a22ca..f5704c1 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -16,7 +16,6 @@
package com.android.settings;
-import android.app.ActionBar;
import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.AlertDialog;
@@ -27,55 +26,58 @@ import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.hardware.usb.IUsbManager;
+import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
-import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemProperties;
import android.os.UserHandle;
+import android.os.UserManager;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
+import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
-import android.view.Gravity;
import android.view.HardwareRenderer;
import android.view.IWindowManager;
import android.view.View;
-import android.widget.CompoundButton;
+import android.view.accessibility.AccessibilityManager;
import android.widget.Switch;
import android.widget.TextView;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.widget.SwitchBar;
import dalvik.system.VMRuntime;
-import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
/*
* Displays preferences for application developers.
*/
-public class DevelopmentSettings extends RestrictedSettingsFragment
+public class DevelopmentSettings extends SettingsPreferenceFragment
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
- OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener {
+ OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable {
private static final String TAG = "DevelopmentSettings";
/**
@@ -93,8 +95,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String ENABLE_TERMINAL = "enable_terminal";
private static final String KEEP_SCREEN_ON = "keep_screen_on";
private static final String BT_HCI_SNOOP_LOG = "bt_hci_snoop_log";
- private static final String SELECT_RUNTIME_KEY = "select_runtime";
- private static final String SELECT_RUNTIME_PROPERTY = "persist.sys.dalvik.vm.lib";
+ private static final String ENABLE_OEM_UNLOCK = "oem_unlock_enable";
private static final String ALLOW_MOCK_LOCATION = "allow_mock_location";
private static final String HDCP_CHECKING_KEY = "hdcp_checking";
private static final String HDCP_CHECKING_PROPERTY = "persist.sys.hdcp_checking";
@@ -108,11 +109,16 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String DEBUG_APP_KEY = "debug_app";
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
private static final String VERIFY_APPS_OVER_USB_KEY = "verify_apps_over_usb";
+ private static final String DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
private static final String STRICT_MODE_KEY = "strict_mode";
private static final String POINTER_LOCATION_KEY = "pointer_location";
private static final String SHOW_TOUCHES_KEY = "show_touches";
private static final String SHOW_SCREEN_UPDATES_KEY = "show_screen_updates";
private static final String DISABLE_OVERLAYS_KEY = "disable_overlays";
+ private static final String SIMULATE_COLOR_SPACE = "simulate_color_space";
+ private static final String USE_NUPLAYER_KEY = "use_nuplayer";
+ private static final String USB_AUDIO_KEY = "usb_audio";
+ private static final String USE_AWESOMEPLAYER_PROPERTY = "persist.sys.media.use-awesome";
private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
private static final String FORCE_MSAA_KEY = "force_msaa";
@@ -130,6 +136,12 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
private static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_category";
private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification";
+ private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
+ private static final String WIFI_AGGRESSIVE_HANDOVER_KEY = "wifi_aggressive_handover";
+ private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic";
+ private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
+ private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
+ private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
@@ -139,6 +151,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String SHOW_ALL_ANRS_KEY = "show_all_anrs";
+ private static final String PROCESS_STATS = "proc_stats";
+
private static final String TAG_CONFIRM_ENFORCE = "confirm_enforce";
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
@@ -147,11 +161,17 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final int RESULT_DEBUG_APP = 1000;
+ private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
+
+ private static String DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES = "262144"; // 256K
+
private IWindowManager mWindowManager;
private IBackupManager mBackupManager;
private DevicePolicyManager mDpm;
+ private UserManager mUm;
+ private WifiManager mWifiManager;
- private Switch mEnabledSwitch;
+ private SwitchBar mSwitchBar;
private boolean mLastEnabledState;
private boolean mHaveDebugSettings;
private boolean mDontPokeProperties;
@@ -163,15 +183,20 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private CheckBoxPreference mBugreportInPower;
private CheckBoxPreference mKeepScreenOn;
private CheckBoxPreference mBtHciSnoopLog;
+ private CheckBoxPreference mEnableOemUnlock;
private CheckBoxPreference mAllowMockLocation;
- private PreferenceScreen mPassword;
+ private CheckBoxPreference mDebugViewAttributes;
+ private PreferenceScreen mPassword;
private String mDebugApp;
private Preference mDebugAppPref;
private CheckBoxPreference mWaitForDebugger;
private CheckBoxPreference mVerifyAppsOverUsb;
private CheckBoxPreference mWifiDisplayCertification;
+ private CheckBoxPreference mWifiVerboseLogging;
+ private CheckBoxPreference mWifiAggressiveHandover;
+ private CheckBoxPreference mWifiAllowScansWithTraffic;
private CheckBoxPreference mStrictMode;
private CheckBoxPreference mPointerLocation;
private CheckBoxPreference mShowTouches;
@@ -185,6 +210,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private CheckBoxPreference mDebugLayout;
private CheckBoxPreference mForceRtlLayout;
private ListPreference mDebugHwOverdraw;
+ private ListPreference mLogdSize;
private ListPreference mTrackFrameTime;
private ListPreference mShowNonRectClip;
private ListPreference mWindowAnimationScale;
@@ -193,29 +219,31 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private ListPreference mOverlayDisplayDevices;
private ListPreference mOpenGLTraces;
+ private ListPreference mSimulateColorSpace;
+
+ private CheckBoxPreference mUseNuplayer;
+ private CheckBoxPreference mUSBAudio;
private CheckBoxPreference mImmediatelyDestroyActivities;
+
private ListPreference mAppProcessLimit;
private CheckBoxPreference mShowAllANRs;
+ private PreferenceScreen mProcessStats;
private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
+
private final ArrayList<CheckBoxPreference> mResetCbPrefs
= new ArrayList<CheckBoxPreference>();
private final HashSet<Preference> mDisabledPrefs = new HashSet<Preference>();
-
// To track whether a confirmation dialog was clicked.
private boolean mDialogClicked;
private Dialog mEnableDialog;
private Dialog mAdbDialog;
- private Dialog mAdbKeysDialog;
+ private Dialog mAdbKeysDialog;
private boolean mUnavailable;
- public DevelopmentSettings() {
- super(RESTRICTIONS_PIN_SET);
- }
-
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -224,8 +252,12 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
+ mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
+ mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER) {
+ if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER
+ || mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
return;
@@ -243,6 +275,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
debugDebuggingCategory.removePreference(mClearAdbKeys);
}
}
+ mAllPrefs.add(mClearAdbKeys);
mEnableTerminal = findAndInitCheckboxPref(ENABLE_TERMINAL);
if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
debugDebuggingCategory.removePreference(mEnableTerminal);
@@ -253,10 +286,17 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBugreportInPower = findAndInitCheckboxPref(BUGREPORT_IN_POWER_KEY);
mKeepScreenOn = findAndInitCheckboxPref(KEEP_SCREEN_ON);
mBtHciSnoopLog = findAndInitCheckboxPref(BT_HCI_SNOOP_LOG);
+ mEnableOemUnlock = findAndInitCheckboxPref(ENABLE_OEM_UNLOCK);
+ if (!showEnableOemUnlockPreference()) {
+ removePreference(mEnableOemUnlock);
+ mEnableOemUnlock = null;
+ }
mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
+ mDebugViewAttributes = findAndInitCheckboxPref(DEBUG_VIEW_ATTRIBUTES);
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
mAllPrefs.add(mPassword);
+
if (!android.os.Process.myUserHandle().equals(UserHandle.OWNER)) {
disableForUser(mEnableAdb);
disableForUser(mClearAdbKeys);
@@ -291,16 +331,25 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mForceRtlLayout = findAndInitCheckboxPref(FORCE_RTL_LAYOUT_KEY);
mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
mWifiDisplayCertification = findAndInitCheckboxPref(WIFI_DISPLAY_CERTIFICATION_KEY);
+ mWifiVerboseLogging = findAndInitCheckboxPref(WIFI_VERBOSE_LOGGING_KEY);
+ mWifiAggressiveHandover = findAndInitCheckboxPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
+ mWifiAllowScansWithTraffic = findAndInitCheckboxPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
+ mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
+
mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
mOpenGLTraces = addListPreference(OPENGL_TRACES_KEY);
+ mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
+ mUseNuplayer = findAndInitCheckboxPref(USE_NUPLAYER_KEY);
+ mUSBAudio = findAndInitCheckboxPref(USB_AUDIO_KEY);
mImmediatelyDestroyActivities = (CheckBoxPreference) findPreference(
IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
mAllPrefs.add(mImmediatelyDestroyActivities);
mResetCbPrefs.add(mImmediatelyDestroyActivities);
+
mAppProcessLimit = addListPreference(APP_PROCESS_LIMIT_KEY);
mShowAllANRs = (CheckBoxPreference) findPreference(
@@ -308,17 +357,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mAllPrefs.add(mShowAllANRs);
mResetCbPrefs.add(mShowAllANRs);
- Preference selectRuntime = findPreference(SELECT_RUNTIME_KEY);
- if (selectRuntime != null) {
- mAllPrefs.add(selectRuntime);
- filterRuntimeOptions(selectRuntime);
- }
-
Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
if (hdcpChecking != null) {
mAllPrefs.add(hdcpChecking);
removePreferenceForProduction(hdcpChecking);
}
+
+ mProcessStats = (PreferenceScreen) findPreference(PROCESS_STATS);
+ mAllPrefs.add(mProcessStats);
}
private ListPreference addListPreference(String prefKey) {
@@ -349,37 +395,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- final Activity activity = getActivity();
- mEnabledSwitch = new Switch(activity);
+ final SettingsActivity activity = (SettingsActivity) getActivity();
- final int padding = activity.getResources().getDimensionPixelSize(
- R.dimen.action_bar_switch_padding);
- mEnabledSwitch.setPaddingRelative(0, 0, padding, 0);
- if (mUnavailable) {
- mEnabledSwitch.setEnabled(false);
+ mSwitchBar = activity.getSwitchBar();
+ if (mUnavailable) {
+ mSwitchBar.setEnabled(false);
return;
}
- mEnabledSwitch.setOnCheckedChangeListener(this);
- }
- @Override
- public void onStart() {
- super.onStart();
- final Activity activity = getActivity();
- activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
- ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(mEnabledSwitch, new ActionBar.LayoutParams(
- ActionBar.LayoutParams.WRAP_CONTENT,
- ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.END));
- }
-
- @Override
- public void onStop() {
- super.onStop();
- final Activity activity = getActivity();
- activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(null);
+ mSwitchBar.addOnSwitchChangeListener(this);
}
private boolean removePreferenceForProduction(Preference preference) {
@@ -430,7 +454,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
final ContentResolver cr = getActivity().getContentResolver();
mLastEnabledState = Settings.Global.getInt(cr,
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
- mEnabledSwitch.setChecked(mLastEnabledState);
+ mSwitchBar.setChecked(mLastEnabledState);
setPrefsEnabledState(mLastEnabledState);
if (mHaveDebugSettings && !mLastEnabledState) {
@@ -441,9 +465,21 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.putInt(getActivity().getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mLastEnabledState = true;
- mEnabledSwitch.setChecked(mLastEnabledState);
+ mSwitchBar.setChecked(mLastEnabledState);
setPrefsEnabledState(mLastEnabledState);
}
+ mSwitchBar.show();
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ if (mUnavailable) {
+ return;
+ }
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
}
void updateCheckBox(CheckBoxPreference checkBox, boolean value) {
@@ -468,9 +504,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
updateCheckBox(mBtHciSnoopLog, Settings.Secure.getInt(cr,
Settings.Secure.BLUETOOTH_HCI_LOG, 0) != 0);
+ if (mEnableOemUnlock != null) {
+ updateCheckBox(mEnableOemUnlock, Utils.isOemUnlockEnabled(getActivity()));
+ }
updateCheckBox(mAllowMockLocation, Settings.Secure.getInt(cr,
Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
- updateRuntimeValue();
+ updateCheckBox(mDebugViewAttributes, Settings.Global.getInt(cr,
+ Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0) != 0);
updateHdcpValues();
updatePasswordSummary();
updateDebuggerOptions();
@@ -496,7 +536,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateVerifyAppsOverUsbOptions();
updateBugreportOptions();
updateForceRtlOptions();
+ updateLogdSizeValues();
updateWifiDisplayCertificationOptions();
+ updateWifiVerboseLoggingOptions();
+ updateWifiAggressiveHandoverOptions();
+ updateWifiAllowScansWithTrafficOptions();
+ updateSimulateColorSpace();
+ updateUseNuplayerOptions();
+ updateUSBAudioOptions();
}
private void resetDangerousOptions() {
@@ -509,9 +556,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
}
}
resetDebuggerOptions();
+ writeLogdSizeOption(null);
writeAnimationScaleOption(0, mWindowAnimationScale, null);
writeAnimationScaleOption(1, mTransitionAnimationScale, null);
writeAnimationScaleOption(2, mAnimatorDurationScale, null);
+ // Only poke the color space setting if we control it.
+ if (usingDevelopmentColorSpace()) {
+ writeSimulateColorSpace(-1);
+ }
writeOverlayDisplayDevicesOptions(null);
writeAppProcessLimitOptions(null);
mHaveDebugSettings = false;
@@ -520,53 +572,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
pokeSystemProperties();
}
- void filterRuntimeOptions(Preference selectRuntime) {
- ListPreference pref = (ListPreference) selectRuntime;
- ArrayList<String> validValues = new ArrayList<String>();
- ArrayList<String> validSummaries = new ArrayList<String>();
- String[] values = getResources().getStringArray(R.array.select_runtime_values);
- String[] summaries = getResources().getStringArray(R.array.select_runtime_summaries);
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
- String summary = summaries[i];
- if (new File("/system/lib/" + value).exists()) {
- validValues.add(value);
- validSummaries.add(summary);
- }
- }
- int count = validValues.size();
- if (count <= 1) {
- // no choices, so remove preference
- removePreference(selectRuntime);
- } else {
- pref.setEntryValues(validValues.toArray(new String[count]));
- pref.setEntries(validSummaries.toArray(new String[count]));
- }
- }
-
- private String currentRuntimeValue() {
- return SystemProperties.get(SELECT_RUNTIME_PROPERTY, VMRuntime.getRuntime().vmLibrary());
- }
-
- private void updateRuntimeValue() {
- ListPreference selectRuntime = (ListPreference) findPreference(SELECT_RUNTIME_KEY);
- if (selectRuntime != null) {
- String currentValue = currentRuntimeValue();
- String[] values = getResources().getStringArray(R.array.select_runtime_values);
- String[] summaries = getResources().getStringArray(R.array.select_runtime_summaries);
- int index = 0;
- for (int i = 0; i < values.length; i++) {
- if (currentValue.equals(values[i])) {
- index = i;
- break;
- }
- }
- selectRuntime.setValue(values[index]);
- selectRuntime.setSummary(summaries[index]);
- selectRuntime.setOnPreferenceChangeListener(this);
- }
- }
-
private void updateHdcpValues() {
ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY);
if (hdcpChecking != null) {
@@ -682,6 +687,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.PACKAGE_VERIFIER_SETTING_VISIBLE, 1) > 0;
}
+ private static boolean showEnableOemUnlockPreference() {
+ return !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("");
+ }
+
private void updateBugreportOptions() {
if ("user".equals(Build.TYPE)) {
final ContentResolver resolver = getActivity().getContentResolver();
@@ -933,6 +942,83 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
pokeSystemProperties();
}
+ private void updateSimulateColorSpace() {
+ final ContentResolver cr = getContentResolver();
+ final boolean enabled = Settings.Secure.getInt(
+ cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0) != 0;
+ if (enabled) {
+ final String mode = Integer.toString(Settings.Secure.getInt(
+ cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
+ AccessibilityManager.DALTONIZER_DISABLED));
+ mSimulateColorSpace.setValue(mode);
+ final int index = mSimulateColorSpace.findIndexOfValue(mode);
+ if (index < 0) {
+ // We're using a mode controlled by accessibility preferences.
+ mSimulateColorSpace.setSummary(getString(R.string.daltonizer_type_overridden,
+ getString(R.string.accessibility_display_daltonizer_preference_title)));
+ } else {
+ mSimulateColorSpace.setSummary("%s");
+ }
+ } else {
+ mSimulateColorSpace.setValue(
+ Integer.toString(AccessibilityManager.DALTONIZER_DISABLED));
+ }
+ }
+
+ /**
+ * @return <code>true</code> if the color space preference is currently
+ * controlled by development settings
+ */
+ private boolean usingDevelopmentColorSpace() {
+ final ContentResolver cr = getContentResolver();
+ final boolean enabled = Settings.Secure.getInt(
+ cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0) != 0;
+ if (enabled) {
+ final String mode = Integer.toString(Settings.Secure.getInt(
+ cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
+ AccessibilityManager.DALTONIZER_DISABLED));
+ final int index = mSimulateColorSpace.findIndexOfValue(mode);
+ if (index >= 0) {
+ // We're using a mode controlled by developer preferences.
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void writeSimulateColorSpace(Object value) {
+ final ContentResolver cr = getContentResolver();
+ final int newMode = Integer.parseInt(value.toString());
+ if (newMode < 0) {
+ Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
+ } else {
+ Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 1);
+ Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, newMode);
+ }
+ }
+
+ private void updateUseNuplayerOptions() {
+ updateCheckBox(
+ mUseNuplayer, !SystemProperties.getBoolean(USE_AWESOMEPLAYER_PROPERTY, false));
+ }
+
+ private void writeUseNuplayerOptions() {
+ SystemProperties.set(
+ USE_AWESOMEPLAYER_PROPERTY, mUseNuplayer.isChecked() ? "false" : "true");
+ pokeSystemProperties();
+ }
+
+ private void updateUSBAudioOptions() {
+ updateCheckBox(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
+ }
+
+ private void writeUSBAudioOptions() {
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED,
+ mUSBAudio.isChecked() ? 1 : 0);
+ }
+
private void updateForceRtlOptions() {
updateCheckBox(mForceRtlLayout, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL, 0) != 0);
@@ -958,6 +1044,82 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mWifiDisplayCertification.isChecked() ? 1 : 0);
}
+ private void updateWifiVerboseLoggingOptions() {
+ boolean enabled = mWifiManager.getVerboseLoggingLevel() > 0;
+ updateCheckBox(mWifiVerboseLogging, enabled);
+ }
+
+ private void writeWifiVerboseLoggingOptions() {
+ mWifiManager.enableVerboseLogging(mWifiVerboseLogging.isChecked() ? 1 : 0);
+ }
+
+ private void updateWifiAggressiveHandoverOptions() {
+ boolean enabled = mWifiManager.getAggressiveHandover() > 0;
+ updateCheckBox(mWifiAggressiveHandover, enabled);
+ }
+
+ private void writeWifiAggressiveHandoverOptions() {
+ mWifiManager.enableAggressiveHandover(mWifiAggressiveHandover.isChecked() ? 1 : 0);
+ }
+
+ private void updateWifiAllowScansWithTrafficOptions() {
+ boolean enabled = mWifiManager.getAllowScansWithTraffic() > 0;
+ updateCheckBox(mWifiAllowScansWithTraffic, enabled);
+ }
+
+ private void writeWifiAllowScansWithTrafficOptions() {
+ mWifiManager.setAllowScansWithTraffic(mWifiAllowScansWithTraffic.isChecked() ? 1 : 0);
+ }
+
+ private void updateLogdSizeValues() {
+ if (mLogdSize != null) {
+ String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
+ if (currentValue == null) {
+ currentValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY);
+ if (currentValue == null) {
+ currentValue = "256K";
+ }
+ }
+ String[] values = getResources().getStringArray(R.array.select_logd_size_values);
+ String[] titles = getResources().getStringArray(R.array.select_logd_size_titles);
+ if (SystemProperties.get("ro.config.low_ram").equals("true")) {
+ mLogdSize.setEntries(R.array.select_logd_size_lowram_titles);
+ titles = getResources().getStringArray(R.array.select_logd_size_lowram_titles);
+ }
+ String[] summaries = getResources().getStringArray(R.array.select_logd_size_summaries);
+ int index = 1; // punt to second entry if not found
+ for (int i = 0; i < titles.length; i++) {
+ if (currentValue.equals(values[i])
+ || currentValue.equals(titles[i])) {
+ index = i;
+ break;
+ }
+ }
+ mLogdSize.setValue(values[index]);
+ mLogdSize.setSummary(summaries[index]);
+ mLogdSize.setOnPreferenceChangeListener(this);
+ }
+ }
+
+ private void writeLogdSizeOption(Object newValue) {
+ String currentValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY);
+ if (currentValue != null) {
+ DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES = currentValue;
+ }
+ final String size = (newValue != null) ?
+ newValue.toString() : DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES;
+ SystemProperties.set(SELECT_LOGD_SIZE_PROPERTY, size);
+ pokeSystemProperties();
+ try {
+ Process p = Runtime.getRuntime().exec("logcat -b all -G " + size);
+ p.waitFor();
+ Log.i(TAG, "Logcat ring buffer sizes set to: " + size);
+ } catch (Exception e) {
+ Log.w(TAG, "Cannot set logcat ring buffer sizes", e);
+ }
+ updateLogdSizeValues();
+ }
+
private void updateCpuUsageOptions() {
updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.SHOW_PROCESSES, 0) != 0);
@@ -1116,28 +1278,28 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
}
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (buttonView == mEnabledSwitch) {
- if (isChecked != mLastEnabledState) {
- if (isChecked) {
- mDialogClicked = false;
- if (mEnableDialog != null) dismissDialogs();
- mEnableDialog = new AlertDialog.Builder(getActivity()).setMessage(
- getActivity().getResources().getString(
- R.string.dev_settings_warning_message))
- .setTitle(R.string.dev_settings_warning_title)
- .setIconAttribute(android.R.attr.alertDialogIcon)
- .setPositiveButton(android.R.string.yes, this)
- .setNegativeButton(android.R.string.no, this)
- .show();
- mEnableDialog.setOnDismissListener(this);
- } else {
- resetDangerousOptions();
- Settings.Global.putInt(getActivity().getContentResolver(),
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
- mLastEnabledState = isChecked;
- setPrefsEnabledState(mLastEnabledState);
- }
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ if (switchView != mSwitchBar.getSwitch()) {
+ return;
+ }
+ if (isChecked != mLastEnabledState) {
+ if (isChecked) {
+ mDialogClicked = false;
+ if (mEnableDialog != null) dismissDialogs();
+ mEnableDialog = new AlertDialog.Builder(getActivity()).setMessage(
+ getActivity().getResources().getString(
+ R.string.dev_settings_warning_message))
+ .setTitle(R.string.dev_settings_warning_title)
+ .setPositiveButton(android.R.string.yes, this)
+ .setNegativeButton(android.R.string.no, this)
+ .show();
+ mEnableDialog.setOnDismissListener(this);
+ } else {
+ resetDangerousOptions();
+ Settings.Global.putInt(getActivity().getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+ mLastEnabledState = isChecked;
+ setPrefsEnabledState(mLastEnabledState);
}
}
}
@@ -1168,7 +1330,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mAdbDialog = new AlertDialog.Builder(getActivity()).setMessage(
getActivity().getResources().getString(R.string.adb_warning_message))
.setTitle(R.string.adb_warning_title)
- .setIconAttribute(android.R.attr.alertDialogIcon)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this)
.show();
@@ -1200,13 +1361,19 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.putInt(getActivity().getContentResolver(),
Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
mKeepScreenOn.isChecked() ?
- (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
+ (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
} else if (preference == mBtHciSnoopLog) {
writeBtHciSnoopLogOptions();
+ } else if (preference == mEnableOemUnlock) {
+ Utils.setOemUnlockEnabled(getActivity(), mEnableOemUnlock.isChecked());
} else if (preference == mAllowMockLocation) {
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ALLOW_MOCK_LOCATION,
mAllowMockLocation.isChecked() ? 1 : 0);
+ } else if (preference == mDebugViewAttributes) {
+ Settings.Global.putInt(getActivity().getContentResolver(),
+ Settings.Global.DEBUG_VIEW_ATTRIBUTES,
+ mDebugViewAttributes.isChecked() ? 1 : 0);
} else if (preference == mDebugAppPref) {
startActivityForResult(new Intent(getActivity(), AppPicker.class), RESULT_DEBUG_APP);
} else if (preference == mWaitForDebugger) {
@@ -1243,6 +1410,16 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
writeForceRtlOptions();
} else if (preference == mWifiDisplayCertification) {
writeWifiDisplayCertificationOptions();
+ } else if (preference == mWifiVerboseLogging) {
+ writeWifiVerboseLoggingOptions();
+ } else if (preference == mWifiAggressiveHandover) {
+ writeWifiAggressiveHandoverOptions();
+ } else if (preference == mWifiAllowScansWithTraffic) {
+ writeWifiAllowScansWithTrafficOptions();
+ } else if (preference == mUseNuplayer) {
+ writeUseNuplayerOptions();
+ } else if (preference == mUSBAudio) {
+ writeUSBAudioOptions();
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@@ -1252,38 +1429,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (SELECT_RUNTIME_KEY.equals(preference.getKey())) {
- final String oldRuntimeValue = VMRuntime.getRuntime().vmLibrary();
- final String newRuntimeValue = newValue.toString();
- if (!newRuntimeValue.equals(oldRuntimeValue)) {
- final Context context = getActivity();
- final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setMessage(context.getResources().getString(R.string.select_runtime_warning_message,
- oldRuntimeValue, newRuntimeValue));
- builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- SystemProperties.set(SELECT_RUNTIME_PROPERTY, newRuntimeValue);
- pokeSystemProperties();
- PowerManager pm = (PowerManager)
- context.getSystemService(Context.POWER_SERVICE);
- pm.reboot(null);
- }
- });
- builder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- updateRuntimeValue();
- }
- });
- builder.show();
- }
- return true;
- } else if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
+ if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
updateHdcpValues();
pokeSystemProperties();
return true;
+ } else if (preference == mLogdSize) {
+ writeLogdSizeOption(newValue);
+ return true;
} else if (preference == mWindowAnimationScale) {
writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
return true;
@@ -1311,6 +1464,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} else if (preference == mAppProcessLimit) {
writeAppProcessLimitOptions(newValue);
return true;
+ } else if (preference == mSimulateColorSpace) {
+ writeSimulateColorSpace(newValue);
+ return true;
}
return false;
}
@@ -1362,7 +1518,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
setPrefsEnabledState(mLastEnabledState);
} else {
// Reset the toggle
- mEnabledSwitch.setChecked(false);
+ mSwitchBar.setChecked(false);
}
}
}
@@ -1376,7 +1532,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mAdbDialog = null;
} else if (dialog == mEnableDialog) {
if (!mDialogClicked) {
- mEnabledSwitch.setChecked(false);
+ mSwitchBar.setChecked(false);
}
mEnableDialog = null;
}
@@ -1429,4 +1585,44 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
return false;
}
}
+
+ /**
+ * For Search.
+ */
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ private boolean isShowingDeveloperOptions(Context context) {
+ return context.getSharedPreferences(DevelopmentSettings.PREF_FILE,
+ Context.MODE_PRIVATE).getBoolean(
+ DevelopmentSettings.PREF_SHOW,
+ android.os.Build.TYPE.equals("eng"));
+ }
+
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+
+ if (!isShowingDeveloperOptions(context)) {
+ return null;
+ }
+
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.development_prefs;
+ return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ if (!isShowingDeveloperOptions(context)) {
+ return null;
+ }
+
+ final List<String> keys = new ArrayList<String>();
+ if (!showEnableOemUnlockPreference()) {
+ keys.add(ENABLE_OEM_UNLOCK);
+ }
+ return keys;
+ }
+ };
}