Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b733115 authored by Lee Shombert's avatar Lee Shombert
Browse files

Binder caches for Bluetooth

* A cache for isOffloadedFilteringSupported().

* A cache for getProfileConnectionState().

Bug: 140788621

Test: A special build that puts the PropertyInvalidatedCache in
verification mode was loaded on the device.  Then one iteration of MPTS
was executed.  No cache inconsistencies were found and no SELinux
violations (associated with the binder cache) were found.  The number of
cache misses was approximately 15% of the total binder calls.  A second
test was run in which bluetooth headphones were connected and
disconnected.  Then bluetooth itself was disabled and then enabled.  The
caches were invalidated as expected and no errors were uncovered.

Change-Id: I6b939b37663b81894dd1c23a33758910580159fe
parent cedec5d3
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -182,10 +182,12 @@ class AdapterProperties {
    AdapterProperties(AdapterService service) {
        mService = service;
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        invalidateIsOffloadedFilteringSupportedCache();
    }

    public void init(RemoteDevices remoteDevices) {
        mProfileConnectionState.clear();
        invalidateGetProfileConnectionStateCache();
        mRemoteDevices = remoteDevices;

        // Get default max connected audio devices from config.xml in frameworks/base/core
@@ -228,6 +230,7 @@ class AdapterProperties {
    public void cleanup() {
        mRemoteDevices = null;
        mProfileConnectionState.clear();
        invalidateGetProfileConnectionStateCache();
        if (mReceiverRegistered) {
            mService.unregisterReceiver(mReceiver);
            mReceiverRegistered = false;
@@ -236,6 +239,13 @@ class AdapterProperties {
        mBondedDevices.clear();
    }

    private static void invalidateGetProfileConnectionStateCache() {
        BluetoothAdapter.invalidateGetProfileConnectionStateCache();
    }
    private static void invalidateIsOffloadedFilteringSupportedCache() {
        BluetoothAdapter.invalidateIsOffloadedFilteringSupportedCache();
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException();
@@ -764,6 +774,7 @@ class AdapterProperties {

        if (update) {
            mProfileConnectionState.put(profile, new Pair<Integer, Integer>(newHashState, numDev));
            invalidateGetProfileConnectionStateCache();
        }
    }

@@ -889,6 +900,7 @@ class AdapterProperties {
                + " mIsLeExtendedAdvertisingSupported = " + mIsLeExtendedAdvertisingSupported
                + " mIsLePeriodicAdvertisingSupported = " + mIsLePeriodicAdvertisingSupported
                + " mLeMaximumAdvertisingDataLength = " + mLeMaximumAdvertisingDataLength);
        invalidateIsOffloadedFilteringSupportedCache();
    }

    void onBluetoothReady() {
@@ -899,6 +911,7 @@ class AdapterProperties {
            // Reset adapter and profile connection states
            setConnectionState(BluetoothAdapter.STATE_DISCONNECTED);
            mProfileConnectionState.clear();
            invalidateGetProfileConnectionStateCache();
            mProfilesConnected = 0;
            mProfilesConnecting = 0;
            mProfilesDisconnecting = 0;
+11 −0
Original line number Diff line number Diff line
@@ -697,6 +697,9 @@ public class AdapterService extends Service {
            return;
        }

        BluetoothAdapter.invalidateGetProfileConnectionStateCache();
        BluetoothAdapter.invalidateIsOffloadedFilteringSupportedCache();

        clearAdapterService(this);

        mCleaningUp = true;
@@ -1380,6 +1383,10 @@ public class AdapterService extends Service {
            return service.mAdapterProperties.getConnectionState();
        }

        /**
         * This method has an associated binder cache.  The invalidation
         * methods must be changed if the logic behind this method changes.
         */
        @Override
        public int getProfileConnectionState(int profile) {
            AdapterService service = getService();
@@ -1924,6 +1931,10 @@ public class AdapterService extends Service {
            return val >= MIN_ADVT_INSTANCES_FOR_MA;
        }

        /**
         * This method has an associated binder cache.  The invalidation
         * methods must be changed if the logic behind this method changes.
         */
        @Override
        public boolean isOffloadedFilteringSupported() {
            AdapterService service = getService();