Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +5 −8 Original line number Original line Diff line number Diff line Loading @@ -1997,6 +1997,9 @@ public class AdapterService extends Service { mLeAudioService = LeAudioService.getLeAudioService(); mLeAudioService = LeAudioService.getLeAudioService(); mBassClientService = BassClientService.getBassClientService(); mBassClientService = BassClientService.getBassClientService(); mBatteryService = BatteryService.getBatteryService(); mBatteryService = BatteryService.getBatteryService(); if (Flags.scanManagerRefactor()) { mGattService = GattService.getGattService(); } } } @BluetoothAdapter.RfcommListenerResult @BluetoothAdapter.RfcommListenerResult Loading Loading @@ -4200,10 +4203,7 @@ public class AdapterService extends Service { @Override @Override public IBinder getBluetoothGatt() { public IBinder getBluetoothGatt() { AdapterService service = getService(); AdapterService service = getService(); if (service == null) { return service == null ? null : service.getBluetoothGatt(); return null; } return service.getBluetoothGatt(); } } @Override @Override Loading Loading @@ -5915,10 +5915,7 @@ public class AdapterService extends Service { } } IBinder getBluetoothGatt() { IBinder getBluetoothGatt() { if (mGattService == null) { return mGattService == null ? null : mGattService.getBinder(); return null; } return ((ProfileService) mGattService).getBinder(); } } IBinder getBluetoothScan() { IBinder getBluetoothScan() { Loading android/app/src/com/android/bluetooth/gatt/GattService.java +39 −0 Original line number Original line Diff line number Diff line Loading @@ -140,6 +140,9 @@ public class GattService extends ProfileService { public final TransitionalScanHelper mTransitionalScanHelper = public final TransitionalScanHelper mTransitionalScanHelper = new TransitionalScanHelper(this, this::isTestModeEnabled); new TransitionalScanHelper(this, this::isTestModeEnabled); /** This is only used when Flags.scanManagerRefactor() is true. */ private static GattService sGattService; /** List of our registered advertisers. */ /** List of our registered advertisers. */ static class AdvertiserMap extends ContextMap<IAdvertisingSetCallback, Void> {} static class AdvertiserMap extends ContextMap<IAdvertisingSetCallback, Void> {} Loading Loading @@ -200,6 +203,11 @@ public class GattService extends ProfileService { @Override @Override public void start() { public void start() { Log.d(TAG, "start()"); Log.d(TAG, "start()"); if (Flags.scanManagerRefactor() && sGattService != null) { throw new IllegalStateException("start() called twice"); } Settings.Global.putInt( Settings.Global.putInt( getContentResolver(), "bluetooth_sanitized_exposure_notification_supported", 1); getContentResolver(), "bluetooth_sanitized_exposure_notification_supported", 1); Loading @@ -220,11 +228,24 @@ public class GattService extends ProfileService { mActivityManager = getSystemService(ActivityManager.class); mActivityManager = getSystemService(ActivityManager.class); mPackageManager = mAdapterService.getPackageManager(); mPackageManager = mAdapterService.getPackageManager(); if (Flags.scanManagerRefactor()) { setGattService(this); } } } @Override @Override public void stop() { public void stop() { Log.d(TAG, "stop()"); Log.d(TAG, "stop()"); if (Flags.scanManagerRefactor() && sGattService != null) { Log.w(TAG, "stop() called before start()"); return; } if (Flags.scanManagerRefactor()) { setGattService(null); } mTransitionalScanHelper.stop(); mTransitionalScanHelper.stop(); mAdvertiserMap.clear(); mAdvertiserMap.clear(); mClientMap.clear(); mClientMap.clear(); Loading Loading @@ -253,6 +274,24 @@ public class GattService extends ProfileService { mTransitionalScanHelper.cleanup(); mTransitionalScanHelper.cleanup(); } } /** This is only used when Flags.scanManagerRefactor() is true. */ public static synchronized GattService getGattService() { if (sGattService == null) { Log.w(TAG, "getGattService(): service is null"); return null; } if (!sGattService.isAvailable()) { Log.w(TAG, "getGattService(): service is not available"); return null; } return sGattService; } private static synchronized void setGattService(GattService instance) { Log.d(TAG, "setGattService(): set to: " + instance); sGattService = instance; } TransitionalScanHelper getTransitionalScanHelper() { TransitionalScanHelper getTransitionalScanHelper() { return mTransitionalScanHelper; return mTransitionalScanHelper; } } Loading Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +5 −8 Original line number Original line Diff line number Diff line Loading @@ -1997,6 +1997,9 @@ public class AdapterService extends Service { mLeAudioService = LeAudioService.getLeAudioService(); mLeAudioService = LeAudioService.getLeAudioService(); mBassClientService = BassClientService.getBassClientService(); mBassClientService = BassClientService.getBassClientService(); mBatteryService = BatteryService.getBatteryService(); mBatteryService = BatteryService.getBatteryService(); if (Flags.scanManagerRefactor()) { mGattService = GattService.getGattService(); } } } @BluetoothAdapter.RfcommListenerResult @BluetoothAdapter.RfcommListenerResult Loading Loading @@ -4200,10 +4203,7 @@ public class AdapterService extends Service { @Override @Override public IBinder getBluetoothGatt() { public IBinder getBluetoothGatt() { AdapterService service = getService(); AdapterService service = getService(); if (service == null) { return service == null ? null : service.getBluetoothGatt(); return null; } return service.getBluetoothGatt(); } } @Override @Override Loading Loading @@ -5915,10 +5915,7 @@ public class AdapterService extends Service { } } IBinder getBluetoothGatt() { IBinder getBluetoothGatt() { if (mGattService == null) { return mGattService == null ? null : mGattService.getBinder(); return null; } return ((ProfileService) mGattService).getBinder(); } } IBinder getBluetoothScan() { IBinder getBluetoothScan() { Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +39 −0 Original line number Original line Diff line number Diff line Loading @@ -140,6 +140,9 @@ public class GattService extends ProfileService { public final TransitionalScanHelper mTransitionalScanHelper = public final TransitionalScanHelper mTransitionalScanHelper = new TransitionalScanHelper(this, this::isTestModeEnabled); new TransitionalScanHelper(this, this::isTestModeEnabled); /** This is only used when Flags.scanManagerRefactor() is true. */ private static GattService sGattService; /** List of our registered advertisers. */ /** List of our registered advertisers. */ static class AdvertiserMap extends ContextMap<IAdvertisingSetCallback, Void> {} static class AdvertiserMap extends ContextMap<IAdvertisingSetCallback, Void> {} Loading Loading @@ -200,6 +203,11 @@ public class GattService extends ProfileService { @Override @Override public void start() { public void start() { Log.d(TAG, "start()"); Log.d(TAG, "start()"); if (Flags.scanManagerRefactor() && sGattService != null) { throw new IllegalStateException("start() called twice"); } Settings.Global.putInt( Settings.Global.putInt( getContentResolver(), "bluetooth_sanitized_exposure_notification_supported", 1); getContentResolver(), "bluetooth_sanitized_exposure_notification_supported", 1); Loading @@ -220,11 +228,24 @@ public class GattService extends ProfileService { mActivityManager = getSystemService(ActivityManager.class); mActivityManager = getSystemService(ActivityManager.class); mPackageManager = mAdapterService.getPackageManager(); mPackageManager = mAdapterService.getPackageManager(); if (Flags.scanManagerRefactor()) { setGattService(this); } } } @Override @Override public void stop() { public void stop() { Log.d(TAG, "stop()"); Log.d(TAG, "stop()"); if (Flags.scanManagerRefactor() && sGattService != null) { Log.w(TAG, "stop() called before start()"); return; } if (Flags.scanManagerRefactor()) { setGattService(null); } mTransitionalScanHelper.stop(); mTransitionalScanHelper.stop(); mAdvertiserMap.clear(); mAdvertiserMap.clear(); mClientMap.clear(); mClientMap.clear(); Loading Loading @@ -253,6 +274,24 @@ public class GattService extends ProfileService { mTransitionalScanHelper.cleanup(); mTransitionalScanHelper.cleanup(); } } /** This is only used when Flags.scanManagerRefactor() is true. */ public static synchronized GattService getGattService() { if (sGattService == null) { Log.w(TAG, "getGattService(): service is null"); return null; } if (!sGattService.isAvailable()) { Log.w(TAG, "getGattService(): service is not available"); return null; } return sGattService; } private static synchronized void setGattService(GattService instance) { Log.d(TAG, "setGattService(): set to: " + instance); sGattService = instance; } TransitionalScanHelper getTransitionalScanHelper() { TransitionalScanHelper getTransitionalScanHelper() { return mTransitionalScanHelper; return mTransitionalScanHelper; } } Loading