OSDN Git Service

Adds a menu item for additional battery info to battery settings.
[android-x86/packages-apps-Settings.git] / src / com / android / settings / DevelopmentSettings.java
index 9815b41..41d96d6 100644 (file)
@@ -18,7 +18,7 @@ package com.android.settings;
 
 import android.Manifest;
 import android.app.Activity;
-import android.app.ActivityManagerNative;
+import android.app.ActivityManager;
 import android.app.AlertDialog;
 import android.app.AppOpsManager;
 import android.app.AppOpsManager.PackageOps;
@@ -54,10 +54,11 @@ import android.os.StrictMode;
 import android.os.SystemProperties;
 import android.os.UserHandle;
 import android.os.UserManager;
-import android.os.storage.IMountService;
+import android.os.storage.IStorageManager;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 import android.service.persistentdata.PersistentDataBlockManager;
+import android.support.annotation.VisibleForTesting;
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
@@ -79,15 +80,20 @@ import android.widget.Switch;
 import android.widget.Toast;
 
 import com.android.internal.app.LocalePicker;
-import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.applications.BackgroundCheckSummary;
+import com.android.settings.dashboard.DashboardFeatureProvider;
+import com.android.settings.development.BugReportPreferenceController;
+import com.android.settings.development.BugReportInPowerPreferenceController;
 import com.android.settings.fuelgauge.InactiveApps;
+import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.widget.SwitchBar;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.drawer.CategoryKey;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -99,7 +105,7 @@ import java.util.List;
  */
 public class DevelopmentSettings extends RestrictedSettingsFragment
         implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
