Loading framework/java/android/bluetooth/BluetoothAdapter.java +24 −22 Original line number Diff line number Diff line Loading @@ -1269,7 +1269,7 @@ public final class BluetoothAdapter { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<IBluetooth, Integer> mBluetoothGetStateQuery = private static final IpcDataCache.QueryHandler<IBluetooth, Integer> sBluetoothGetStateQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission Loading @@ -1288,13 +1288,13 @@ public final class BluetoothAdapter { private static final String GET_STATE_API = "BluetoothAdapter_getState"; private final IpcDataCache<IBluetooth, Integer> mBluetoothGetStateCache = new BluetoothCache<>(GET_STATE_API, mBluetoothGetStateQuery); private static final IpcDataCache<IBluetooth, Integer> sBluetoothGetStateCache = new BluetoothCache<>(GET_STATE_API, sBluetoothGetStateQuery); /** @hide */ @RequiresNoPermission public void disableBluetoothGetStateCache() { mBluetoothGetStateCache.disableForCurrentProcess(); sBluetoothGetStateCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -1310,7 +1310,7 @@ public final class BluetoothAdapter { mServiceLock.readLock().lock(); try { if (mService != null) { return mBluetoothGetStateCache.query(mService); return sBluetoothGetStateCache.query(mService); } } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) Loading Loading @@ -2422,7 +2422,7 @@ public final class BluetoothAdapter { } } private final IpcDataCache.QueryHandler<IBluetooth, Boolean> mBluetoothFilteringQuery = private static final IpcDataCache.QueryHandler<IBluetooth, Boolean> sBluetoothFilteringQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission Loading @@ -2439,13 +2439,13 @@ public final class BluetoothAdapter { private static final String FILTERING_API = "BluetoothAdapter_isOffloadedFilteringSupported"; private final IpcDataCache<IBluetooth, Boolean> mBluetoothFilteringCache = new BluetoothCache<>(FILTERING_API, mBluetoothFilteringQuery); private static final IpcDataCache<IBluetooth, Boolean> sBluetoothFilteringCache = new BluetoothCache<>(FILTERING_API, sBluetoothFilteringQuery); /** @hide */ @RequiresNoPermission public void disableIsOffloadedFilteringSupportedCache() { mBluetoothFilteringCache.disableForCurrentProcess(); sBluetoothFilteringCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -2466,7 +2466,7 @@ public final class BluetoothAdapter { } mServiceLock.readLock().lock(); try { if (mService != null) return mBluetoothFilteringCache.query(mService); if (mService != null) return sBluetoothFilteringCache.query(mService); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading Loading @@ -2982,8 +2982,8 @@ public final class BluetoothAdapter { return supportedProfiles; } private final IpcDataCache.QueryHandler<IBluetooth, Integer> mBluetoothGetAdapterConnectionStateQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache.QueryHandler<IBluetooth, Integer> sBluetoothGetAdapterConnectionStateQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission @Override Loading @@ -3002,13 +3002,14 @@ public final class BluetoothAdapter { private static final String GET_CONNECTION_API = "BluetoothAdapter_getConnectionState"; private final IpcDataCache<IBluetooth, Integer> mBluetoothGetAdapterConnectionStateCache = new BluetoothCache<>(GET_CONNECTION_API, mBluetoothGetAdapterConnectionStateQuery); private static final IpcDataCache<IBluetooth, Integer> sBluetoothGetAdapterConnectionStateCache = new BluetoothCache<>(GET_CONNECTION_API, sBluetoothGetAdapterConnectionStateQuery); /** @hide */ @RequiresNoPermission public void disableGetAdapterConnectionStateCache() { mBluetoothGetAdapterConnectionStateCache.disableForCurrentProcess(); sBluetoothGetAdapterConnectionStateCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -3035,7 +3036,7 @@ public final class BluetoothAdapter { } mServiceLock.readLock().lock(); try { if (mService != null) return mBluetoothGetAdapterConnectionStateCache.query(mService); if (mService != null) return sBluetoothGetAdapterConnectionStateCache.query(mService); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading @@ -3048,8 +3049,8 @@ public final class BluetoothAdapter { return STATE_DISCONNECTED; } private final IpcDataCache.QueryHandler<Pair<IBluetooth, Integer>, Integer> mBluetoothProfileQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache.QueryHandler<Pair<IBluetooth, Integer>, Integer> sBluetoothProfileQuery = new IpcDataCache.QueryHandler<>() { @RequiresNoPermission @Override public Integer apply(Pair<IBluetooth, Integer> pairQuery) { Loading @@ -3067,15 +3068,16 @@ public final class BluetoothAdapter { private static final String PROFILE_API = "BluetoothAdapter_getProfileConnectionState"; private final IpcDataCache<Pair<IBluetooth, Integer>, Integer> mGetProfileConnectionStateCache = new BluetoothCache<>(PROFILE_API, mBluetoothProfileQuery); private static final IpcDataCache<Pair<IBluetooth, Integer>, Integer> sGetProfileConnectionStateCache = new BluetoothCache<>(PROFILE_API, sBluetoothProfileQuery); /** * @hide */ @RequiresNoPermission public void disableGetProfileConnectionStateCache() { mGetProfileConnectionStateCache.disableForCurrentProcess(); sGetProfileConnectionStateCache.disableForCurrentProcess(); } /** Loading Loading @@ -3104,7 +3106,7 @@ public final class BluetoothAdapter { mServiceLock.readLock().lock(); try { if (mService != null) { return mGetProfileConnectionStateCache.query(new Pair<>(mService, profile)); return sGetProfileConnectionStateCache.query(new Pair<>(mService, profile)); } } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) Loading framework/java/android/bluetooth/BluetoothDevice.java +16 −10 Original line number Diff line number Diff line Loading @@ -1903,21 +1903,25 @@ public final class BluetoothDevice implements Parcelable, Attributable { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<Pair<IBluetooth, BluetoothDevice>, Integer> mBluetoothBondQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache .QueryHandler<Pair<IBluetooth, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothBondQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresBluetoothConnectPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) @Override public Integer apply(Pair<IBluetooth, BluetoothDevice> pairQuery) { public Integer apply(Pair<IBluetooth, Pair<AttributionSource, BluetoothDevice>> pairQuery) { IBluetooth service = pairQuery.first; AttributionSource source = pairQuery.second.first; BluetoothDevice device = pairQuery.second.second; if (DBG) { log("getConnectionState(" + pairQuery.second.getAnonymizedAddress() + ") uncached"); log("getBondState(" + device.getAnonymizedAddress() + ") uncached"); } try { final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); pairQuery.first.getBondState(pairQuery.second, mAttributionSource, recv); service.getBondState(device, source, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(BOND_NONE); } catch (RemoteException | TimeoutException e) { throw new RuntimeException(e); Loading @@ -1927,12 +1931,13 @@ public final class BluetoothDevice implements Parcelable, Attributable { private static final String GET_BOND_STATE_API = "BluetoothDevice_getBondState"; private final BluetoothCache<Pair<IBluetooth, BluetoothDevice>, Integer> mBluetoothBondCache = new BluetoothCache<>(GET_BOND_STATE_API, mBluetoothBondQuery); private static final BluetoothCache<Pair<IBluetooth, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothBondCache = new BluetoothCache<>(GET_BOND_STATE_API, sBluetoothBondQuery); /** @hide */ public void disableBluetoothGetBondStateCache() { mBluetoothBondCache.disableForCurrentProcess(); sBluetoothBondCache.disableForCurrentProcess(); } /** @hide */ Loading Loading @@ -1961,7 +1966,8 @@ public final class BluetoothDevice implements Parcelable, Attributable { if (DBG) log(Log.getStackTraceString(new Throwable())); } else { try { return mBluetoothBondCache.query(new Pair<>(service, BluetoothDevice.this)); return sBluetoothBondCache.query( new Pair<>(service, new Pair<>(mAttributionSource, BluetoothDevice.this))); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading framework/java/android/bluetooth/BluetoothMap.java +17 −12 Original line number Diff line number Diff line Loading @@ -367,7 +367,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { /** @hide */ public void disableBluetoothGetConnectionStateCache() { mBluetoothConnectionCache.disableForCurrentProcess(); sBluetoothConnectionCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -383,20 +383,23 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<Pair<IBluetoothMap, BluetoothDevice>, Integer> mBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache .QueryHandler<Pair<IBluetoothMap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { @RequiresBluetoothConnectPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) @Override public Integer apply(Pair<IBluetoothMap, BluetoothDevice> pairQuery) { public Integer apply(Pair<IBluetoothMap, Pair<AttributionSource, BluetoothDevice>> pairQuery) { IBluetoothMap service = pairQuery.first; AttributionSource source = pairQuery.second.first; BluetoothDevice device = pairQuery.second.second; if (DBG) { log("getConnectionState(" + pairQuery.second.getAnonymizedAddress() + ") uncached"); log("getConnectionState(" + device.getAnonymizedAddress() + ") uncached"); } final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); try { pairQuery.first .getConnectionState(pairQuery.second, mAttributionSource, recv); service.getConnectionState(device, source, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()) .getValue(BluetoothProfile.STATE_DISCONNECTED); } catch (RemoteException | TimeoutException e) { Loading @@ -407,9 +410,10 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { private static final String GET_CONNECTION_STATE_API = "BluetoothMap_getConnectionState"; private final BluetoothCache<Pair<IBluetoothMap, BluetoothDevice>, Integer> mBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, mBluetoothConnectionQuery); private static final BluetoothCache<Pair<IBluetoothMap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, sBluetoothConnectionQuery); /** * Get connection state of device Loading @@ -427,7 +431,8 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { if (DBG) log(Log.getStackTraceString(new Throwable())); } else if (isEnabled() && isValidDevice(device)) { try { return mBluetoothConnectionCache.query(new Pair<>(service, device)); return sBluetoothConnectionCache.query( new Pair<>(service, new Pair<>(mAttributionSource, device))); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading framework/java/android/bluetooth/BluetoothSap.java +17 −12 Original line number Diff line number Diff line Loading @@ -364,7 +364,7 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { /** @hide */ public void disableBluetoothGetConnectionStateCache() { mBluetoothConnectionCache.disableForCurrentProcess(); sBluetoothConnectionCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -380,20 +380,23 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<Pair<IBluetoothSap, BluetoothDevice>, Integer> mBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache .QueryHandler<Pair<IBluetoothSap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { @RequiresBluetoothConnectPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) @Override public Integer apply(Pair<IBluetoothSap, BluetoothDevice> pairQuery) { public Integer apply(Pair<IBluetoothSap, Pair<AttributionSource, BluetoothDevice>> pairQuery) { IBluetoothSap service = pairQuery.first; AttributionSource source = pairQuery.second.first; BluetoothDevice device = pairQuery.second.second; if (DBG) { log("getConnectionState(" + pairQuery.second.getAnonymizedAddress() + ") uncached"); log("getConnectionState(" + device.getAnonymizedAddress() + ") uncached"); } final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); try { pairQuery.first .getConnectionState(pairQuery.second, mAttributionSource, recv); service.getConnectionState(device, source, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()) .getValue(BluetoothProfile.STATE_DISCONNECTED); } catch (RemoteException | TimeoutException e) { Loading @@ -404,9 +407,10 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { private static final String GET_CONNECTION_STATE_API = "BluetoothSap_getConnectionState"; private final BluetoothCache<Pair<IBluetoothSap, BluetoothDevice>, Integer> mBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, mBluetoothConnectionQuery); private static final BluetoothCache<Pair<IBluetoothSap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, sBluetoothConnectionQuery); /** * Get connection state of device Loading @@ -424,7 +428,8 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { if (DBG) log(Log.getStackTraceString(new Throwable())); } else if (isEnabled() && isValidDevice(device)) { try { return mBluetoothConnectionCache.query(new Pair<>(service, device)); return sBluetoothConnectionCache.query( new Pair<>(service, new Pair<>(mAttributionSource, device))); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +24 −22 Original line number Diff line number Diff line Loading @@ -1269,7 +1269,7 @@ public final class BluetoothAdapter { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<IBluetooth, Integer> mBluetoothGetStateQuery = private static final IpcDataCache.QueryHandler<IBluetooth, Integer> sBluetoothGetStateQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission Loading @@ -1288,13 +1288,13 @@ public final class BluetoothAdapter { private static final String GET_STATE_API = "BluetoothAdapter_getState"; private final IpcDataCache<IBluetooth, Integer> mBluetoothGetStateCache = new BluetoothCache<>(GET_STATE_API, mBluetoothGetStateQuery); private static final IpcDataCache<IBluetooth, Integer> sBluetoothGetStateCache = new BluetoothCache<>(GET_STATE_API, sBluetoothGetStateQuery); /** @hide */ @RequiresNoPermission public void disableBluetoothGetStateCache() { mBluetoothGetStateCache.disableForCurrentProcess(); sBluetoothGetStateCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -1310,7 +1310,7 @@ public final class BluetoothAdapter { mServiceLock.readLock().lock(); try { if (mService != null) { return mBluetoothGetStateCache.query(mService); return sBluetoothGetStateCache.query(mService); } } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) Loading Loading @@ -2422,7 +2422,7 @@ public final class BluetoothAdapter { } } private final IpcDataCache.QueryHandler<IBluetooth, Boolean> mBluetoothFilteringQuery = private static final IpcDataCache.QueryHandler<IBluetooth, Boolean> sBluetoothFilteringQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission Loading @@ -2439,13 +2439,13 @@ public final class BluetoothAdapter { private static final String FILTERING_API = "BluetoothAdapter_isOffloadedFilteringSupported"; private final IpcDataCache<IBluetooth, Boolean> mBluetoothFilteringCache = new BluetoothCache<>(FILTERING_API, mBluetoothFilteringQuery); private static final IpcDataCache<IBluetooth, Boolean> sBluetoothFilteringCache = new BluetoothCache<>(FILTERING_API, sBluetoothFilteringQuery); /** @hide */ @RequiresNoPermission public void disableIsOffloadedFilteringSupportedCache() { mBluetoothFilteringCache.disableForCurrentProcess(); sBluetoothFilteringCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -2466,7 +2466,7 @@ public final class BluetoothAdapter { } mServiceLock.readLock().lock(); try { if (mService != null) return mBluetoothFilteringCache.query(mService); if (mService != null) return sBluetoothFilteringCache.query(mService); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading Loading @@ -2982,8 +2982,8 @@ public final class BluetoothAdapter { return supportedProfiles; } private final IpcDataCache.QueryHandler<IBluetooth, Integer> mBluetoothGetAdapterConnectionStateQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache.QueryHandler<IBluetooth, Integer> sBluetoothGetAdapterConnectionStateQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission @Override Loading @@ -3002,13 +3002,14 @@ public final class BluetoothAdapter { private static final String GET_CONNECTION_API = "BluetoothAdapter_getConnectionState"; private final IpcDataCache<IBluetooth, Integer> mBluetoothGetAdapterConnectionStateCache = new BluetoothCache<>(GET_CONNECTION_API, mBluetoothGetAdapterConnectionStateQuery); private static final IpcDataCache<IBluetooth, Integer> sBluetoothGetAdapterConnectionStateCache = new BluetoothCache<>(GET_CONNECTION_API, sBluetoothGetAdapterConnectionStateQuery); /** @hide */ @RequiresNoPermission public void disableGetAdapterConnectionStateCache() { mBluetoothGetAdapterConnectionStateCache.disableForCurrentProcess(); sBluetoothGetAdapterConnectionStateCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -3035,7 +3036,7 @@ public final class BluetoothAdapter { } mServiceLock.readLock().lock(); try { if (mService != null) return mBluetoothGetAdapterConnectionStateCache.query(mService); if (mService != null) return sBluetoothGetAdapterConnectionStateCache.query(mService); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading @@ -3048,8 +3049,8 @@ public final class BluetoothAdapter { return STATE_DISCONNECTED; } private final IpcDataCache.QueryHandler<Pair<IBluetooth, Integer>, Integer> mBluetoothProfileQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache.QueryHandler<Pair<IBluetooth, Integer>, Integer> sBluetoothProfileQuery = new IpcDataCache.QueryHandler<>() { @RequiresNoPermission @Override public Integer apply(Pair<IBluetooth, Integer> pairQuery) { Loading @@ -3067,15 +3068,16 @@ public final class BluetoothAdapter { private static final String PROFILE_API = "BluetoothAdapter_getProfileConnectionState"; private final IpcDataCache<Pair<IBluetooth, Integer>, Integer> mGetProfileConnectionStateCache = new BluetoothCache<>(PROFILE_API, mBluetoothProfileQuery); private static final IpcDataCache<Pair<IBluetooth, Integer>, Integer> sGetProfileConnectionStateCache = new BluetoothCache<>(PROFILE_API, sBluetoothProfileQuery); /** * @hide */ @RequiresNoPermission public void disableGetProfileConnectionStateCache() { mGetProfileConnectionStateCache.disableForCurrentProcess(); sGetProfileConnectionStateCache.disableForCurrentProcess(); } /** Loading Loading @@ -3104,7 +3106,7 @@ public final class BluetoothAdapter { mServiceLock.readLock().lock(); try { if (mService != null) { return mGetProfileConnectionStateCache.query(new Pair<>(mService, profile)); return sGetProfileConnectionStateCache.query(new Pair<>(mService, profile)); } } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) Loading
framework/java/android/bluetooth/BluetoothDevice.java +16 −10 Original line number Diff line number Diff line Loading @@ -1903,21 +1903,25 @@ public final class BluetoothDevice implements Parcelable, Attributable { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<Pair<IBluetooth, BluetoothDevice>, Integer> mBluetoothBondQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache .QueryHandler<Pair<IBluetooth, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothBondQuery = new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresBluetoothConnectPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) @Override public Integer apply(Pair<IBluetooth, BluetoothDevice> pairQuery) { public Integer apply(Pair<IBluetooth, Pair<AttributionSource, BluetoothDevice>> pairQuery) { IBluetooth service = pairQuery.first; AttributionSource source = pairQuery.second.first; BluetoothDevice device = pairQuery.second.second; if (DBG) { log("getConnectionState(" + pairQuery.second.getAnonymizedAddress() + ") uncached"); log("getBondState(" + device.getAnonymizedAddress() + ") uncached"); } try { final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); pairQuery.first.getBondState(pairQuery.second, mAttributionSource, recv); service.getBondState(device, source, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(BOND_NONE); } catch (RemoteException | TimeoutException e) { throw new RuntimeException(e); Loading @@ -1927,12 +1931,13 @@ public final class BluetoothDevice implements Parcelable, Attributable { private static final String GET_BOND_STATE_API = "BluetoothDevice_getBondState"; private final BluetoothCache<Pair<IBluetooth, BluetoothDevice>, Integer> mBluetoothBondCache = new BluetoothCache<>(GET_BOND_STATE_API, mBluetoothBondQuery); private static final BluetoothCache<Pair<IBluetooth, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothBondCache = new BluetoothCache<>(GET_BOND_STATE_API, sBluetoothBondQuery); /** @hide */ public void disableBluetoothGetBondStateCache() { mBluetoothBondCache.disableForCurrentProcess(); sBluetoothBondCache.disableForCurrentProcess(); } /** @hide */ Loading Loading @@ -1961,7 +1966,8 @@ public final class BluetoothDevice implements Parcelable, Attributable { if (DBG) log(Log.getStackTraceString(new Throwable())); } else { try { return mBluetoothBondCache.query(new Pair<>(service, BluetoothDevice.this)); return sBluetoothBondCache.query( new Pair<>(service, new Pair<>(mAttributionSource, BluetoothDevice.this))); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading
framework/java/android/bluetooth/BluetoothMap.java +17 −12 Original line number Diff line number Diff line Loading @@ -367,7 +367,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { /** @hide */ public void disableBluetoothGetConnectionStateCache() { mBluetoothConnectionCache.disableForCurrentProcess(); sBluetoothConnectionCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -383,20 +383,23 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<Pair<IBluetoothMap, BluetoothDevice>, Integer> mBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache .QueryHandler<Pair<IBluetoothMap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { @RequiresBluetoothConnectPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) @Override public Integer apply(Pair<IBluetoothMap, BluetoothDevice> pairQuery) { public Integer apply(Pair<IBluetoothMap, Pair<AttributionSource, BluetoothDevice>> pairQuery) { IBluetoothMap service = pairQuery.first; AttributionSource source = pairQuery.second.first; BluetoothDevice device = pairQuery.second.second; if (DBG) { log("getConnectionState(" + pairQuery.second.getAnonymizedAddress() + ") uncached"); log("getConnectionState(" + device.getAnonymizedAddress() + ") uncached"); } final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); try { pairQuery.first .getConnectionState(pairQuery.second, mAttributionSource, recv); service.getConnectionState(device, source, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()) .getValue(BluetoothProfile.STATE_DISCONNECTED); } catch (RemoteException | TimeoutException e) { Loading @@ -407,9 +410,10 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { private static final String GET_CONNECTION_STATE_API = "BluetoothMap_getConnectionState"; private final BluetoothCache<Pair<IBluetoothMap, BluetoothDevice>, Integer> mBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, mBluetoothConnectionQuery); private static final BluetoothCache<Pair<IBluetoothMap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, sBluetoothConnectionQuery); /** * Get connection state of device Loading @@ -427,7 +431,8 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable { if (DBG) log(Log.getStackTraceString(new Throwable())); } else if (isEnabled() && isValidDevice(device)) { try { return mBluetoothConnectionCache.query(new Pair<>(service, device)); return sBluetoothConnectionCache.query( new Pair<>(service, new Pair<>(mAttributionSource, device))); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading
framework/java/android/bluetooth/BluetoothSap.java +17 −12 Original line number Diff line number Diff line Loading @@ -364,7 +364,7 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { /** @hide */ public void disableBluetoothGetConnectionStateCache() { mBluetoothConnectionCache.disableForCurrentProcess(); sBluetoothConnectionCache.disableForCurrentProcess(); } /** @hide */ Loading @@ -380,20 +380,23 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } private final IpcDataCache.QueryHandler<Pair<IBluetoothSap, BluetoothDevice>, Integer> mBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { private static final IpcDataCache .QueryHandler<Pair<IBluetoothSap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionQuery = new IpcDataCache.QueryHandler<>() { @RequiresBluetoothConnectPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) @Override public Integer apply(Pair<IBluetoothSap, BluetoothDevice> pairQuery) { public Integer apply(Pair<IBluetoothSap, Pair<AttributionSource, BluetoothDevice>> pairQuery) { IBluetoothSap service = pairQuery.first; AttributionSource source = pairQuery.second.first; BluetoothDevice device = pairQuery.second.second; if (DBG) { log("getConnectionState(" + pairQuery.second.getAnonymizedAddress() + ") uncached"); log("getConnectionState(" + device.getAnonymizedAddress() + ") uncached"); } final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); try { pairQuery.first .getConnectionState(pairQuery.second, mAttributionSource, recv); service.getConnectionState(device, source, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()) .getValue(BluetoothProfile.STATE_DISCONNECTED); } catch (RemoteException | TimeoutException e) { Loading @@ -404,9 +407,10 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { private static final String GET_CONNECTION_STATE_API = "BluetoothSap_getConnectionState"; private final BluetoothCache<Pair<IBluetoothSap, BluetoothDevice>, Integer> mBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, mBluetoothConnectionQuery); private static final BluetoothCache<Pair<IBluetoothSap, Pair<AttributionSource, BluetoothDevice>>, Integer> sBluetoothConnectionCache = new BluetoothCache<>(GET_CONNECTION_STATE_API, sBluetoothConnectionQuery); /** * Get connection state of device Loading @@ -424,7 +428,8 @@ public final class BluetoothSap implements BluetoothProfile, AutoCloseable { if (DBG) log(Log.getStackTraceString(new Throwable())); } else if (isEnabled() && isValidDevice(device)) { try { return mBluetoothConnectionCache.query(new Pair<>(service, device)); return sBluetoothConnectionCache.query( new Pair<>(service, new Pair<>(mAttributionSource, device))); } catch (RuntimeException e) { if (!(e.getCause() instanceof TimeoutException) && !(e.getCause() instanceof RemoteException)) { Loading