Loading android/app/src/com/android/bluetooth/a2dp/A2dpService.java +4 −11 Original line number Diff line number Diff line Loading @@ -182,20 +182,17 @@ public class A2dpService extends ProfileService { mAvrcp.cleanup(); mAvrcp = null; } clearA2dpService(); // TODO(b/72948646): should be moved to stop() setA2dpService(null); } public static synchronized A2dpService getA2dpService() { if (sA2dpService == null) { if (DBG) { Log.d(TAG, "getA2dpService(): service is NULL"); } Log.w(TAG, "getA2dpService(): service is null"); return null; } if (!sA2dpService.isAvailable()) { if (DBG) { Log.d(TAG, "getA2dpService(): service is not available"); } Log.w(TAG, "getA2dpService(): service is not available"); return null; } return sA2dpService; Loading @@ -208,10 +205,6 @@ public class A2dpService extends ProfileService { sA2dpService = instance; } private static synchronized void clearA2dpService() { sA2dpService = null; } public boolean connect(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); if (DBG) { Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +11 −30 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ public class A2dpSinkService extends ProfileService { if (DBG) { Log.d(TAG, "stop()"); } setA2dpSinkService(null); if (mStateMachine != null) { mStateMachine.doQuit(); } Loading @@ -79,47 +80,27 @@ public class A2dpSinkService extends ProfileService { if (mStateMachine != null) { mStateMachine.cleanup(); } clearA2dpSinkService(); } //API Methods public static synchronized A2dpSinkService getA2dpSinkService() { if (sA2dpSinkService != null && sA2dpSinkService.isAvailable()) { if (DBG) { Log.d(TAG, "getA2dpSinkService(): returning " + sA2dpSinkService); } return sA2dpSinkService; } if (DBG) { if (sA2dpSinkService == null) { Log.d(TAG, "getA2dpSinkService(): service is NULL"); } else if (!(sA2dpSinkService.isAvailable())) { Log.d(TAG, "getA2dpSinkService(): service is not available"); } Log.w(TAG, "getA2dpSinkService(): service is null"); return null; } if (!sA2dpSinkService.isAvailable()) { Log.w(TAG, "getA2dpSinkService(): service is not available "); return null; } return sA2dpSinkService; } private static synchronized void setA2dpSinkService(A2dpSinkService instance) { if (instance != null && instance.isAvailable()) { if (DBG) { Log.d(TAG, "setA2dpSinkService(): set to: " + sA2dpSinkService); Log.d(TAG, "setA2dpSinkService(): set to: " + instance); } sA2dpSinkService = instance; } else { if (DBG) { if (sA2dpSinkService == null) { Log.d(TAG, "setA2dpSinkService(): service not available"); } else if (!sA2dpSinkService.isAvailable()) { Log.d(TAG, "setA2dpSinkService(): service is cleaning up"); } } } } private static synchronized void clearA2dpSinkService() { sA2dpSinkService = null; } public boolean connect(BluetoothDevice device) { Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +11 −29 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ public class AvrcpControllerService extends ProfileService { @Override protected boolean stop() { setAvrcpControllerService(null); if (mAvrcpCtSm != null) { mAvrcpCtSm.doQuit(); } Loading @@ -231,41 +232,22 @@ public class AvrcpControllerService extends ProfileService { //API Methods public static synchronized AvrcpControllerService getAvrcpControllerService() { if (sAvrcpControllerService != null && sAvrcpControllerService.isAvailable()) { if (DBG) { Log.d(TAG, "getAvrcpControllerService(): returning " + sAvrcpControllerService); } return sAvrcpControllerService; } if (DBG) { if (sAvrcpControllerService == null) { Log.d(TAG, "getAvrcpControllerService(): service is NULL"); } else if (!(sAvrcpControllerService.isAvailable())) { Log.d(TAG, "getAvrcpControllerService(): service is not available"); } Log.w(TAG, "getAvrcpControllerService(): service is null"); return null; } if (!sAvrcpControllerService.isAvailable()) { Log.w(TAG, "getAvrcpControllerService(): service is not available "); return null; } return sAvrcpControllerService; } private static synchronized void setAvrcpControllerService(AvrcpControllerService instance) { if (instance != null && instance.isAvailable()) { if (DBG) { Log.d(TAG, "setAvrcpControllerService(): set to: " + sAvrcpControllerService); Log.d(TAG, "setAvrcpControllerService(): set to: " + instance); } sAvrcpControllerService = instance; } else { if (DBG) { if (instance == null) { Log.d(TAG, "setAvrcpControllerService(): service not available"); } else if (!instance.isAvailable()) { Log.d(TAG, "setAvrcpControllerService(): service is cleaning up"); } } } } private static synchronized void clearAvrcpControllerService() { sAvrcpControllerService = null; } public synchronized List<BluetoothDevice> getConnectedDevices() { Loading android/app/src/com/android/bluetooth/gatt/GattService.java +30 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,8 @@ public class GattService extends ProfileService { private ScanManager mScanManager; private AppOpsManager mAppOps; private static GattService sGattService; /** * Reliable write queue */ Loading Loading @@ -201,6 +203,7 @@ public class GattService extends ProfileService { mPeriodicScanManager = new PeriodicScanManager(AdapterService.getAdapterService()); mPeriodicScanManager.start(); setGattService(this); return true; } Loading @@ -209,6 +212,7 @@ public class GattService extends ProfileService { if (DBG) { Log.d(TAG, "stop()"); } setGattService(null); mScannerMap.clear(); mClientMap.clear(); mServerMap.clear(); Loading Loading @@ -243,6 +247,32 @@ public class GattService extends ProfileService { } } /** * Get the current instance of {@link GattService} * * @return current instance of {@link GattService} */ @VisibleForTesting 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) { if (DBG) { Log.d(TAG, "setGattService(): set to: " + instance); } sGattService = instance; } boolean permissionCheck(UUID uuid) { return !(isRestrictedCharUuid(uuid) && (0 != checkCallingOrSelfPermission( BLUETOOTH_PRIVILEGED))); Loading android/app/src/com/android/bluetooth/hdp/HealthService.java +30 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.bluetooth.Utils; Loading Loading @@ -67,6 +68,8 @@ public class HealthService extends ProfileService { private static final int MESSAGE_APP_REGISTRATION_CALLBACK = 11; private static final int MESSAGE_CHANNEL_STATE_CALLBACK = 12; private static HealthService sHealthService; static { classInitNative(); } Loading @@ -89,11 +92,13 @@ public class HealthService extends ProfileService { mHandler = new HealthServiceMessageHandler(looper); initializeNative(); mNativeAvailable = true; setHealthService(this); return true; } @Override protected boolean stop() { setHealthService(null); if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); Looper looper = mHandler.getLooper(); Loading Loading @@ -139,6 +144,31 @@ public class HealthService extends ProfileService { } } /** * Get a static reference to the current health service instance * * @return current health service instance */ @VisibleForTesting public static synchronized HealthService getHealthService() { if (sHealthService == null) { Log.w(TAG, "getHealthService(): service is null"); return null; } if (!sHealthService.isAvailable()) { Log.w(TAG, "getHealthService(): service is not available"); return null; } return sHealthService; } private static synchronized void setHealthService(HealthService instance) { if (DBG) { Log.d(TAG, "setHealthService(): set to: " + instance); } sHealthService = instance; } private final class HealthServiceMessageHandler extends Handler { private HealthServiceMessageHandler(Looper looper) { super(looper); Loading Loading
android/app/src/com/android/bluetooth/a2dp/A2dpService.java +4 −11 Original line number Diff line number Diff line Loading @@ -182,20 +182,17 @@ public class A2dpService extends ProfileService { mAvrcp.cleanup(); mAvrcp = null; } clearA2dpService(); // TODO(b/72948646): should be moved to stop() setA2dpService(null); } public static synchronized A2dpService getA2dpService() { if (sA2dpService == null) { if (DBG) { Log.d(TAG, "getA2dpService(): service is NULL"); } Log.w(TAG, "getA2dpService(): service is null"); return null; } if (!sA2dpService.isAvailable()) { if (DBG) { Log.d(TAG, "getA2dpService(): service is not available"); } Log.w(TAG, "getA2dpService(): service is not available"); return null; } return sA2dpService; Loading @@ -208,10 +205,6 @@ public class A2dpService extends ProfileService { sA2dpService = instance; } private static synchronized void clearA2dpService() { sA2dpService = null; } public boolean connect(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); if (DBG) { Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +11 −30 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ public class A2dpSinkService extends ProfileService { if (DBG) { Log.d(TAG, "stop()"); } setA2dpSinkService(null); if (mStateMachine != null) { mStateMachine.doQuit(); } Loading @@ -79,47 +80,27 @@ public class A2dpSinkService extends ProfileService { if (mStateMachine != null) { mStateMachine.cleanup(); } clearA2dpSinkService(); } //API Methods public static synchronized A2dpSinkService getA2dpSinkService() { if (sA2dpSinkService != null && sA2dpSinkService.isAvailable()) { if (DBG) { Log.d(TAG, "getA2dpSinkService(): returning " + sA2dpSinkService); } return sA2dpSinkService; } if (DBG) { if (sA2dpSinkService == null) { Log.d(TAG, "getA2dpSinkService(): service is NULL"); } else if (!(sA2dpSinkService.isAvailable())) { Log.d(TAG, "getA2dpSinkService(): service is not available"); } Log.w(TAG, "getA2dpSinkService(): service is null"); return null; } if (!sA2dpSinkService.isAvailable()) { Log.w(TAG, "getA2dpSinkService(): service is not available "); return null; } return sA2dpSinkService; } private static synchronized void setA2dpSinkService(A2dpSinkService instance) { if (instance != null && instance.isAvailable()) { if (DBG) { Log.d(TAG, "setA2dpSinkService(): set to: " + sA2dpSinkService); Log.d(TAG, "setA2dpSinkService(): set to: " + instance); } sA2dpSinkService = instance; } else { if (DBG) { if (sA2dpSinkService == null) { Log.d(TAG, "setA2dpSinkService(): service not available"); } else if (!sA2dpSinkService.isAvailable()) { Log.d(TAG, "setA2dpSinkService(): service is cleaning up"); } } } } private static synchronized void clearA2dpSinkService() { sA2dpSinkService = null; } public boolean connect(BluetoothDevice device) { Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +11 −29 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ public class AvrcpControllerService extends ProfileService { @Override protected boolean stop() { setAvrcpControllerService(null); if (mAvrcpCtSm != null) { mAvrcpCtSm.doQuit(); } Loading @@ -231,41 +232,22 @@ public class AvrcpControllerService extends ProfileService { //API Methods public static synchronized AvrcpControllerService getAvrcpControllerService() { if (sAvrcpControllerService != null && sAvrcpControllerService.isAvailable()) { if (DBG) { Log.d(TAG, "getAvrcpControllerService(): returning " + sAvrcpControllerService); } return sAvrcpControllerService; } if (DBG) { if (sAvrcpControllerService == null) { Log.d(TAG, "getAvrcpControllerService(): service is NULL"); } else if (!(sAvrcpControllerService.isAvailable())) { Log.d(TAG, "getAvrcpControllerService(): service is not available"); } Log.w(TAG, "getAvrcpControllerService(): service is null"); return null; } if (!sAvrcpControllerService.isAvailable()) { Log.w(TAG, "getAvrcpControllerService(): service is not available "); return null; } return sAvrcpControllerService; } private static synchronized void setAvrcpControllerService(AvrcpControllerService instance) { if (instance != null && instance.isAvailable()) { if (DBG) { Log.d(TAG, "setAvrcpControllerService(): set to: " + sAvrcpControllerService); Log.d(TAG, "setAvrcpControllerService(): set to: " + instance); } sAvrcpControllerService = instance; } else { if (DBG) { if (instance == null) { Log.d(TAG, "setAvrcpControllerService(): service not available"); } else if (!instance.isAvailable()) { Log.d(TAG, "setAvrcpControllerService(): service is cleaning up"); } } } } private static synchronized void clearAvrcpControllerService() { sAvrcpControllerService = null; } public synchronized List<BluetoothDevice> getConnectedDevices() { Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +30 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,8 @@ public class GattService extends ProfileService { private ScanManager mScanManager; private AppOpsManager mAppOps; private static GattService sGattService; /** * Reliable write queue */ Loading Loading @@ -201,6 +203,7 @@ public class GattService extends ProfileService { mPeriodicScanManager = new PeriodicScanManager(AdapterService.getAdapterService()); mPeriodicScanManager.start(); setGattService(this); return true; } Loading @@ -209,6 +212,7 @@ public class GattService extends ProfileService { if (DBG) { Log.d(TAG, "stop()"); } setGattService(null); mScannerMap.clear(); mClientMap.clear(); mServerMap.clear(); Loading Loading @@ -243,6 +247,32 @@ public class GattService extends ProfileService { } } /** * Get the current instance of {@link GattService} * * @return current instance of {@link GattService} */ @VisibleForTesting 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) { if (DBG) { Log.d(TAG, "setGattService(): set to: " + instance); } sGattService = instance; } boolean permissionCheck(UUID uuid) { return !(isRestrictedCharUuid(uuid) && (0 != checkCallingOrSelfPermission( BLUETOOTH_PRIVILEGED))); Loading
android/app/src/com/android/bluetooth/hdp/HealthService.java +30 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.bluetooth.Utils; Loading Loading @@ -67,6 +68,8 @@ public class HealthService extends ProfileService { private static final int MESSAGE_APP_REGISTRATION_CALLBACK = 11; private static final int MESSAGE_CHANNEL_STATE_CALLBACK = 12; private static HealthService sHealthService; static { classInitNative(); } Loading @@ -89,11 +92,13 @@ public class HealthService extends ProfileService { mHandler = new HealthServiceMessageHandler(looper); initializeNative(); mNativeAvailable = true; setHealthService(this); return true; } @Override protected boolean stop() { setHealthService(null); if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); Looper looper = mHandler.getLooper(); Loading Loading @@ -139,6 +144,31 @@ public class HealthService extends ProfileService { } } /** * Get a static reference to the current health service instance * * @return current health service instance */ @VisibleForTesting public static synchronized HealthService getHealthService() { if (sHealthService == null) { Log.w(TAG, "getHealthService(): service is null"); return null; } if (!sHealthService.isAvailable()) { Log.w(TAG, "getHealthService(): service is not available"); return null; } return sHealthService; } private static synchronized void setHealthService(HealthService instance) { if (DBG) { Log.d(TAG, "setHealthService(): set to: " + instance); } sHealthService = instance; } private final class HealthServiceMessageHandler extends Handler { private HealthServiceMessageHandler(Looper looper) { super(looper); Loading