-                OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable {
+        OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable {
     private static final String TAG = "DevelopmentSettings";
 
     /**
@@ -125,8 +131,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";
     private static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw";
     private static final String MSAA_PROPERTY = "debug.egl.force_msaa";
-    private static final String BUGREPORT = "bugreport";
-    private static final String BUGREPORT_IN_POWER_KEY = "bugreport_in_power";
     private static final String OPENGL_TRACES_PROPERTY = "debug.egl.trace";
     private static final String TUNER_UI_KEY = "tuner_ui";
     private static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp";
@@ -135,7 +139,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
     private static final String MOCK_LOCATION_APP_KEY = "mock_location_app";
     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 DEBUG_VIEW_ATTRIBUTES = "debug_view_attributes";
     private static final String FORCE_ALLOW_ON_EXTERNAL_KEY = "force_allow_on_external";
     private static final String STRICT_MODE_KEY = "strict_mode";
     private static final String POINTER_LOCATION_KEY = "pointer_location";
@@ -177,7 +181,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private static final String SELECT_LOGPERSIST_PROPERTY_SERVICE = "logcatd";
     private static final String SELECT_LOGPERSIST_PROPERTY_CLEAR = "clear";
     private static final String SELECT_LOGPERSIST_PROPERTY_STOP = "stop";
-    private static final String SELECT_LOGPERSIST_PROPERTY_BUFFER = "persist.logd.logpersistd.buffer";
+    private static final String SELECT_LOGPERSIST_PROPERTY_BUFFER =
+            "persist.logd.logpersistd.buffer";
     private static final String ACTUAL_LOGPERSIST_PROPERTY_BUFFER = "logd.logpersistd.buffer";
     private static final String ACTUAL_LOGPERSIST_PROPERTY_ENABLE = "logd.logpersistd.enable";
 
@@ -192,9 +197,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
 
     private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY =
-                                    "bluetooth_disable_absolute_volume";
+            "bluetooth_disable_absolute_volume";
     private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
-                                    "persist.bluetooth.disableabsvol";
+            "persist.bluetooth.disableabsvol";
 
     private static final String INACTIVE_APPS_KEY = "inactive_apps";
 
@@ -224,7 +229,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
 
-    private static final int[] MOCK_LOCATION_APP_OPS = new int[] {AppOpsManager.OP_MOCK_LOCATION};
+    private static final int[] MOCK_LOCATION_APP_OPS = new int[]{AppOpsManager.OP_MOCK_LOCATION};
 
     private IWindowManager mWindowManager;
     private IBackupManager mBackupManager;
@@ -243,8 +248,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private SwitchPreference mEnableAdb;
     private Preference mClearAdbKeys;
     private SwitchPreference mEnableTerminal;
-    private Preference mBugreport;
-    private SwitchPreference mBugreportInPower;
     private RestrictedSwitchPreference mKeepScreenOn;
     private SwitchPreference mBtHciSnoopLog;
     private RestrictedSwitchPreference mEnableOemUnlock;
@@ -324,34 +327,47 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private boolean mLogpersistCleared;
     private Dialog mLogpersistClearDialog;
+    private DashboardFeatureProvider mDashboardFeatureProvider;
+    private BugReportPreferenceController mBugReportController;
+    private BugReportInPowerPreferenceController mBugReportInPowerController;
 
     public DevelopmentSettings() {
         super(UserManager.DISALLOW_DEBUGGING_FEATURES);
     }
 
     @Override
-    protected int getMetricsCategory() {
+    public int getMetricsCategory() {
         return MetricsEvent.DEVELOPMENT;
     }
 
     @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mDashboardFeatureProvider = FeatureFactory.getFactory(context)
+                .getDashboardFeatureProvider(context);
+    }
+
+    @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
         mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
         mBackupManager = IBackupManager.Stub.asInterface(
                 ServiceManager.getService(Context.BACKUP_SERVICE));
-        mWebViewUpdateService  =
-            IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
-        mOemUnlockManager = (PersistentDataBlockManager)getActivity()
+        mWebViewUpdateService =
+                IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
+        mOemUnlockManager = (PersistentDataBlockManager) getActivity()
                 .getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
         mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
 
-        mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
+        mDpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
         mUm = (UserManager) getSystemService(Context.USER_SERVICE);
 
         mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
 
+        mBugReportController = new BugReportPreferenceController(getActivity());
+        mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
+
         setIfOnlyAvailableForAdmins(true);
         if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
             // Block access to developer options if the user is not the owner, if user policy
@@ -379,8 +395,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             mEnableTerminal = null;
         }
 
-        mBugreport = findPreference(BUGREPORT);
-        mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY);
+        mBugReportController.displayPreference(getPreferenceScreen());
+        mBugReportInPowerController.displayPreference(getPreferenceScreen());
+
         mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
         mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
         mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
@@ -480,19 +497,19 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         }
 
         PreferenceScreen convertFbePreference =
-            (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
+                (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
 
         try {
             IBinder service = ServiceManager.getService("mount");
-            IMountService mountService = IMountService.Stub.asInterface(service);
-            if (!mountService.isConvertibleToFBE()) {
+            IStorageManager storageManager = IStorageManager.Stub.asInterface(service);
+            if (!storageManager.isConvertibleToFBE()) {
                 removePreference(KEY_CONVERT_FBE);
             } else if ("file".equals(SystemProperties.get("ro.crypto.type", "none"))) {
                 convertFbePreference.setEnabled(false);
                 convertFbePreference.setSummary(getResources()
-                                   .getString(R.string.convert_to_file_encryption_done));
+                        .getString(R.string.convert_to_file_encryption_done));
             }
-        } catch(RemoteException e) {
+        } catch (RemoteException e) {
             removePreference(KEY_CONVERT_FBE);
         }
 
@@ -514,6 +531,20 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             removePreference(COLOR_TEMPERATURE_KEY);
             mColorTemperaturePreference = null;
         }
+
+        addDashboardCategoryPreferences();
+    }
+
+    @VisibleForTesting
+    void addDashboardCategoryPreferences() {
+        final PreferenceScreen screen = getPreferenceScreen();
+        final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(
+                getActivity(), getPrefContext(), CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
+        if (tilePrefs != null) {
+            for (Preference preference : tilePrefs) {
+                screen.addPreference(preference);
+            }
+        }
     }
 
     private ListPreference addListPreference(String prefKey) {
@@ -547,7 +578,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         final SettingsActivity activity = (SettingsActivity) getActivity();
 
         mSwitchBar = activity.getSwitchBar();
-       if (mUnavailable) {
+        if (mUnavailable) {
             mSwitchBar.setEnabled(false);
             return;
         }
@@ -574,6 +605,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             Preference pref = mAllPrefs.get(i);
             pref.setEnabled(enabled && !mDisabledPrefs.contains(pref));
         }
+        mBugReportInPowerController.enablePreference(enabled);
         updateAllOptions();
     }
 
@@ -675,8 +707,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                     context.getPackageManager().getApplicationEnabledSetting(TERMINAL_APP_PACKAGE)
                             == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
         }
-        updateSwitchPreference(mBugreportInPower, Settings.Secure.getInt(cr,
-                Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0);
+        mHaveDebugSettings |= mBugReportInPowerController.updatePreference();
         updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr,
                 Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
         updateSwitchPreference(mBtHciSnoopLog, Settings.Secure.getInt(cr,
@@ -731,13 +762,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private void resetDangerousOptions() {
         mDontPokeProperties = true;
-        for (int i=0; i< mResetSwitchPrefs.size(); i++) {
+        for (int i = 0; i < mResetSwitchPrefs.size(); i++) {
             SwitchPreference cb = mResetSwitchPrefs.get(i);
             if (cb.isChecked()) {
                 cb.setChecked(false);
                 onPreferenceTreeClick(cb);
             }
         }
+        mBugReportInPowerController.resetPreference();
         resetDebuggerOptions();
         writeLogpersistOption(null, true);
         writeLogdSizeOption(null);
@@ -765,7 +797,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             }
             ArrayList<String> options = new ArrayList<String>();
             ArrayList<String> values = new ArrayList<String>();
-            for(int n = 0; n < providers.length; n++) {
+            for (int n = 0; n < providers.length; n++) {
                 if (Utils.isPackageEnabled(getActivity(), providers[n].packageName)) {
                     options.add(providers[n].description);
                     values.add(providers[n].packageName);
@@ -785,7 +817,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                     return;
                 }
             }
-        } catch(RemoteException e) {
+        } catch (RemoteException e) {
         }
     }
 
@@ -802,9 +834,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
         try {
             String wv_package = mWebViewUpdateService.getCurrentWebViewPackageName();
-            ActivityManagerNative.getDefault().killPackageDependents(
+            ActivityManager.getService().killPackageDependents(
                     wv_package, UserHandle.USER_ALL);
-        } catch(RemoteException e) {
+        } catch (RemoteException e) {
         }
     }
 
@@ -853,15 +885,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                     newValue == null ? "" : newValue.toString());
             updateWebViewProviderOptions();
             return newValue != null && newValue.equals(updatedProvider);
-        } catch(RemoteException e) {
+        } catch (RemoteException e) {
         }
         return false;
     }
 
     private void writeDebuggerOptions() {
         try {
-            ActivityManagerNative.getDefault().setDebugApp(
-                mDebugApp, mWaitForDebugger.isChecked(), true);
+            ActivityManager.getService().setDebugApp(
+                    mDebugApp, mWaitForDebugger.isChecked(), true);
         } catch (RemoteException ex) {
         }
     }
@@ -903,7 +935,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private static void resetDebuggerOptions() {
         try {
-            ActivityManagerNative.getDefault().setDebugApp(
+            ActivityManager.getService().setDebugApp(
                     null, false, true);
         } catch (RemoteException ex) {
         }
@@ -967,8 +999,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     }
 
     private void updateVerifyAppsOverUsbOptions() {
-        updateSwitchPreference(mVerifyAppsOverUsb, Settings.Global.getInt(getActivity().getContentResolver(),
-                Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0);
+        updateSwitchPreference(mVerifyAppsOverUsb,
+                Settings.Global.getInt(getActivity().getContentResolver(),
+                        Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0);
         mVerifyAppsOverUsb.setEnabled(enableVerifierSetting());
     }
 
@@ -1048,19 +1081,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     }
 
     private void updateBugreportOptions() {
-        mBugreport.setEnabled(true);
-        mBugreportInPower.setEnabled(true);
-        setBugreportStorageProviderStatus();
-    }
-
-    private void setBugreportStorageProviderStatus() {
-        final ComponentName componentName = new ComponentName("com.android.shell",
-                "com.android.shell.BugreportStorageProvider");
-        final boolean enabled = mBugreportInPower.isChecked();
-        getPackageManager().setComponentEnabledSetting(componentName,
-                enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
-                        : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
-                0);
+        mBugReportController.enablePreference(true);
+        mBugReportInPowerController.updateBugreportOptions();
     }
 
     // Returns the current state of the system property that controls
@@ -1323,7 +1345,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     /**
      * @return <code>true</code> if the color space preference is currently
-     *         controlled by development settings
+     * controlled by development settings
      */
     private boolean usingDevelopmentColorSpace() {
         final ContentResolver cr = getContentResolver();
@@ -1483,7 +1505,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             }
             if (mLogpersist != null) {
                 String currentLogpersistEnable
-                    = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_ENABLE);
+                        = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_ENABLE);
                 if ((currentLogpersistEnable == null)
                         || !currentLogpersistEnable.equals("true")
                         || currentValue.equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE)) {
@@ -1520,7 +1542,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private void writeLogdSizeOption(Object newValue) {
         boolean disable = (newValue != null) &&
-            (newValue.toString().equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE));
+                (newValue.toString().equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE));
         String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
         if (currentTag == null) {
             currentTag = "";
@@ -1553,7 +1575,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         }
         String defaultValue = defaultLogdSizeValue();
         final String size = ((newValue != null) && (newValue.toString().length() != 0)) ?
