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

Commit e83f00ef authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "GetState use system cache instead of module cache" into main

parents 1ccbb4f8 efdd4383
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1514,7 +1514,12 @@ public final class BluetoothAdapter {
            new BluetoothCache<>(GET_STATE_API, sBluetoothGetStateQuery);

    private static final IpcDataCache<IBluetoothManager, Integer> sBluetoothGetSystemStateCache =
            new BluetoothCache<>(GET_SYSTEM_STATE_API, sBluetoothGetSystemStateQuery);
            new IpcDataCache<>(
                    8,
                    IBluetoothManager.IPC_CACHE_MODULE_SYSTEM,
                    GET_SYSTEM_STATE_API,
                    GET_SYSTEM_STATE_API,
                    sBluetoothGetSystemStateQuery);

    /** @hide */
    @RequiresNoPermission
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ interface IBluetoothManager
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED}, conditional=true)")
    boolean disable(in AttributionSource attributionSource, boolean persist);

    const String IPC_CACHE_MODULE_SYSTEM = "system_server"; // See IpcDataCache.MODULE_SYSTEM
    const String GET_SYSTEM_STATE_API = "BluetoothAdapter_getSystemState";

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.bluetooth
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothAdapter.STATE_OFF
import android.bluetooth.IBluetoothManager.GET_SYSTEM_STATE_API
import android.bluetooth.IBluetoothManager.IPC_CACHE_MODULE_SYSTEM
import android.os.IpcDataCache
import com.android.bluetooth.flags.Flags
import kotlin.time.Duration
@@ -40,7 +41,7 @@ class BluetoothAdapterState {
    fun set(s: Int) = runBlocking {
        _uiState.emit(s)
        if (Flags.getStateFromSystemServer()) {
            IpcDataCache.invalidateCache(IpcDataCache.MODULE_BLUETOOTH, GET_SYSTEM_STATE_API)
            IpcDataCache.invalidateCache(IPC_CACHE_MODULE_SYSTEM, GET_SYSTEM_STATE_API)
        }
    }