Loading android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +0 −7 Original line number Diff line number Diff line Loading @@ -744,10 +744,6 @@ class AdapterProperties { intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM); debugLog("Scan Mode:" + mScanMode); if (mBluetoothDisabling) { mBluetoothDisabling = false; mService.startBluetoothDisable(); } break; case AbstractionLayer.BT_PROPERTY_UUIDS: mUuids = Utils.byteArrayToUuid(val); Loading Loading @@ -842,8 +838,6 @@ class AdapterProperties { } } private boolean mBluetoothDisabling = false; void onBleDisable() { // Sequence BLE_ON to STATE_OFF - that is _complete_ OFF state. // When BT disable is invoked, set the scan_mode to NONE Loading @@ -862,7 +856,6 @@ class AdapterProperties { //Set flag to indicate we are disabling. When property change of scan mode done //continue with disable sequence debugLog("onBluetoothDisable()"); mBluetoothDisabling = true; if (getState() == BluetoothAdapter.STATE_TURNING_OFF) { // Turn off any Device Search/Inquiry mService.cancelDiscovery(); Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +58 −20 Original line number Diff line number Diff line Loading @@ -270,9 +270,11 @@ public class AdapterService extends Service { } mRunningProfiles.add(profile); if (GattService.class.getSimpleName().equals(profile.getName())) { mAdapterStateMachine.sendMessage(AdapterState.BLE_STARTED); enableNativeWithGuestFlag(); } else if (mRegisteredProfiles.size() == Config.getSupportedProfiles().length && mRegisteredProfiles.size() == mRunningProfiles.size()) { updateUuids(); setBluetoothClassFromConfig(); mAdapterStateMachine.sendMessage(AdapterState.BREDR_STARTED); } break; Loading @@ -291,6 +293,7 @@ public class AdapterService extends Service { .equals(mRunningProfiles.get(0).getName())))) { mAdapterStateMachine.sendMessage(AdapterState.BREDR_STOPPED); } else if (mRunningProfiles.size() == 0) { disableNative(); mAdapterStateMachine.sendMessage(AdapterState.BLE_STOPPED); } break; Loading Loading @@ -369,8 +372,8 @@ public class AdapterService extends Service { mRemoteDevices.init(); mBinder = new AdapterServiceBinder(this); mAdapterProperties = new AdapterProperties(this); mAdapterStateMachine = AdapterState.make(this, mAdapterProperties); mJniCallbacks = new JniCallbacks(mAdapterStateMachine, mAdapterProperties); mAdapterStateMachine = AdapterState.make(this); mJniCallbacks = new JniCallbacks(this, mAdapterProperties); initNative(); mNativeAvailable = true; mCallbacks = new RemoteCallbackList<IBluetoothCallback>(); Loading Loading @@ -473,7 +476,7 @@ public class AdapterService extends Service { } }; void bleOnProcessStart() { void bringUpBle() { debugLog("bleOnProcessStart()"); if (getResources().getBoolean( Loading Loading @@ -508,6 +511,20 @@ public class AdapterService extends Service { setProfileServiceState(GattService.class, BluetoothAdapter.STATE_ON); } void bringDownBle() { stopGattProfileService(); } void stateChangeCallback(int status) { if (status == AbstractionLayer.BT_STATE_OFF) { debugLog("stateChangeCallback: disableNative() completed"); } else if (status == AbstractionLayer.BT_STATE_ON) { mAdapterStateMachine.sendMessage(AdapterState.BLE_STARTED); } else { Log.e(TAG, "Incorrect status " + status + " in stateChangeCallback"); } } /** * Sets the Bluetooth CoD value of the local adapter if there exists a config value for it. */ Loading @@ -534,31 +551,42 @@ public class AdapterService extends Service { return result; } void startCoreServices() { void startProfileServices() { debugLog("startCoreServices()"); Class[] supportedProfileServices = Config.getSupportedProfiles(); if (supportedProfileServices.length == 1 && GattService.class.getSimpleName() .equals(supportedProfileServices[0].getSimpleName())) { updateUuids(); setBluetoothClassFromConfig(); mAdapterStateMachine.sendMessage(AdapterState.BREDR_STARTED); } else { setAllProfileServiceStates(supportedProfileServices, BluetoothAdapter.STATE_ON); } void startBluetoothDisable() { mAdapterStateMachine.sendMessage(AdapterState.BEGIN_DISABLE); } void stopProfileServices() { mAdapterProperties.onBluetoothDisable(); Class[] supportedProfileServices = Config.getSupportedProfiles(); if (mRunningProfiles.size() == 0) { if (supportedProfileServices.length == 1 && (mRunningProfiles.size() == 1 && GattService.class.getSimpleName().equals(mRunningProfiles.get(0).getName()))) { debugLog("stopProfileServices() - No profiles services to stop or already stopped."); return; } mAdapterStateMachine.sendMessage(AdapterState.BREDR_STOPPED); } else { setAllProfileServiceStates(supportedProfileServices, BluetoothAdapter.STATE_OFF); } } boolean stopGattProfileService() { private void stopGattProfileService() { mAdapterProperties.onBleDisable(); if (mRunningProfiles.size() == 0) { debugLog("stopGattProfileService() - No profiles services to stop."); mAdapterStateMachine.sendMessage(AdapterState.BLE_STOPPED); } setProfileServiceState(GattService.class, BluetoothAdapter.STATE_OFF); return true; } void updateAdapterState(int prevState, int newState) { mAdapterProperties.setState(newState); if (mCallbacks != null) { int n = mCallbacks.beginBroadcast(); debugLog("updateAdapterState() - Broadcasting state " + BluetoothAdapter.nameForState( Loading Loading @@ -1576,7 +1604,7 @@ public class AdapterService extends Service { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); debugLog("disable() called with mRunningProfiles.size() = " + mRunningProfiles.size()); mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_OFF); mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_OFF); return true; } Loading Loading @@ -2185,12 +2213,12 @@ public class AdapterService extends Service { return mAdapterProperties.getTotalNumOfTrackableAdvertisements(); } public void onLeServiceUp() { void onLeServiceUp() { mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_ON); } public void onBrEdrDown() { mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_OFF); void onBrEdrDown() { mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_OFF); } private static int convertScanModeToHal(int mode) { Loading Loading @@ -2384,6 +2412,9 @@ public class AdapterService extends Service { + device.getName()); } writer.println(); mAdapterStateMachine.dump(fd, writer, args); StringBuilder sb = new StringBuilder(); for (ProfileService profile : mRegisteredProfiles) { profile.dump(sb); Loading Loading @@ -2447,7 +2478,14 @@ public class AdapterService extends Service { } }; private static native void classInitNative(); private void enableNativeWithGuestFlag() { boolean isGuest = UserManager.get(this).isGuestUser(); if (!enableNative(isGuest)) { Log.e(TAG, "enableNative() returned false"); } } static native void classInitNative(); native boolean initNative(); Loading Loading
android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +0 −7 Original line number Diff line number Diff line Loading @@ -744,10 +744,6 @@ class AdapterProperties { intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM); debugLog("Scan Mode:" + mScanMode); if (mBluetoothDisabling) { mBluetoothDisabling = false; mService.startBluetoothDisable(); } break; case AbstractionLayer.BT_PROPERTY_UUIDS: mUuids = Utils.byteArrayToUuid(val); Loading Loading @@ -842,8 +838,6 @@ class AdapterProperties { } } private boolean mBluetoothDisabling = false; void onBleDisable() { // Sequence BLE_ON to STATE_OFF - that is _complete_ OFF state. // When BT disable is invoked, set the scan_mode to NONE Loading @@ -862,7 +856,6 @@ class AdapterProperties { //Set flag to indicate we are disabling. When property change of scan mode done //continue with disable sequence debugLog("onBluetoothDisable()"); mBluetoothDisabling = true; if (getState() == BluetoothAdapter.STATE_TURNING_OFF) { // Turn off any Device Search/Inquiry mService.cancelDiscovery(); Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +58 −20 Original line number Diff line number Diff line Loading @@ -270,9 +270,11 @@ public class AdapterService extends Service { } mRunningProfiles.add(profile); if (GattService.class.getSimpleName().equals(profile.getName())) { mAdapterStateMachine.sendMessage(AdapterState.BLE_STARTED); enableNativeWithGuestFlag(); } else if (mRegisteredProfiles.size() == Config.getSupportedProfiles().length && mRegisteredProfiles.size() == mRunningProfiles.size()) { updateUuids(); setBluetoothClassFromConfig(); mAdapterStateMachine.sendMessage(AdapterState.BREDR_STARTED); } break; Loading @@ -291,6 +293,7 @@ public class AdapterService extends Service { .equals(mRunningProfiles.get(0).getName())))) { mAdapterStateMachine.sendMessage(AdapterState.BREDR_STOPPED); } else if (mRunningProfiles.size() == 0) { disableNative(); mAdapterStateMachine.sendMessage(AdapterState.BLE_STOPPED); } break; Loading Loading @@ -369,8 +372,8 @@ public class AdapterService extends Service { mRemoteDevices.init(); mBinder = new AdapterServiceBinder(this); mAdapterProperties = new AdapterProperties(this); mAdapterStateMachine = AdapterState.make(this, mAdapterProperties); mJniCallbacks = new JniCallbacks(mAdapterStateMachine, mAdapterProperties); mAdapterStateMachine = AdapterState.make(this); mJniCallbacks = new JniCallbacks(this, mAdapterProperties); initNative(); mNativeAvailable = true; mCallbacks = new RemoteCallbackList<IBluetoothCallback>(); Loading Loading @@ -473,7 +476,7 @@ public class AdapterService extends Service { } }; void bleOnProcessStart() { void bringUpBle() { debugLog("bleOnProcessStart()"); if (getResources().getBoolean( Loading Loading @@ -508,6 +511,20 @@ public class AdapterService extends Service { setProfileServiceState(GattService.class, BluetoothAdapter.STATE_ON); } void bringDownBle() { stopGattProfileService(); } void stateChangeCallback(int status) { if (status == AbstractionLayer.BT_STATE_OFF) { debugLog("stateChangeCallback: disableNative() completed"); } else if (status == AbstractionLayer.BT_STATE_ON) { mAdapterStateMachine.sendMessage(AdapterState.BLE_STARTED); } else { Log.e(TAG, "Incorrect status " + status + " in stateChangeCallback"); } } /** * Sets the Bluetooth CoD value of the local adapter if there exists a config value for it. */ Loading @@ -534,31 +551,42 @@ public class AdapterService extends Service { return result; } void startCoreServices() { void startProfileServices() { debugLog("startCoreServices()"); Class[] supportedProfileServices = Config.getSupportedProfiles(); if (supportedProfileServices.length == 1 && GattService.class.getSimpleName() .equals(supportedProfileServices[0].getSimpleName())) { updateUuids(); setBluetoothClassFromConfig(); mAdapterStateMachine.sendMessage(AdapterState.BREDR_STARTED); } else { setAllProfileServiceStates(supportedProfileServices, BluetoothAdapter.STATE_ON); } void startBluetoothDisable() { mAdapterStateMachine.sendMessage(AdapterState.BEGIN_DISABLE); } void stopProfileServices() { mAdapterProperties.onBluetoothDisable(); Class[] supportedProfileServices = Config.getSupportedProfiles(); if (mRunningProfiles.size() == 0) { if (supportedProfileServices.length == 1 && (mRunningProfiles.size() == 1 && GattService.class.getSimpleName().equals(mRunningProfiles.get(0).getName()))) { debugLog("stopProfileServices() - No profiles services to stop or already stopped."); return; } mAdapterStateMachine.sendMessage(AdapterState.BREDR_STOPPED); } else { setAllProfileServiceStates(supportedProfileServices, BluetoothAdapter.STATE_OFF); } } boolean stopGattProfileService() { private void stopGattProfileService() { mAdapterProperties.onBleDisable(); if (mRunningProfiles.size() == 0) { debugLog("stopGattProfileService() - No profiles services to stop."); mAdapterStateMachine.sendMessage(AdapterState.BLE_STOPPED); } setProfileServiceState(GattService.class, BluetoothAdapter.STATE_OFF); return true; } void updateAdapterState(int prevState, int newState) { mAdapterProperties.setState(newState); if (mCallbacks != null) { int n = mCallbacks.beginBroadcast(); debugLog("updateAdapterState() - Broadcasting state " + BluetoothAdapter.nameForState( Loading Loading @@ -1576,7 +1604,7 @@ public class AdapterService extends Service { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); debugLog("disable() called with mRunningProfiles.size() = " + mRunningProfiles.size()); mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_OFF); mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_OFF); return true; } Loading Loading @@ -2185,12 +2213,12 @@ public class AdapterService extends Service { return mAdapterProperties.getTotalNumOfTrackableAdvertisements(); } public void onLeServiceUp() { void onLeServiceUp() { mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_ON); } public void onBrEdrDown() { mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_OFF); void onBrEdrDown() { mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_OFF); } private static int convertScanModeToHal(int mode) { Loading Loading @@ -2384,6 +2412,9 @@ public class AdapterService extends Service { + device.getName()); } writer.println(); mAdapterStateMachine.dump(fd, writer, args); StringBuilder sb = new StringBuilder(); for (ProfileService profile : mRegisteredProfiles) { profile.dump(sb); Loading Loading @@ -2447,7 +2478,14 @@ public class AdapterService extends Service { } }; private static native void classInitNative(); private void enableNativeWithGuestFlag() { boolean isGuest = UserManager.get(this).isGuestUser(); if (!enableNative(isGuest)) { Log.e(TAG, "enableNative() returned false"); } } static native void classInitNative(); native boolean initNative(); Loading