From db6f3e7a902e011af4fbb4434d353dc59b8e2c19 Mon Sep 17 00:00:00 2001 From: Lee Shombert Date: Fri, 4 Mar 2022 07:37:36 -0800 Subject: Convert the Bluetooth module to os/IpcDataCache Bug: 214455273 Tag: #refactor Convert all references to PropertyInvalidatedCache into references to os/IpcDataCache. IpcDataCache has the necessary system APIs for mainline modules. Any system APIs in PropertyInvalidatedCache will be deleted. Manual testing was done by pairing a phone with a headset and verifying that the caches were in use via 'dumpsys cacheinfo'. Test: presubmit Change-Id: Ia9ebc89ba6fc8d1c3757dcb141b37a59a0b3f713 --- .../java/android/bluetooth/BluetoothAdapter.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java') diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 15f0f923c1..8eeb38d2b7 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -32,7 +32,6 @@ import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.app.PendingIntent; -import android.app.PropertyInvalidatedCache; import android.bluetooth.BluetoothDevice.AddressType; import android.bluetooth.BluetoothDevice.Transport; import android.bluetooth.BluetoothProfile.ConnectionPolicy; @@ -57,6 +56,7 @@ import android.os.Binder; import android.os.BluetoothServiceManager; import android.os.Build; import android.os.IBinder; +import android.os.IpcDataCache; import android.os.ParcelUuid; import android.os.RemoteException; import android.os.ResultReceiver; @@ -1125,13 +1125,13 @@ public final class BluetoothAdapter { } /** - * There are several instances of PropertyInvalidatedCache used in this class. + * There are several instances of IpcDataCache used in this class. * BluetoothCache wraps up the common code. All caches are created with a maximum of * eight entries, and the key is in the bluetooth module. The name is set to the api. */ - private static class BluetoothCache extends PropertyInvalidatedCache { - BluetoothCache(String api, PropertyInvalidatedCache.QueryHandler query) { - super(8, PropertyInvalidatedCache.MODULE_BLUETOOTH, api, api, query); + private static class BluetoothCache extends IpcDataCache { + BluetoothCache(String api, IpcDataCache.QueryHandler query) { + super(8, IpcDataCache.MODULE_BLUETOOTH, api, api, query); }}; /** @@ -1139,7 +1139,7 @@ public final class BluetoothAdapter { * enforces the bluetooth module. */ private static void invalidateCache(@NonNull String api) { - PropertyInvalidatedCache.invalidateCache(PropertyInvalidatedCache.MODULE_BLUETOOTH, api); + IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, api); } /** @@ -1147,8 +1147,8 @@ public final class BluetoothAdapter { */ private static final String GET_STATE_API = "getState"; - private final PropertyInvalidatedCache.QueryHandler mBluetoothGetStateQuery = - new PropertyInvalidatedCache.QueryHandler<>() { + private final IpcDataCache.QueryHandler mBluetoothGetStateQuery = + new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission @AdapterState @@ -1174,7 +1174,7 @@ public final class BluetoothAdapter { return state; }}; - private final PropertyInvalidatedCache mBluetoothGetStateCache = + private final IpcDataCache mBluetoothGetStateCache = new BluetoothCache(GET_STATE_API, mBluetoothGetStateQuery); /** @hide */ @@ -2267,8 +2267,8 @@ public final class BluetoothAdapter { } } - private final PropertyInvalidatedCache.QueryHandler mBluetoothFilteringQuery = - new PropertyInvalidatedCache.QueryHandler<>() { + private final IpcDataCache.QueryHandler mBluetoothFilteringQuery = + new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission @Override @@ -2290,7 +2290,7 @@ public final class BluetoothAdapter { private static final String FILTERING_API = "isOffloadedFilteringSupported"; - private final PropertyInvalidatedCache mBluetoothFilteringCache = + private final IpcDataCache mBluetoothFilteringCache = new BluetoothCache(FILTERING_API, mBluetoothFilteringQuery); /** @hide */ @@ -2810,8 +2810,8 @@ public final class BluetoothAdapter { return supportedProfiles; } - private final PropertyInvalidatedCache.QueryHandler mBluetoothGetAdapterQuery = - new PropertyInvalidatedCache.QueryHandler<>() { + private final IpcDataCache.QueryHandler mBluetoothGetAdapterQuery = + new IpcDataCache.QueryHandler<>() { @RequiresLegacyBluetoothPermission @RequiresNoPermission @Override @@ -2836,7 +2836,7 @@ public final class BluetoothAdapter { }}; private static final String GET_CONNECTION_API = "getAdapterConnectionState"; - private final PropertyInvalidatedCache + private final IpcDataCache mBluetoothGetAdapterConnectionStateCache = new BluetoothCache(GET_CONNECTION_API, mBluetoothGetAdapterQuery); @@ -2872,8 +2872,8 @@ public final class BluetoothAdapter { return mBluetoothGetAdapterConnectionStateCache.query(null); } - private final PropertyInvalidatedCache.QueryHandler mBluetoothProfileQuery = - new PropertyInvalidatedCache.QueryHandler<>() { + private final IpcDataCache.QueryHandler mBluetoothProfileQuery = + new IpcDataCache.QueryHandler<>() { @RequiresNoPermission @Override public Integer apply(Integer query) { @@ -2896,7 +2896,7 @@ public final class BluetoothAdapter { }}; private static final String PROFILE_API = "getProfileConnectionState"; - private final PropertyInvalidatedCache + private final IpcDataCache mGetProfileConnectionStateCache = new BluetoothCache(PROFILE_API, mBluetoothProfileQuery); -- cgit v1.2.3