Loading media/java/android/media/AudioDeviceAttributes.java +1 −25 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public final class AudioDeviceAttributes implements Parcelable { /** * The unique address of the device. Some devices don't have addresses, only an empty string. */ private @NonNull String mAddress; private final @NonNull String mAddress; /** * The non-unique name of the device. Some devices don't have names, only an empty string. * Should not be used as a unique identifier for a device. Loading Loading @@ -186,21 +186,6 @@ public final class AudioDeviceAttributes implements Parcelable { mAudioDescriptors = new ArrayList<>(); } /** * @hide * Copy Constructor. * @param ada the copied AudioDeviceAttributes */ public AudioDeviceAttributes(AudioDeviceAttributes ada) { mRole = ada.getRole(); mType = ada.getType(); mAddress = ada.getAddress(); mName = ada.getName(); mNativeType = ada.getInternalType(); mAudioProfiles = ada.getAudioProfiles(); mAudioDescriptors = ada.getAudioDescriptors(); } /** * @hide * Returns the role of a device Loading Loading @@ -231,15 +216,6 @@ public final class AudioDeviceAttributes implements Parcelable { return mAddress; } /** * @hide * Sets the device address. Only used by audio service. */ public void setAddress(@NonNull String address) { Objects.requireNonNull(address); mAddress = address; } /** * @hide * Returns the name of the audio device, or an empty string for devices without one Loading services/core/java/com/android/server/audio/AdiDeviceState.java +1 −10 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.media.AudioDeviceAttributes; import android.media.AudioDeviceInfo; import android.text.TextUtils; import android.util.Log; import android.util.Pair; import java.util.Objects; Loading @@ -44,8 +43,6 @@ import java.util.Objects; private final int mInternalDeviceType; @NonNull private final String mDeviceAddress; /** Unique device id from internal device type and address. */ private final Pair<Integer, String> mDeviceId; private boolean mSAEnabled; private boolean mHasHeadTracker = false; private boolean mHeadTrackerEnabled; Loading @@ -71,11 +68,6 @@ import java.util.Objects; } mDeviceAddress = isBluetoothDevice(mInternalDeviceType) ? Objects.requireNonNull( address) : ""; mDeviceId = new Pair<>(mInternalDeviceType, mDeviceAddress); } public Pair<Integer, String> getDeviceId() { return mDeviceId; } @AudioDeviceInfo.AudioDeviceType Loading Loading @@ -146,8 +138,7 @@ import java.util.Objects; @Override public String toString() { return "type: " + mDeviceType + " internal type: 0x" + Integer.toHexString(mInternalDeviceType) return "type: " + mDeviceType + "internal type: " + mInternalDeviceType + " addr: " + mDeviceAddress + " enabled: " + mSAEnabled + " HT: " + mHasHeadTracker + " HTenabled: " + mHeadTrackerEnabled; } Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +6 −11 Original line number Diff line number Diff line Loading @@ -1153,8 +1153,8 @@ public class AudioDeviceBroker { } /*package*/ void registerStrategyPreferredDevicesDispatcher( @NonNull IStrategyPreferredDevicesDispatcher dispatcher, boolean isPrivileged) { mDeviceInventory.registerStrategyPreferredDevicesDispatcher(dispatcher, isPrivileged); @NonNull IStrategyPreferredDevicesDispatcher dispatcher) { mDeviceInventory.registerStrategyPreferredDevicesDispatcher(dispatcher); } /*package*/ void unregisterStrategyPreferredDevicesDispatcher( Loading @@ -1163,8 +1163,8 @@ public class AudioDeviceBroker { } /*package*/ void registerStrategyNonDefaultDevicesDispatcher( @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher, boolean isPrivileged) { mDeviceInventory.registerStrategyNonDefaultDevicesDispatcher(dispatcher, isPrivileged); @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher) { mDeviceInventory.registerStrategyNonDefaultDevicesDispatcher(dispatcher); } /*package*/ void unregisterStrategyNonDefaultDevicesDispatcher( Loading @@ -1182,8 +1182,8 @@ public class AudioDeviceBroker { } /*package*/ void registerCapturePresetDevicesRoleDispatcher( @NonNull ICapturePresetDevicesRoleDispatcher dispatcher, boolean isPrivileged) { mDeviceInventory.registerCapturePresetDevicesRoleDispatcher(dispatcher, isPrivileged); @NonNull ICapturePresetDevicesRoleDispatcher dispatcher) { mDeviceInventory.registerCapturePresetDevicesRoleDispatcher(dispatcher); } /*package*/ void unregisterCapturePresetDevicesRoleDispatcher( Loading @@ -1191,11 +1191,6 @@ public class AudioDeviceBroker { mDeviceInventory.unregisterCapturePresetDevicesRoleDispatcher(dispatcher); } /* package */ List<AudioDeviceAttributes> anonymizeAudioDeviceAttributesListUnchecked( List<AudioDeviceAttributes> devices) { return mAudioService.anonymizeAudioDeviceAttributesListUnchecked(devices); } /*package*/ void registerCommunicationDeviceDispatcher( @NonNull ICommunicationDeviceDispatcher dispatcher) { mCommDevDispatchers.register(dispatcher); Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +28 −72 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import com.google.android.collect.Sets; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; Loading Loading @@ -92,59 +91,31 @@ public class AudioDeviceInventory { private final Object mDeviceInventoryLock = new Object(); @GuardedBy("mDeviceInventoryLock") private final HashMap<Pair<Integer, String>, AdiDeviceState> mDeviceInventory = new HashMap<>(); private final ArrayList<AdiDeviceState> mDeviceInventory = new ArrayList<>(0); List<AdiDeviceState> getImmutableDeviceInventory() { synchronized (mDeviceInventoryLock) { return new ArrayList<AdiDeviceState>(mDeviceInventory.values()); return List.copyOf(mDeviceInventory); } } void addDeviceStateToInventory(AdiDeviceState deviceState) { synchronized (mDeviceInventoryLock) { mDeviceInventory.put(deviceState.getDeviceId(), deviceState); } } /** * Adds a new entry in mDeviceInventory if the AudioDeviceAttributes passed is an sink * Bluetooth device and no corresponding entry already exists. * @param ada the device to add if needed */ void addAudioDeviceInInventoryIfNeeded(AudioDeviceAttributes ada) { if (!AudioSystem.isBluetoothOutDevice(ada.getInternalType())) { return; } synchronized (mDeviceInventoryLock) { if (findDeviceStateForAudioDeviceAttributes(ada, ada.getType()) != null) { return; mDeviceInventory.add(deviceState); } AdiDeviceState ads = new AdiDeviceState( ada.getType(), ada.getInternalType(), ada.getAddress()); mDeviceInventory.put(ads.getDeviceId(), ads); } mDeviceBroker.persistAudioDeviceSettings(); } /** * Finds the device state that matches the passed {@link AudioDeviceAttributes} and device * type. Note: currently this method only returns a valid device for A2DP and BLE devices. * * @param ada attributes of device to match * @param canonicalDeviceType external device type to match * @return the found {@link AdiDeviceState} matching a cached A2DP or BLE device or * {@code null} otherwise. */ @Nullable AdiDeviceState findDeviceStateForAudioDeviceAttributes(AudioDeviceAttributes ada, int canonicalDeviceType) { final boolean isWireless = isBluetoothDevice(ada.getInternalType()); synchronized (mDeviceInventoryLock) { for (AdiDeviceState deviceState : mDeviceInventory.values()) { if (deviceState.getDeviceType() == canonicalDeviceType for (AdiDeviceState deviceSetting : mDeviceInventory) { if (deviceSetting.getDeviceType() == canonicalDeviceType && (!isWireless || ada.getAddress().equals( deviceState.getDeviceAddress()))) { return deviceState; deviceSetting.getDeviceAddress()))) { return deviceSetting; } } } Loading Loading @@ -416,7 +387,7 @@ public class AudioDeviceInventory { + " role:" + key.second + " devices:" + devices); }); pw.println("\ndevices:\n"); synchronized (mDeviceInventoryLock) { for (AdiDeviceState device : mDeviceInventory.values()) { for (AdiDeviceState device : mDeviceInventory) { pw.println("\t" + device + "\n"); } } Loading Loading @@ -963,8 +934,8 @@ public class AudioDeviceInventory { /*package*/ void registerStrategyPreferredDevicesDispatcher( @NonNull IStrategyPreferredDevicesDispatcher dispatcher, boolean isPrivileged) { mPrefDevDispatchers.register(dispatcher, isPrivileged); @NonNull IStrategyPreferredDevicesDispatcher dispatcher) { mPrefDevDispatchers.register(dispatcher); } /*package*/ void unregisterStrategyPreferredDevicesDispatcher( Loading @@ -973,8 +944,8 @@ public class AudioDeviceInventory { } /*package*/ void registerStrategyNonDefaultDevicesDispatcher( @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher, boolean isPrivileged) { mNonDefDevDispatchers.register(dispatcher, isPrivileged); @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher) { mNonDefDevDispatchers.register(dispatcher); } /*package*/ void unregisterStrategyNonDefaultDevicesDispatcher( Loading Loading @@ -1055,8 +1026,8 @@ public class AudioDeviceInventory { } /*package*/ void registerCapturePresetDevicesRoleDispatcher( @NonNull ICapturePresetDevicesRoleDispatcher dispatcher, boolean isPrivileged) { mDevRoleCapturePresetDispatchers.register(dispatcher, isPrivileged); @NonNull ICapturePresetDevicesRoleDispatcher dispatcher) { mDevRoleCapturePresetDispatchers.register(dispatcher); } /*package*/ void unregisterCapturePresetDevicesRoleDispatcher( Loading Loading @@ -1383,8 +1354,6 @@ public class AudioDeviceInventory { updateBluetoothPreferredModes_l(connect ? btDevice : null /*connectedDevice*/); if (!connect) { purgeDevicesRoles_l(); } else { addAudioDeviceInInventoryIfNeeded(attributes); } } mmi.set(MediaMetrics.Property.STATE, MediaMetrics.Value.CONNECTED).record(); Loading Loading @@ -1651,7 +1620,6 @@ public class AudioDeviceInventory { setCurrentAudioRouteNameIfPossible(name, true /*fromA2dp*/); updateBluetoothPreferredModes_l(btInfo.mDevice /*connectedDevice*/); addAudioDeviceInInventoryIfNeeded(ada); } static final int[] CAPTURE_PRESETS = new int[] {AudioSource.MIC, AudioSource.CAMCORDER, Loading Loading @@ -1951,9 +1919,9 @@ public class AudioDeviceInventory { final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID); mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, streamType); AudioDeviceAttributes ada = new AudioDeviceAttributes( AudioSystem.DEVICE_OUT_HEARING_AID, address, name); mAudioSystem.setDeviceConnectionState(ada, mAudioSystem.setDeviceConnectionState(new AudioDeviceAttributes( AudioSystem.DEVICE_OUT_HEARING_AID, address, name), AudioSystem.DEVICE_STATE_AVAILABLE, AudioSystem.AUDIO_FORMAT_DEFAULT); mConnectedDevices.put( Loading @@ -1963,7 +1931,6 @@ public class AudioDeviceInventory { mDeviceBroker.postApplyVolumeOnDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID, "makeHearingAidDeviceAvailable"); setCurrentAudioRouteNameIfPossible(name, false /*fromA2dp*/); addAudioDeviceInInventoryIfNeeded(ada); new MediaMetrics.Item(mMetricsId + "makeHearingAidDeviceAvailable") .set(MediaMetrics.Property.ADDRESS, address != null ? address : "") .set(MediaMetrics.Property.DEVICE, Loading Loading @@ -2066,7 +2033,6 @@ public class AudioDeviceInventory { sensorUuid)); mDeviceBroker.postAccessoryPlugMediaUnmute(device); setCurrentAudioRouteNameIfPossible(name, /*fromA2dp=*/false); addAudioDeviceInInventoryIfNeeded(ada); } if (streamType == AudioSystem.STREAM_DEFAULT) { Loading Loading @@ -2397,9 +2363,6 @@ public class AudioDeviceInventory { final int nbDispatchers = mPrefDevDispatchers.beginBroadcast(); for (int i = 0; i < nbDispatchers; i++) { try { if (!((Boolean) mPrefDevDispatchers.getBroadcastCookie(i))) { devices = mDeviceBroker.anonymizeAudioDeviceAttributesListUnchecked(devices); } mPrefDevDispatchers.getBroadcastItem(i).dispatchPrefDevicesChanged( strategy, devices); } catch (RemoteException e) { Loading @@ -2413,9 +2376,6 @@ public class AudioDeviceInventory { final int nbDispatchers = mNonDefDevDispatchers.beginBroadcast(); for (int i = 0; i < nbDispatchers; i++) { try { if (!((Boolean) mNonDefDevDispatchers.getBroadcastCookie(i))) { devices = mDeviceBroker.anonymizeAudioDeviceAttributesListUnchecked(devices); } mNonDefDevDispatchers.getBroadcastItem(i).dispatchNonDefDevicesChanged( strategy, devices); } catch (RemoteException e) { Loading @@ -2429,9 +2389,6 @@ public class AudioDeviceInventory { final int nbDispatchers = mDevRoleCapturePresetDispatchers.beginBroadcast(); for (int i = 0; i < nbDispatchers; ++i) { try { if (!((Boolean) mDevRoleCapturePresetDispatchers.getBroadcastCookie(i))) { devices = mDeviceBroker.anonymizeAudioDeviceAttributesListUnchecked(devices); } mDevRoleCapturePresetDispatchers.getBroadcastItem(i).dispatchDevicesRoleChanged( capturePreset, role, devices); } catch (RemoteException e) { Loading @@ -2456,21 +2413,20 @@ public class AudioDeviceInventory { int deviceCatalogSize = 0; synchronized (mDeviceInventoryLock) { deviceCatalogSize = mDeviceInventory.size(); } final StringBuilder settingsBuilder = new StringBuilder( deviceCatalogSize * AdiDeviceState.getPeristedMaxSize()); Iterator<AdiDeviceState> iterator = mDeviceInventory.values().iterator(); if (iterator.hasNext()) { settingsBuilder.append(iterator.next().toPersistableString()); } while (iterator.hasNext()) { synchronized (mDeviceInventoryLock) { for (int i = 0; i < mDeviceInventory.size(); i++) { settingsBuilder.append(mDeviceInventory.get(i).toPersistableString()); if (i != mDeviceInventory.size() - 1) { settingsBuilder.append(SETTING_DEVICE_SEPARATOR_CHAR); settingsBuilder.append(iterator.next().toPersistableString()); } return settingsBuilder.toString(); } } return settingsBuilder.toString(); } /*package*/ void setDeviceSettings(String settings) { clearDeviceInventory(); Loading services/core/java/com/android/server/audio/AudioService.java +26 −183 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
media/java/android/media/AudioDeviceAttributes.java +1 −25 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public final class AudioDeviceAttributes implements Parcelable { /** * The unique address of the device. Some devices don't have addresses, only an empty string. */ private @NonNull String mAddress; private final @NonNull String mAddress; /** * The non-unique name of the device. Some devices don't have names, only an empty string. * Should not be used as a unique identifier for a device. Loading Loading @@ -186,21 +186,6 @@ public final class AudioDeviceAttributes implements Parcelable { mAudioDescriptors = new ArrayList<>(); } /** * @hide * Copy Constructor. * @param ada the copied AudioDeviceAttributes */ public AudioDeviceAttributes(AudioDeviceAttributes ada) { mRole = ada.getRole(); mType = ada.getType(); mAddress = ada.getAddress(); mName = ada.getName(); mNativeType = ada.getInternalType(); mAudioProfiles = ada.getAudioProfiles(); mAudioDescriptors = ada.getAudioDescriptors(); } /** * @hide * Returns the role of a device Loading Loading @@ -231,15 +216,6 @@ public final class AudioDeviceAttributes implements Parcelable { return mAddress; } /** * @hide * Sets the device address. Only used by audio service. */ public void setAddress(@NonNull String address) { Objects.requireNonNull(address); mAddress = address; } /** * @hide * Returns the name of the audio device, or an empty string for devices without one Loading
services/core/java/com/android/server/audio/AdiDeviceState.java +1 −10 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.media.AudioDeviceAttributes; import android.media.AudioDeviceInfo; import android.text.TextUtils; import android.util.Log; import android.util.Pair; import java.util.Objects; Loading @@ -44,8 +43,6 @@ import java.util.Objects; private final int mInternalDeviceType; @NonNull private final String mDeviceAddress; /** Unique device id from internal device type and address. */ private final Pair<Integer, String> mDeviceId; private boolean mSAEnabled; private boolean mHasHeadTracker = false; private boolean mHeadTrackerEnabled; Loading @@ -71,11 +68,6 @@ import java.util.Objects; } mDeviceAddress = isBluetoothDevice(mInternalDeviceType) ? Objects.requireNonNull( address) : ""; mDeviceId = new Pair<>(mInternalDeviceType, mDeviceAddress); } public Pair<Integer, String> getDeviceId() { return mDeviceId; } @AudioDeviceInfo.AudioDeviceType Loading Loading @@ -146,8 +138,7 @@ import java.util.Objects; @Override public String toString() { return "type: " + mDeviceType + " internal type: 0x" + Integer.toHexString(mInternalDeviceType) return "type: " + mDeviceType + "internal type: " + mInternalDeviceType + " addr: " + mDeviceAddress + " enabled: " + mSAEnabled + " HT: " + mHasHeadTracker + " HTenabled: " + mHeadTrackerEnabled; } Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +6 −11 Original line number Diff line number Diff line Loading @@ -1153,8 +1153,8 @@ public class AudioDeviceBroker { } /*package*/ void registerStrategyPreferredDevicesDispatcher( @NonNull IStrategyPreferredDevicesDispatcher dispatcher, boolean isPrivileged) { mDeviceInventory.registerStrategyPreferredDevicesDispatcher(dispatcher, isPrivileged); @NonNull IStrategyPreferredDevicesDispatcher dispatcher) { mDeviceInventory.registerStrategyPreferredDevicesDispatcher(dispatcher); } /*package*/ void unregisterStrategyPreferredDevicesDispatcher( Loading @@ -1163,8 +1163,8 @@ public class AudioDeviceBroker { } /*package*/ void registerStrategyNonDefaultDevicesDispatcher( @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher, boolean isPrivileged) { mDeviceInventory.registerStrategyNonDefaultDevicesDispatcher(dispatcher, isPrivileged); @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher) { mDeviceInventory.registerStrategyNonDefaultDevicesDispatcher(dispatcher); } /*package*/ void unregisterStrategyNonDefaultDevicesDispatcher( Loading @@ -1182,8 +1182,8 @@ public class AudioDeviceBroker { } /*package*/ void registerCapturePresetDevicesRoleDispatcher( @NonNull ICapturePresetDevicesRoleDispatcher dispatcher, boolean isPrivileged) { mDeviceInventory.registerCapturePresetDevicesRoleDispatcher(dispatcher, isPrivileged); @NonNull ICapturePresetDevicesRoleDispatcher dispatcher) { mDeviceInventory.registerCapturePresetDevicesRoleDispatcher(dispatcher); } /*package*/ void unregisterCapturePresetDevicesRoleDispatcher( Loading @@ -1191,11 +1191,6 @@ public class AudioDeviceBroker { mDeviceInventory.unregisterCapturePresetDevicesRoleDispatcher(dispatcher); } /* package */ List<AudioDeviceAttributes> anonymizeAudioDeviceAttributesListUnchecked( List<AudioDeviceAttributes> devices) { return mAudioService.anonymizeAudioDeviceAttributesListUnchecked(devices); } /*package*/ void registerCommunicationDeviceDispatcher( @NonNull ICommunicationDeviceDispatcher dispatcher) { mCommDevDispatchers.register(dispatcher); Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +28 −72 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import com.google.android.collect.Sets; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; Loading Loading @@ -92,59 +91,31 @@ public class AudioDeviceInventory { private final Object mDeviceInventoryLock = new Object(); @GuardedBy("mDeviceInventoryLock") private final HashMap<Pair<Integer, String>, AdiDeviceState> mDeviceInventory = new HashMap<>(); private final ArrayList<AdiDeviceState> mDeviceInventory = new ArrayList<>(0); List<AdiDeviceState> getImmutableDeviceInventory() { synchronized (mDeviceInventoryLock) { return new ArrayList<AdiDeviceState>(mDeviceInventory.values()); return List.copyOf(mDeviceInventory); } } void addDeviceStateToInventory(AdiDeviceState deviceState) { synchronized (mDeviceInventoryLock) { mDeviceInventory.put(deviceState.getDeviceId(), deviceState); } } /** * Adds a new entry in mDeviceInventory if the AudioDeviceAttributes passed is an sink * Bluetooth device and no corresponding entry already exists. * @param ada the device to add if needed */ void addAudioDeviceInInventoryIfNeeded(AudioDeviceAttributes ada) { if (!AudioSystem.isBluetoothOutDevice(ada.getInternalType())) { return; } synchronized (mDeviceInventoryLock) { if (findDeviceStateForAudioDeviceAttributes(ada, ada.getType()) != null) { return; mDeviceInventory.add(deviceState); } AdiDeviceState ads = new AdiDeviceState( ada.getType(), ada.getInternalType(), ada.getAddress()); mDeviceInventory.put(ads.getDeviceId(), ads); } mDeviceBroker.persistAudioDeviceSettings(); } /** * Finds the device state that matches the passed {@link AudioDeviceAttributes} and device * type. Note: currently this method only returns a valid device for A2DP and BLE devices. * * @param ada attributes of device to match * @param canonicalDeviceType external device type to match * @return the found {@link AdiDeviceState} matching a cached A2DP or BLE device or * {@code null} otherwise. */ @Nullable AdiDeviceState findDeviceStateForAudioDeviceAttributes(AudioDeviceAttributes ada, int canonicalDeviceType) { final boolean isWireless = isBluetoothDevice(ada.getInternalType()); synchronized (mDeviceInventoryLock) { for (AdiDeviceState deviceState : mDeviceInventory.values()) { if (deviceState.getDeviceType() == canonicalDeviceType for (AdiDeviceState deviceSetting : mDeviceInventory) { if (deviceSetting.getDeviceType() == canonicalDeviceType && (!isWireless || ada.getAddress().equals( deviceState.getDeviceAddress()))) { return deviceState; deviceSetting.getDeviceAddress()))) { return deviceSetting; } } } Loading Loading @@ -416,7 +387,7 @@ public class AudioDeviceInventory { + " role:" + key.second + " devices:" + devices); }); pw.println("\ndevices:\n"); synchronized (mDeviceInventoryLock) { for (AdiDeviceState device : mDeviceInventory.values()) { for (AdiDeviceState device : mDeviceInventory) { pw.println("\t" + device + "\n"); } } Loading Loading @@ -963,8 +934,8 @@ public class AudioDeviceInventory { /*package*/ void registerStrategyPreferredDevicesDispatcher( @NonNull IStrategyPreferredDevicesDispatcher dispatcher, boolean isPrivileged) { mPrefDevDispatchers.register(dispatcher, isPrivileged); @NonNull IStrategyPreferredDevicesDispatcher dispatcher) { mPrefDevDispatchers.register(dispatcher); } /*package*/ void unregisterStrategyPreferredDevicesDispatcher( Loading @@ -973,8 +944,8 @@ public class AudioDeviceInventory { } /*package*/ void registerStrategyNonDefaultDevicesDispatcher( @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher, boolean isPrivileged) { mNonDefDevDispatchers.register(dispatcher, isPrivileged); @NonNull IStrategyNonDefaultDevicesDispatcher dispatcher) { mNonDefDevDispatchers.register(dispatcher); } /*package*/ void unregisterStrategyNonDefaultDevicesDispatcher( Loading Loading @@ -1055,8 +1026,8 @@ public class AudioDeviceInventory { } /*package*/ void registerCapturePresetDevicesRoleDispatcher( @NonNull ICapturePresetDevicesRoleDispatcher dispatcher, boolean isPrivileged) { mDevRoleCapturePresetDispatchers.register(dispatcher, isPrivileged); @NonNull ICapturePresetDevicesRoleDispatcher dispatcher) { mDevRoleCapturePresetDispatchers.register(dispatcher); } /*package*/ void unregisterCapturePresetDevicesRoleDispatcher( Loading Loading @@ -1383,8 +1354,6 @@ public class AudioDeviceInventory { updateBluetoothPreferredModes_l(connect ? btDevice : null /*connectedDevice*/); if (!connect) { purgeDevicesRoles_l(); } else { addAudioDeviceInInventoryIfNeeded(attributes); } } mmi.set(MediaMetrics.Property.STATE, MediaMetrics.Value.CONNECTED).record(); Loading Loading @@ -1651,7 +1620,6 @@ public class AudioDeviceInventory { setCurrentAudioRouteNameIfPossible(name, true /*fromA2dp*/); updateBluetoothPreferredModes_l(btInfo.mDevice /*connectedDevice*/); addAudioDeviceInInventoryIfNeeded(ada); } static final int[] CAPTURE_PRESETS = new int[] {AudioSource.MIC, AudioSource.CAMCORDER, Loading Loading @@ -1951,9 +1919,9 @@ public class AudioDeviceInventory { final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID); mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, streamType); AudioDeviceAttributes ada = new AudioDeviceAttributes( AudioSystem.DEVICE_OUT_HEARING_AID, address, name); mAudioSystem.setDeviceConnectionState(ada, mAudioSystem.setDeviceConnectionState(new AudioDeviceAttributes( AudioSystem.DEVICE_OUT_HEARING_AID, address, name), AudioSystem.DEVICE_STATE_AVAILABLE, AudioSystem.AUDIO_FORMAT_DEFAULT); mConnectedDevices.put( Loading @@ -1963,7 +1931,6 @@ public class AudioDeviceInventory { mDeviceBroker.postApplyVolumeOnDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID, "makeHearingAidDeviceAvailable"); setCurrentAudioRouteNameIfPossible(name, false /*fromA2dp*/); addAudioDeviceInInventoryIfNeeded(ada); new MediaMetrics.Item(mMetricsId + "makeHearingAidDeviceAvailable") .set(MediaMetrics.Property.ADDRESS, address != null ? address : "") .set(MediaMetrics.Property.DEVICE, Loading Loading @@ -2066,7 +2033,6 @@ public class AudioDeviceInventory { sensorUuid)); mDeviceBroker.postAccessoryPlugMediaUnmute(device); setCurrentAudioRouteNameIfPossible(name, /*fromA2dp=*/false); addAudioDeviceInInventoryIfNeeded(ada); } if (streamType == AudioSystem.STREAM_DEFAULT) { Loading Loading @@ -2397,9 +2363,6 @@ public class AudioDeviceInventory { final int nbDispatchers = mPrefDevDispatchers.beginBroadcast(); for (int i = 0; i < nbDispatchers; i++) { try { if (!((Boolean) mPrefDevDispatchers.getBroadcastCookie(i))) { devices = mDeviceBroker.anonymizeAudioDeviceAttributesListUnchecked(devices); } mPrefDevDispatchers.getBroadcastItem(i).dispatchPrefDevicesChanged( strategy, devices); } catch (RemoteException e) { Loading @@ -2413,9 +2376,6 @@ public class AudioDeviceInventory { final int nbDispatchers = mNonDefDevDispatchers.beginBroadcast(); for (int i = 0; i < nbDispatchers; i++) { try { if (!((Boolean) mNonDefDevDispatchers.getBroadcastCookie(i))) { devices = mDeviceBroker.anonymizeAudioDeviceAttributesListUnchecked(devices); } mNonDefDevDispatchers.getBroadcastItem(i).dispatchNonDefDevicesChanged( strategy, devices); } catch (RemoteException e) { Loading @@ -2429,9 +2389,6 @@ public class AudioDeviceInventory { final int nbDispatchers = mDevRoleCapturePresetDispatchers.beginBroadcast(); for (int i = 0; i < nbDispatchers; ++i) { try { if (!((Boolean) mDevRoleCapturePresetDispatchers.getBroadcastCookie(i))) { devices = mDeviceBroker.anonymizeAudioDeviceAttributesListUnchecked(devices); } mDevRoleCapturePresetDispatchers.getBroadcastItem(i).dispatchDevicesRoleChanged( capturePreset, role, devices); } catch (RemoteException e) { Loading @@ -2456,21 +2413,20 @@ public class AudioDeviceInventory { int deviceCatalogSize = 0; synchronized (mDeviceInventoryLock) { deviceCatalogSize = mDeviceInventory.size(); } final StringBuilder settingsBuilder = new StringBuilder( deviceCatalogSize * AdiDeviceState.getPeristedMaxSize()); Iterator<AdiDeviceState> iterator = mDeviceInventory.values().iterator(); if (iterator.hasNext()) { settingsBuilder.append(iterator.next().toPersistableString()); } while (iterator.hasNext()) { synchronized (mDeviceInventoryLock) { for (int i = 0; i < mDeviceInventory.size(); i++) { settingsBuilder.append(mDeviceInventory.get(i).toPersistableString()); if (i != mDeviceInventory.size() - 1) { settingsBuilder.append(SETTING_DEVICE_SEPARATOR_CHAR); settingsBuilder.append(iterator.next().toPersistableString()); } return settingsBuilder.toString(); } } return settingsBuilder.toString(); } /*package*/ void setDeviceSettings(String settings) { clearDeviceInventory(); Loading
services/core/java/com/android/server/audio/AudioService.java +26 −183 File changed.Preview size limit exceeded, changes collapsed. Show changes