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

Commit efdd4383 authored by William Escande's avatar William Escande
Browse files

GetState use system cache instead of module cache

Bug: 362569584
Test: m . + install on device and observe state change
Flag: com.android.bluetooth.flags.get_state_from_system_server
Change-Id: Ia046052613e4f725cff289b14aa9335d6e7f513b
parent 8c3a57b9
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -1514,7 +1514,12 @@ public final class BluetoothAdapter {
            new BluetoothCache<>(GET_STATE_API, sBluetoothGetStateQuery);
            new BluetoothCache<>(GET_STATE_API, sBluetoothGetStateQuery);


    private static final IpcDataCache<IBluetoothManager, Integer> sBluetoothGetSystemStateCache =
    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 */
    /** @hide */
    @RequiresNoPermission
    @RequiresNoPermission
+1 −0
Original line number Original line 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)")
    @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);
    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";
    const String GET_SYSTEM_STATE_API = "BluetoothAdapter_getSystemState";


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