From ceb47aae5a045856ad13a5534a4d96f9b36c9a65 Mon Sep 17 00:00:00 2001 From: Paul McLean Date: Thu, 19 Feb 2015 15:09:53 -0800 Subject: Changing AudioManager.listAudioDevicePorts to take a ArrayList argument. Change-Id: Ide9a2f58a7544e263600e100ba4274403201c5fa --- media/java/android/media/AudioDevicesManager.java | 9 ++++----- media/java/android/media/AudioManager.java | 4 ++-- .../com/android/server/tv/TvInputHardwareManager.java | 18 ++++++++---------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/media/java/android/media/AudioDevicesManager.java b/media/java/android/media/AudioDevicesManager.java index 4e52953..bce2100 100644 --- a/media/java/android/media/AudioDevicesManager.java +++ b/media/java/android/media/AudioDevicesManager.java @@ -130,8 +130,7 @@ public class AudioDevicesManager { public ArrayList listDevices(int flags) { Slog.i(TAG, "AudioManager.listDevices(" + Integer.toHexString(flags) + ")"); - //FIXME - Use ArrayList when mAudioManager.listAudioDevicePorts() is fixed. - ArrayList ports = new ArrayList(); + ArrayList ports = new ArrayList(); int status = mAudioManager.listAudioDevicePorts(ports); Slog.i(TAG, " status:" + status + " numPorts:" + ports.size()); @@ -140,9 +139,9 @@ public class AudioDevicesManager { if (status == AudioManager.SUCCESS) { deviceList = new ArrayList(); - for (AudioPort port : ports) { - if (/*port instanceof AudioDevicePort &&*/ checkFlags((AudioDevicePort)port, flags)) { - deviceList.add(new AudioDeviceInfo((AudioDevicePort)port)); + for (AudioDevicePort port : ports) { + if (checkFlags(port, flags)) { + deviceList.add(new AudioDeviceInfo(port)); } } } diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index da89cf4..9876995 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -3459,14 +3459,14 @@ public class AudioManager { * @see listAudioPorts(ArrayList) * @hide */ - public int listAudioDevicePorts(ArrayList devices) { + public int listAudioDevicePorts(ArrayList devices) { ArrayList ports = new ArrayList(); int status = updateAudioPortCache(ports, null); if (status == SUCCESS) { devices.clear(); for (int i = 0; i < ports.size(); i++) { if (ports.get(i) instanceof AudioDevicePort) { - devices.add(ports.get(i)); + devices.add((AudioDevicePort)ports.get(i)); } } } diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java index 50b2262..c5f4161 100644 --- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java +++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java @@ -699,15 +699,14 @@ class TvInputHardwareManager implements TvInputHal.Callback { private void findAudioSinkFromAudioPolicy(List sinks) { sinks.clear(); - ArrayList devicePorts = new ArrayList(); + ArrayList devicePorts = new ArrayList(); if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) { return; } int sinkDevice = mAudioManager.getDevicesForStream(AudioManager.STREAM_MUSIC); - for (AudioPort port : devicePorts) { - AudioDevicePort devicePort = (AudioDevicePort) port; - if ((devicePort.type() & sinkDevice) != 0) { - sinks.add(devicePort); + for (AudioDevicePort port : devicePorts) { + if ((port.type() & sinkDevice) != 0) { + sinks.add(port); } } } @@ -716,14 +715,13 @@ class TvInputHardwareManager implements TvInputHal.Callback { if (type == AudioManager.DEVICE_NONE) { return null; } - ArrayList devicePorts = new ArrayList(); + ArrayList devicePorts = new ArrayList(); if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) { return null; } - for (AudioPort port : devicePorts) { - AudioDevicePort devicePort = (AudioDevicePort) port; - if (devicePort.type() == type && devicePort.address().equals(address)) { - return devicePort; + for (AudioDevicePort port : devicePorts) { + if (port.type() == type && port.address().equals(address)) { + return port; } } return null; -- cgit v1.1