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

Commit 7ac46d63 authored by Vlad Popa's avatar Vlad Popa Committed by Eric Laurent
Browse files

Refactor the SADeviceState to AdiDeviceState

The idea is to have a device state catalog for all the known devices.
Also refactored the name of the Settings.Secure key entry for
persistence. The current code will check the legacy key first, erase
it and update the new key.

Test: atest SpatializerHelperTest & AudioDeviceBrokerTest
Bug: 278265907
Bug: 285588444
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:61b2a9219e0b7c8899068d1faa33da3bdc0769b4)
Merged-In: Idabcc84cb0f5f6f88ba5aebc435511ab95016ef3
Change-Id: Idabcc84cb0f5f6f88ba5aebc435511ab95016ef3
parent e56faa0b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -701,6 +701,7 @@ public class SettingsBackupTest {
                 Settings.Secure.ASSIST_SCREENSHOT_ENABLED,
                 Settings.Secure.ASSIST_STRUCTURE_ENABLED,
                 Settings.Secure.ATTENTIVE_TIMEOUT,
                 Settings.Secure.AUDIO_DEVICE_INVENTORY, // setting not controllable by user
                 Settings.Secure.AUTOFILL_FEATURE_FIELD_CLASSIFICATION,
                 Settings.Secure.AUTOFILL_USER_DATA_MAX_CATEGORY_COUNT,
                 Settings.Secure.AUTOFILL_USER_DATA_MAX_FIELD_CLASSIFICATION_IDS_SIZE,
+4 −1
Original line number Diff line number Diff line
@@ -90,8 +90,10 @@ public class AudioDeviceInventory {
    private static final String mMetricsId = "audio.device.";

    private final Object mDeviceInventoryLock = new Object();
    @GuardedBy("mDeviceCatalogLock")
    @GuardedBy("mDeviceInventoryLock")
    private final ArrayList<AdiDeviceState> mDeviceInventory = new ArrayList<>(0);


    List<AdiDeviceState> getImmutableDeviceInventory() {
        synchronized (mDeviceInventoryLock) {
            return List.copyOf(mDeviceInventory);
@@ -107,6 +109,7 @@ public class AudioDeviceInventory {
    AdiDeviceState findDeviceStateForAudioDeviceAttributes(AudioDeviceAttributes ada,
            int canonicalDeviceType) {
        final boolean isWireless = isBluetoothDevice(ada.getInternalType());

        synchronized (mDeviceInventoryLock) {
            for (AdiDeviceState deviceSetting : mDeviceInventory) {
                if (deviceSetting.getDeviceType() == canonicalDeviceType