-            newValue.toString() : defaultValue;
+                newValue.toString() : defaultValue;
         SystemProperties.set(SELECT_LOGD_SIZE_PROPERTY, defaultValue.equals(size) ? "" : size);
         SystemProperties.set("ctl.start", "logd-reinit");
         pokeSystemProperties();
@@ -1583,7 +1605,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                     currentBuffers.contains("kernel")) {
                 index = 2;
                 if (!currentBuffers.contains("default")) {
-                    String[] contains = { "main", "events", "system", "crash" };
+                    String[] contains = {"main", "events", "system", "crash"};
                     for (int i = 0; i < contains.length; i++) {
                         if (!currentBuffers.contains(contains[i])) {
                             index = 1;
@@ -1593,8 +1615,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                 }
             }
         }
-        mLogpersist.setValue(getResources().getStringArray(R.array.select_logpersist_values)[index]);
-        mLogpersist.setSummary(getResources().getStringArray(R.array.select_logpersist_summaries)[index]);
+        mLogpersist.setValue(
+                getResources().getStringArray(R.array.select_logpersist_values)[index]);
+        mLogpersist.setSummary(
+                getResources().getStringArray(R.array.select_logpersist_summaries)[index]);
         mLogpersist.setOnPreferenceChangeListener(this);
         if (index != 0) {
             mLogpersistCleared = false;
@@ -1612,7 +1636,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY_BUFFER, "");
         SystemProperties.set(SELECT_LOGPERSIST_PROPERTY, "");
         SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY,
-            update ? "" : SELECT_LOGPERSIST_PROPERTY_STOP);
+                update ? "" : SELECT_LOGPERSIST_PROPERTY_STOP);
         pokeSystemProperties();
         if (update) {
             updateLogpersistValues();
@@ -1705,7 +1729,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     }
 
     private void writeUsbConfigurationOption(Object newValue) {
-        UsbManager manager = (UsbManager)getActivity().getSystemService(Context.USB_SERVICE);
+        UsbManager manager = (UsbManager) getActivity().getSystemService(Context.USB_SERVICE);
         String function = newValue.toString();
         if (function.equals("none")) {
             manager.setCurrentFunction(function, false);
@@ -1716,7 +1740,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private void writeImmediatelyDestroyActivitiesOptions() {
         try {
-            ActivityManagerNative.getDefault().setAlwaysFinish(
+            ActivityManager.getService().setAlwaysFinish(
                     mImmediatelyDestroyActivities.isChecked());
         } catch (RemoteException ex) {
         }
@@ -1724,7 +1748,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private void updateImmediatelyDestroyActivitiesOptions() {
         updateSwitchPreference(mImmediatelyDestroyActivities, Settings.Global.getInt(
-                getActivity().getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0) != 0);
+                getActivity().getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0)
+                != 0);
     }
 
     private void updateAnimationScaleValue(int which, ListPreference pref) {
@@ -1734,7 +1759,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                 mHaveDebugSettings = true;
             }
             CharSequence[] values = pref.getEntryValues();
-            for (int i=0; i<values.length; i++) {
+            for (int i = 0; i < values.length; i++) {
                 float val = Float.parseFloat(values[i].toString());
                 if (scale <= val) {
                     pref.setValueIndex(i);
@@ -1742,7 +1767,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                     return;
                 }
             }
-            pref.setValueIndex(values.length-1);
+            pref.setValueIndex(values.length - 1);
             pref.setSummary(pref.getEntries()[0]);
         } catch (RemoteException e) {
         }
@@ -1790,9 +1815,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
 
     private void updateAppProcessLimitOptions() {
         try {
-            int limit = ActivityManagerNative.getDefault().getProcessLimit();
+            int limit = ActivityManager.getService().getProcessLimit();
             CharSequence[] values = mAppProcessLimit.getEntryValues();
-            for (int i=0; i<values.length; i++) {
+            for (int i = 0; i < values.length; i++) {
                 int val = Integer.parseInt(values[i].toString());
                 if (val >= limit) {
                     if (i != 0) {
@@ -1812,7 +1837,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private void writeAppProcessLimitOptions(Object newValue) {
         try {
             int limit = newValue != null ? Integer.parseInt(newValue.toString()) : -1;
-            ActivityManagerNative.getDefault().setProcessLimit(limit);
+            ActivityManager.getService().setProcessLimit(limit);
             updateAppProcessLimitOptions();
         } catch (RemoteException e) {
         }
@@ -1839,15 +1864,16 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             }
         };
 
-        DialogInterface.OnDismissListener onDismissListener = new DialogInterface.OnDismissListener() {
-            @Override
-            public void onDismiss(DialogInterface dialog) {
-                if (getActivity() == null) {
-                    return;
-                }
-                updateAllOptions();
-            }
-        };
+        DialogInterface.OnDismissListener onDismissListener =
+                new DialogInterface.OnDismissListener() {
+                    @Override
+                    public void onDismiss(DialogInterface dialog) {
+                        if (getActivity() == null) {
+                            return;
+                        }
+                        updateAllOptions();
+                    }
+                };
 
         new AlertDialog.Builder(getActivity())
                 .setTitle(R.string.confirm_enable_oem_unlock_title)
@@ -1919,6 +1945,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             return false;
         }
 
+        if (mBugReportInPowerController.handlePreferenceTreeClick(preference)) {
+            return true;
+        }
+
         if (preference == mEnableAdb) {
             if (mEnableAdb.isChecked()) {
                 mDialogClicked = false;
@@ -1940,25 +1970,21 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         } else if (preference == mClearAdbKeys) {
             if (mAdbKeysDialog != null) dismissDialogs();
             mAdbKeysDialog = new AlertDialog.Builder(getActivity())
-                        .setMessage(R.string.adb_keys_warning_message)
-                        .setPositiveButton(android.R.string.ok, this)
-                        .setNegativeButton(android.R.string.cancel, null)
-                        .show();
+                    .setMessage(R.string.adb_keys_warning_message)
+                    .setPositiveButton(android.R.string.ok, this)
+                    .setNegativeButton(android.R.string.cancel, null)
+                    .show();
         } else if (preference == mEnableTerminal) {
             final PackageManager pm = getActivity().getPackageManager();
             pm.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE,
                     mEnableTerminal.isChecked() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                             : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
-        } else if (preference == mBugreportInPower) {
-            Settings.Secure.putInt(getActivity().getContentResolver(),
-                    Settings.Global.BUGREPORT_IN_POWER_MENU,
-                    mBugreportInPower.isChecked() ? 1 : 0);
-            setBugreportStorageProviderStatus();
         } else if (preference == mKeepScreenOn) {
             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
+                                    | BatteryManager.BATTERY_PLUGGED_WIRELESS) : 0);
         } else if (preference == mBtHciSnoopLog) {
             writeBtHciSnoopLogOptions();
         } else if (preference == mEnableOemUnlock && mEnableOemUnlock.isEnabled()) {
@@ -2269,8 +2295,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                 private boolean isShowingDeveloperOptions(Context context) {
                     return context.getSharedPreferences(DevelopmentSettings.PREF_FILE,
                             Context.MODE_PRIVATE).getBoolean(
-                                    DevelopmentSettings.PREF_SHOW,
-                                    android.os.Build.TYPE.equals("eng"));
+                            DevelopmentSettings.PREF_SHOW,
+                            android.os.Build.TYPE.equals("eng"));
                 }
 
                 @Override
@@ -2327,7 +2353,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                 // the device hasn't been able to confirm which restrictions (SIM-lock or otherwise)
                 // apply.
                 oemUnlockSummary =
-                    R.string.oem_unlock_enable_disabled_summary_connectivity_or_locked;
+                        R.string.oem_unlock_enable_disabled_summary_connectivity_or_locked;
             }
             mEnableOemUnlock.setSummary(getString(oemUnlockSummary));
         }