Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +22 −6 Original line number Diff line number Diff line Loading @@ -112,8 +112,11 @@ public class AdapterService extends Service { private static final String ACTION_ALARM_WAKEUP = "com.android.bluetooth.btservice.action.ALARM_WAKEUP"; static final String BLUETOOTH_BTSNOOP_ENABLE_PROPERTY = "persist.bluetooth.btsnoopenable"; private boolean mSnoopLogSettingAtEnable = false; static final String BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY = "persist.bluetooth.btsnooplogmode"; static final String BLUETOOTH_BTSNOOP_DEFAULT_MODE_PROPERTY = "persist.bluetooth.btsnoopdefaultmode"; private String mSnoopLogSettingAtEnable = "empty"; private String mDefaultSnoopLogSettingAtEnable = "empty"; public static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN; public static final String BLUETOOTH_PRIVILEGED = Loading Loading @@ -610,15 +613,27 @@ public class AdapterService extends Service { } mCallbacks.finishBroadcast(); } // Turn the Adapter all the way off if we are disabling and the snoop log setting changed. if (newState == BluetoothAdapter.STATE_BLE_TURNING_ON) { mSnoopLogSettingAtEnable = SystemProperties.getBoolean(BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, false); SystemProperties.get(BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "empty"); mDefaultSnoopLogSettingAtEnable = Settings.Global.getString(getContentResolver(), Settings.Global.BLUETOOTH_BTSNOOP_DEFAULT_MODE); SystemProperties.set(BLUETOOTH_BTSNOOP_DEFAULT_MODE_PROPERTY, mDefaultSnoopLogSettingAtEnable); } else if (newState == BluetoothAdapter.STATE_BLE_ON && prevState != BluetoothAdapter.STATE_OFF) { boolean snoopLogSetting = SystemProperties.getBoolean(BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, false); if (mSnoopLogSettingAtEnable != snoopLogSetting) { String snoopLogSetting = SystemProperties.get(BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "empty"); String snoopDefaultModeSetting = Settings.Global.getString(getContentResolver(), Settings.Global.BLUETOOTH_BTSNOOP_DEFAULT_MODE); if (!TextUtils.equals(mSnoopLogSettingAtEnable, snoopLogSetting) || !TextUtils.equals(mDefaultSnoopLogSettingAtEnable, snoopDefaultModeSetting)) { mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_OFF); } } Loading Loading @@ -2540,6 +2555,7 @@ public class AdapterService extends Service { writer.println(); mAdapterProperties.dump(fd, writer, args); writer.println("mSnoopLogSettingAtEnable = " + mSnoopLogSettingAtEnable); writer.println("mDefaultSnoopLogSettingAtEnable = " + mDefaultSnoopLogSettingAtEnable); writer.println(); mAdapterStateMachine.dump(fd, writer, args); Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -451,17 +451,17 @@ public class AdapterServiceTest { @Test public void testSnoopLoggingChange() { String snoopSetting = SystemProperties.get(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, ""); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, "false"); SystemProperties.get(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, ""); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "false"); doEnable(0, false); Assert.assertTrue(mAdapterService.isEnabled()); Assert.assertFalse( SystemProperties.getBoolean(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, true)); SystemProperties.get(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "true").equals("true")); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, "true"); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "true"); mAdapterService.disable(); Loading Loading @@ -491,7 +491,7 @@ public class AdapterServiceTest { Assert.assertFalse(mAdapterService.isEnabled()); // Restore earlier setting SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, snoopSetting); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, snoopSetting); } Loading Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +22 −6 Original line number Diff line number Diff line Loading @@ -112,8 +112,11 @@ public class AdapterService extends Service { private static final String ACTION_ALARM_WAKEUP = "com.android.bluetooth.btservice.action.ALARM_WAKEUP"; static final String BLUETOOTH_BTSNOOP_ENABLE_PROPERTY = "persist.bluetooth.btsnoopenable"; private boolean mSnoopLogSettingAtEnable = false; static final String BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY = "persist.bluetooth.btsnooplogmode"; static final String BLUETOOTH_BTSNOOP_DEFAULT_MODE_PROPERTY = "persist.bluetooth.btsnoopdefaultmode"; private String mSnoopLogSettingAtEnable = "empty"; private String mDefaultSnoopLogSettingAtEnable = "empty"; public static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN; public static final String BLUETOOTH_PRIVILEGED = Loading Loading @@ -610,15 +613,27 @@ public class AdapterService extends Service { } mCallbacks.finishBroadcast(); } // Turn the Adapter all the way off if we are disabling and the snoop log setting changed. if (newState == BluetoothAdapter.STATE_BLE_TURNING_ON) { mSnoopLogSettingAtEnable = SystemProperties.getBoolean(BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, false); SystemProperties.get(BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "empty"); mDefaultSnoopLogSettingAtEnable = Settings.Global.getString(getContentResolver(), Settings.Global.BLUETOOTH_BTSNOOP_DEFAULT_MODE); SystemProperties.set(BLUETOOTH_BTSNOOP_DEFAULT_MODE_PROPERTY, mDefaultSnoopLogSettingAtEnable); } else if (newState == BluetoothAdapter.STATE_BLE_ON && prevState != BluetoothAdapter.STATE_OFF) { boolean snoopLogSetting = SystemProperties.getBoolean(BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, false); if (mSnoopLogSettingAtEnable != snoopLogSetting) { String snoopLogSetting = SystemProperties.get(BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "empty"); String snoopDefaultModeSetting = Settings.Global.getString(getContentResolver(), Settings.Global.BLUETOOTH_BTSNOOP_DEFAULT_MODE); if (!TextUtils.equals(mSnoopLogSettingAtEnable, snoopLogSetting) || !TextUtils.equals(mDefaultSnoopLogSettingAtEnable, snoopDefaultModeSetting)) { mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_OFF); } } Loading Loading @@ -2540,6 +2555,7 @@ public class AdapterService extends Service { writer.println(); mAdapterProperties.dump(fd, writer, args); writer.println("mSnoopLogSettingAtEnable = " + mSnoopLogSettingAtEnable); writer.println("mDefaultSnoopLogSettingAtEnable = " + mDefaultSnoopLogSettingAtEnable); writer.println(); mAdapterStateMachine.dump(fd, writer, args); Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -451,17 +451,17 @@ public class AdapterServiceTest { @Test public void testSnoopLoggingChange() { String snoopSetting = SystemProperties.get(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, ""); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, "false"); SystemProperties.get(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, ""); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "false"); doEnable(0, false); Assert.assertTrue(mAdapterService.isEnabled()); Assert.assertFalse( SystemProperties.getBoolean(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, true)); SystemProperties.get(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "true").equals("true")); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, "true"); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, "true"); mAdapterService.disable(); Loading Loading @@ -491,7 +491,7 @@ public class AdapterServiceTest { Assert.assertFalse(mAdapterService.isEnabled()); // Restore earlier setting SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, snoopSetting); SystemProperties.set(AdapterService.BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY, snoopSetting); } Loading