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

Commit 4aa66346 authored by Lee Shombert's avatar Lee Shombert Committed by Automerger Merge Worker
Browse files

Merge "Fix bluetooth binder cache invalidation" into rvc-dev am: ebfb7779 am: 9d6c6fd0

Change-Id: I3baa8e7820f6f402fc4fdee878d45398cdf21147
parents 2e039075 9d6c6fd0
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -182,12 +182,11 @@ class AdapterProperties {
    AdapterProperties(AdapterService service) {
    AdapterProperties(AdapterService service) {
        mService = service;
        mService = service;
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        invalidateIsOffloadedFilteringSupportedCache();
        invalidateBluetoothCaches();
    }
    }


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


        // Get default max connected audio devices from config.xml in frameworks/base/core
        // 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);
        filter.addAction(BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
        mService.registerReceiver(mReceiver, filter);
        mService.registerReceiver(mReceiver, filter);
        mReceiverRegistered = true;
        mReceiverRegistered = true;
        invalidateBluetoothCaches();
    }
    }


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


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


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


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