Add debug menu to enable btsnoop

bug: 8059358
Change-Id: Ib695aa5c9fff96d1676f718a2e3fb0bbf91eca04
This commit is contained in:
Zhihai Xu
2013-07-26 13:33:16 -07:00
parent 1fb887f264
commit 84bbb548a6
3 changed files with 25 additions and 0 deletions

View File

@@ -3074,6 +3074,10 @@
<string name="keep_screen_on">Stay awake</string>
<!-- setting Checkbox summary whether to keep the screen on when plugged in -->
<string name="keep_screen_on_summary">Screen will never sleep while charging</string>
<!-- Setting Checkbox title whether to enable bluetooth HCI snoop log -->
<string name="bt_hci_snoop_log">Enable Bluetooth HCI snoop log</string>
<!-- setting Checkbox summary whether to capture all bluetooth HCI packets in a file -->
<string name="bt_hci_snoop_log_summary">Capture all bluetooth HCI packets in a file</string>
<!-- Runtime selection title, used for debug purposes only. [CHAR LIMIT=25] -->
<string name="select_runtime_title">Select runtime </string>

View File

@@ -56,6 +56,11 @@
android:title="@string/enforce_read_external_title"
android:summary="@string/enforce_read_external_summary" />
<CheckBoxPreference
android:key="bt_hci_snoop_log"
android:title="@string/bt_hci_snoop_log"
android:summary="@string/bt_hci_snoop_log_summary"/>
<PreferenceCategory android:key="debug_debugging_category"
android:title="@string/debug_debugging_category">

View File

@@ -27,6 +27,7 @@ import android.app.Dialog;
import android.app.DialogFragment;
import android.app.admin.DevicePolicyManager;
import android.app.backup.IBackupManager;
import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -97,6 +98,7 @@ public class DevelopmentSettings extends PreferenceFragment
private static final String CLEAR_ADB_KEYS = "clear_adb_keys";
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 ALLOW_MOCK_LOCATION = "allow_mock_location";
@@ -167,6 +169,7 @@ public class DevelopmentSettings extends PreferenceFragment
private Preference mBugreport;
private CheckBoxPreference mBugreportInPower;
private CheckBoxPreference mKeepScreenOn;
private CheckBoxPreference mBtHciSnoopLog;
private CheckBoxPreference mEnforceReadExternal;
private CheckBoxPreference mAllowMockLocation;
private PreferenceScreen mPassword;
@@ -252,6 +255,7 @@ public class DevelopmentSettings extends PreferenceFragment
mBugreport = findPreference(BUGREPORT);
mBugreportInPower = findAndInitCheckboxPref(BUGREPORT_IN_POWER_KEY);
mKeepScreenOn = findAndInitCheckboxPref(KEEP_SCREEN_ON);
mBtHciSnoopLog = findAndInitCheckboxPref(BT_HCI_SNOOP_LOG);
mEnforceReadExternal = findAndInitCheckboxPref(ENFORCE_READ_EXTERNAL);
mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
@@ -477,6 +481,8 @@ public class DevelopmentSettings extends PreferenceFragment
Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0);
updateCheckBox(mKeepScreenOn, Settings.Global.getInt(cr,
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
updateCheckBox(mBtHciSnoopLog, Settings.Secure.getInt(cr,
Settings.Secure.BLUETOOTH_HCI_LOG, 0) != 0);
updateCheckBox(mEnforceReadExternal, isPermissionEnforced(READ_EXTERNAL_STORAGE));
updateCheckBox(mAllowMockLocation, Settings.Secure.getInt(cr,
Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
@@ -607,6 +613,14 @@ public class DevelopmentSettings extends PreferenceFragment
}
}
private void writeBtHciSnoopLogOptions() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
adapter.configHciSnoopLog(mBtHciSnoopLog.isChecked());
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.BLUETOOTH_HCI_LOG,
mBtHciSnoopLog.isChecked() ? 1 : 0);
}
private void writeDebuggerOptions() {
try {
ActivityManagerNative.getDefault().setDebugApp(
@@ -1193,6 +1207,8 @@ public class DevelopmentSettings extends PreferenceFragment
Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
mKeepScreenOn.isChecked() ?
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
} else if (preference == mBtHciSnoopLog) {
writeBtHciSnoopLogOptions();
} else if (preference == mEnforceReadExternal) {
if (mEnforceReadExternal.isChecked()) {
ConfirmEnforceFragment.show(this);