Loading android/app/aidl/android/bluetooth/IBluetooth.aidl +2 −2 Original line number Original line Diff line number Diff line Loading @@ -250,9 +250,9 @@ interface IBluetooth boolean removeActiveDevice(in int profiles, in AttributionSource attributionSource); boolean removeActiveDevice(in int profiles, in AttributionSource attributionSource); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") boolean registerBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); oneway void registerBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") boolean unregisterBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); oneway void unregisterBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") boolean canBondWithoutDialog(in BluetoothDevice device, in AttributionSource attributionSource); boolean canBondWithoutDialog(in BluetoothDevice device, in AttributionSource attributionSource); Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +5 −6 Original line number Original line Diff line number Diff line Loading @@ -3346,32 +3346,31 @@ public class AdapterService extends Service { } } @Override @Override public boolean registerBluetoothConnectionCallback( public void registerBluetoothConnectionCallback( IBluetoothConnectionCallback callback, AttributionSource source) { IBluetoothConnectionCallback callback, AttributionSource source) { AdapterService service = getService(); AdapterService service = getService(); if (service == null if (service == null || !callerIsSystemOrActiveOrManagedUser( || !callerIsSystemOrActiveOrManagedUser( service, TAG, "registerBluetoothConnectionCallback") service, TAG, "registerBluetoothConnectionCallback") || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { return false; return; } } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPrivilegedPermission(service); service.mBluetoothConnectionCallbacks.add(callback); service.mBluetoothConnectionCallbacks.add(callback); return true; } } @Override @Override public boolean unregisterBluetoothConnectionCallback( public void unregisterBluetoothConnectionCallback( IBluetoothConnectionCallback callback, AttributionSource source) { IBluetoothConnectionCallback callback, AttributionSource source) { AdapterService service = getService(); AdapterService service = getService(); if (service == null if (service == null || !callerIsSystemOrActiveOrManagedUser( || !callerIsSystemOrActiveOrManagedUser( service, TAG, "unregisterBluetoothConnectionCallback") service, TAG, "unregisterBluetoothConnectionCallback") || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { return false; return; } } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPrivilegedPermission(service); return service.mBluetoothConnectionCallbacks.remove(callback); service.mBluetoothConnectionCallbacks.remove(callback); } } @Override @Override Loading framework/java/android/bluetooth/BluetoothAdapter.java +28 −27 Original line number Original line Diff line number Diff line Loading @@ -4804,28 +4804,28 @@ public final class BluetoothAdapter { } } synchronized (mBluetoothConnectionCallbackExecutorMap) { synchronized (mBluetoothConnectionCallbackExecutorMap) { // If the callback map is empty, we register the service-to-app callback if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { throw new IllegalArgumentException("This callback has already been registered"); } if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) { if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) { // If the callback map is empty, we register the service-to-app callback mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); try { try { if (mService != null) { if (mService == null) { if (!mService.registerBluetoothConnectionCallback( mConnectionCallback, mAttributionSource)) { return false; return false; } } } mService.registerBluetoothConnectionCallback( mConnectionCallback, mAttributionSource); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); mBluetoothConnectionCallbackExecutorMap.remove(callback); return false; } finally { } finally { mServiceLock.readLock().unlock(); mServiceLock.readLock().unlock(); } } } } // Adds the passed in callback to our map of callbacks to executors // Adds the passed in callback to our map of callbacks to executors if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { throw new IllegalArgumentException("This callback has already been registered"); } mBluetoothConnectionCallbackExecutorMap.put(callback, executor); mBluetoothConnectionCallbackExecutorMap.put(callback, executor); } } Loading Loading @@ -4854,29 +4854,30 @@ public final class BluetoothAdapter { } } synchronized (mBluetoothConnectionCallbackExecutorMap) { synchronized (mBluetoothConnectionCallbackExecutorMap) { if (mBluetoothConnectionCallbackExecutorMap.remove(callback) != null) { if (!mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { return false; } } if (!mBluetoothConnectionCallbackExecutorMap.isEmpty()) { return true; return true; } } mBluetoothConnectionCallbackExecutorMap.remove(callback); if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) { // If the callback map is empty, we unregister the service-to-app callback // If the callback map is empty, we unregister the service-to-app callback mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); try { try { if (mService != null) { if (mService == null) { return mService.unregisterBluetoothConnectionCallback( return true; mConnectionCallback, mAttributionSource); } } mService.unregisterBluetoothConnectionCallback( mConnectionCallback, mAttributionSource); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } finally { } finally { mServiceLock.readLock().unlock(); mServiceLock.readLock().unlock(); } } } } return false; return true; } } /** /** Loading Loading
android/app/aidl/android/bluetooth/IBluetooth.aidl +2 −2 Original line number Original line Diff line number Diff line Loading @@ -250,9 +250,9 @@ interface IBluetooth boolean removeActiveDevice(in int profiles, in AttributionSource attributionSource); boolean removeActiveDevice(in int profiles, in AttributionSource attributionSource); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") boolean registerBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); oneway void registerBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") boolean unregisterBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); oneway void unregisterBluetoothConnectionCallback(in IBluetoothConnectionCallback callback, in AttributionSource attributionSource); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})") boolean canBondWithoutDialog(in BluetoothDevice device, in AttributionSource attributionSource); boolean canBondWithoutDialog(in BluetoothDevice device, in AttributionSource attributionSource); Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +5 −6 Original line number Original line Diff line number Diff line Loading @@ -3346,32 +3346,31 @@ public class AdapterService extends Service { } } @Override @Override public boolean registerBluetoothConnectionCallback( public void registerBluetoothConnectionCallback( IBluetoothConnectionCallback callback, AttributionSource source) { IBluetoothConnectionCallback callback, AttributionSource source) { AdapterService service = getService(); AdapterService service = getService(); if (service == null if (service == null || !callerIsSystemOrActiveOrManagedUser( || !callerIsSystemOrActiveOrManagedUser( service, TAG, "registerBluetoothConnectionCallback") service, TAG, "registerBluetoothConnectionCallback") || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { return false; return; } } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPrivilegedPermission(service); service.mBluetoothConnectionCallbacks.add(callback); service.mBluetoothConnectionCallbacks.add(callback); return true; } } @Override @Override public boolean unregisterBluetoothConnectionCallback( public void unregisterBluetoothConnectionCallback( IBluetoothConnectionCallback callback, AttributionSource source) { IBluetoothConnectionCallback callback, AttributionSource source) { AdapterService service = getService(); AdapterService service = getService(); if (service == null if (service == null || !callerIsSystemOrActiveOrManagedUser( || !callerIsSystemOrActiveOrManagedUser( service, TAG, "unregisterBluetoothConnectionCallback") service, TAG, "unregisterBluetoothConnectionCallback") || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) { return false; return; } } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPrivilegedPermission(service); return service.mBluetoothConnectionCallbacks.remove(callback); service.mBluetoothConnectionCallbacks.remove(callback); } } @Override @Override Loading
framework/java/android/bluetooth/BluetoothAdapter.java +28 −27 Original line number Original line Diff line number Diff line Loading @@ -4804,28 +4804,28 @@ public final class BluetoothAdapter { } } synchronized (mBluetoothConnectionCallbackExecutorMap) { synchronized (mBluetoothConnectionCallbackExecutorMap) { // If the callback map is empty, we register the service-to-app callback if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { throw new IllegalArgumentException("This callback has already been registered"); } if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) { if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) { // If the callback map is empty, we register the service-to-app callback mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); try { try { if (mService != null) { if (mService == null) { if (!mService.registerBluetoothConnectionCallback( mConnectionCallback, mAttributionSource)) { return false; return false; } } } mService.registerBluetoothConnectionCallback( mConnectionCallback, mAttributionSource); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); mBluetoothConnectionCallbackExecutorMap.remove(callback); return false; } finally { } finally { mServiceLock.readLock().unlock(); mServiceLock.readLock().unlock(); } } } } // Adds the passed in callback to our map of callbacks to executors // Adds the passed in callback to our map of callbacks to executors if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { throw new IllegalArgumentException("This callback has already been registered"); } mBluetoothConnectionCallbackExecutorMap.put(callback, executor); mBluetoothConnectionCallbackExecutorMap.put(callback, executor); } } Loading Loading @@ -4854,29 +4854,30 @@ public final class BluetoothAdapter { } } synchronized (mBluetoothConnectionCallbackExecutorMap) { synchronized (mBluetoothConnectionCallbackExecutorMap) { if (mBluetoothConnectionCallbackExecutorMap.remove(callback) != null) { if (!mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) { return false; } } if (!mBluetoothConnectionCallbackExecutorMap.isEmpty()) { return true; return true; } } mBluetoothConnectionCallbackExecutorMap.remove(callback); if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) { // If the callback map is empty, we unregister the service-to-app callback // If the callback map is empty, we unregister the service-to-app callback mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); try { try { if (mService != null) { if (mService == null) { return mService.unregisterBluetoothConnectionCallback( return true; mConnectionCallback, mAttributionSource); } } mService.unregisterBluetoothConnectionCallback( mConnectionCallback, mAttributionSource); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } finally { } finally { mServiceLock.readLock().unlock(); mServiceLock.readLock().unlock(); } } } } return false; return true; } } /** /** Loading