Add debug menu to enable btsnoop
bug: 8059358
Change-Id: I2d5f13e68defefb92e0b11b749fe77ad67215f36
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 79bb476..5075544 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -599,6 +599,25 @@
}
/**
+ * enable or disable Bluetooth HCI snoop log.
+ *
+ * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
+ * permission
+ *
+ * @return true to indicate configure HCI log successfully, or false on
+ * immediate error
+ * @hide
+ */
+ public boolean configHciSnoopLog(boolean enable) {
+ try {
+ synchronized(mManagerCallback) {
+ if (mService != null) return mService.configHciSnoopLog(enable);
+ }
+ } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return false;
+ }
+
+ /**
* Get the UUIDs supported by the local Bluetooth adapter.
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index 80806f9..07db8cc 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -80,4 +80,6 @@
// For Socket
ParcelFileDescriptor connectSocket(in BluetoothDevice device, int type, in ParcelUuid uuid, int port, int flag);
ParcelFileDescriptor createSocketChannel(int type, in String serviceName, in ParcelUuid uuid, int port, int flag);
+
+ boolean configHciSnoopLog(boolean enable);
}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index c1a296d..914c64f 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3192,6 +3192,13 @@
"input_method_selector_visibility";
/**
+ * bluetooth HCI snoop log configuration
+ * @hide
+ */
+ public static final String BLUETOOTH_HCI_LOG =
+ "bluetooth_hci_log";
+
+ /**
* @deprecated Use {@link android.provider.Settings.Global#DEVICE_PROVISIONED} instead
*/
@Deprecated
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java
index f0164cb..a5cf362 100644
--- a/services/java/com/android/server/BluetoothManagerService.java
+++ b/services/java/com/android/server/BluetoothManagerService.java
@@ -788,11 +788,21 @@
} // else must be SERVICE_IBLUETOOTH
//Remove timeout
- mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);
+ mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);
mBinding = false;
mBluetooth = IBluetooth.Stub.asInterface(service);
+ try {
+ boolean enableHciSnoopLog = (Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.BLUETOOTH_HCI_LOG, 0) == 1);
+ if (!mBluetooth.configHciSnoopLog(enableHciSnoopLog)) {
+ Log.e(TAG,"IBluetooth.configHciSnoopLog return false");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG,"Unable to call configHciSnoopLog", e);
+ }
+
if (mConnection.isGetNameAddressOnly()) {
//Request GET NAME AND ADDRESS
Message getMsg = mHandler.obtainMessage(MESSAGE_GET_NAME_AND_ADDRESS);