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

Commit ebfb7779 authored by Lee Shombert's avatar Lee Shombert Committed by Android (Google) Code Review
Browse files

Merge "Fix bluetooth binder cache invalidation" into rvc-dev

parents e2543fd2 9c4a156f
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -182,12 +182,11 @@ class AdapterProperties {
    AdapterProperties(AdapterService service) {
        mService = service;
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        invalidateIsOffloadedFilteringSupportedCache();
        invalidateBluetoothCaches();
    }

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

        // Get default max connected audio devices from config.xml in frameworks/base/core
@@ -225,18 +224,19 @@ class AdapterProperties {
        filter.addAction(BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
        mService.registerReceiver(mReceiver, filter);
        mReceiverRegistered = true;
        invalidateBluetoothCaches();
    }

    public void cleanup() {
        mRemoteDevices = null;
        mProfileConnectionState.clear();
        invalidateGetProfileConnectionStateCache();
        if (mReceiverRegistered) {
            mService.unregisterReceiver(mReceiver);
            mReceiverRegistered = false;
        }
        mService = null;
        mBondedDevices.clear();
        invalidateBluetoothCaches();
    }

    private static void invalidateGetProfileConnectionStateCache() {
@@ -245,6 +245,14 @@ class AdapterProperties {
    private static void invalidateIsOffloadedFilteringSupportedCache() {
        BluetoothAdapter.invalidateIsOffloadedFilteringSupportedCache();
    }
    private static void invalidateGetBondStateCache() {
        BluetoothDevice.invalidateBluetoothGetBondStateCache();
    }
    private static void invalidateBluetoothCaches() {
        invalidateGetProfileConnectionStateCache();
        invalidateIsOffloadedFilteringSupportedCache();
        invalidateGetBondStateCache();
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
@@ -548,7 +556,7 @@ class AdapterProperties {
                    debugLog("Failed to remove device: " + device);
                }
            }
            BluetoothDevice.invalidateBluetoothGetBondStateCache();
            invalidateGetBondStateCache();
        } catch (Exception ee) {
            Log.w(TAG, "onBondStateChanged: Exception ", ee);
        }
+1 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.PropertyInvalidatedCache;
import android.app.Service;
import android.app.admin.DevicePolicyManager;
import android.bluetooth.BluetoothActivityEnergyInfo;
@@ -790,7 +791,6 @@ public class AdapterService extends Service {
    }

    private void invalidateBluetoothCaches() {
        BluetoothAdapter.invalidateGetProfileConnectionStateCache();
        BluetoothAdapter.invalidateGetProfileConnectionStateCache();
        BluetoothAdapter.invalidateIsOffloadedFilteringSupportedCache();
        BluetoothDevice.invalidateBluetoothGetBondStateCache();