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

Commit ce79b9f4 authored by Lee Shombert's avatar Lee Shombert
Browse files

Binder cache for Bluetooth getBondState()

Bug: 140788621

This includes a change to AdapterService that invalidates the caches after
cleanup has been recorded, and after the bluetooth service starts.  The bug
occurred when switching users.

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
10% of the total binder calls.  Then the phone was cycled through bluetooth
pairing and unpairing events.

Change-Id: I8f3bdabb2f034f5070688141938941ff1cfdb23a
parent 4e358c66
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -548,6 +548,7 @@ class AdapterProperties {
                    debugLog("Failed to remove device: " + device);
                }
            }
            BluetoothDevice.invalidateBluetoothGetBondStateCache();
        } catch (Exception ee) {
            Log.w(TAG, "onBondStateChanged: Exception ", ee);
        }
+11 −3
Original line number Diff line number Diff line
@@ -475,6 +475,8 @@ public class AdapterService extends Service {

        setAdapterService(this);

        invalidateBluetoothCaches();

        // First call to getSharedPreferences will result in a file read into
        // memory cache. Call it here asynchronously to avoid potential ANR
        // in the future
@@ -697,12 +699,10 @@ public class AdapterService extends Service {
            return;
        }

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

        clearAdapterService(this);

        mCleaningUp = true;
        invalidateBluetoothCaches();

        unregisterReceiver(mAlarmBroadcastReceiver);

@@ -788,6 +788,14 @@ public class AdapterService extends Service {
        }
    }

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

    private void setProfileServiceState(Class service, int state) {
        Intent intent = new Intent(this, service);
        intent.putExtra(EXTRA_ACTION, ACTION_SERVICE_STATE_CHANGED);