Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +12 −9 Original line number Original line Diff line number Diff line Loading @@ -424,7 +424,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @return true if speakerphone is active, false otherwise. * @return true if speakerphone is active, false otherwise. */ */ /*package*/ boolean isSpeakerphoneOn() { /*package*/ boolean isSpeakerphoneOn() { AudioDeviceAttributes device = getPreferredDeviceForComm(); AudioDeviceAttributes device = getPreferredCommunicationDevice(); if (device == null) { if (device == null) { return false; return false; } } Loading Loading @@ -595,7 +595,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @return true if Bluetooth SCO is active , false otherwise. * @return true if Bluetooth SCO is active , false otherwise. */ */ /*package*/ boolean isBluetoothScoOn() { /*package*/ boolean isBluetoothScoOn() { AudioDeviceAttributes device = getPreferredDeviceForComm(); AudioDeviceAttributes device = getPreferredCommunicationDevice(); if (device == null) { if (device == null) { return false; return false; } } Loading Loading @@ -1021,9 +1021,11 @@ import java.util.concurrent.atomic.AtomicBoolean; pw.println("\n" + prefix + "mPreferredCommunicationDevice: " pw.println("\n" + prefix + "mPreferredCommunicationDevice: " + mPreferredCommunicationDevice); + mPreferredCommunicationDevice); pw.println(prefix + "Selected Communication Device: " pw.println(prefix + "Selected Communication Device: " + ((getCommunicationDevice() == null) ? "None" + ((getCommunicationDevice() == null) ? "None" : new AudioDeviceAttributes(getCommunicationDevice()))); : new AudioDeviceAttributes(getCommunicationDevice()))); pw.println(prefix + "mCommunicationStrategyId: " pw.println(prefix + "mCommunicationStrategyId: " + mCommunicationStrategyId); + mCommunicationStrategyId); Loading Loading @@ -1213,14 +1215,12 @@ import java.util.concurrent.atomic.AtomicBoolean; case MSG_I_SET_MODE_OWNER_PID: case MSG_I_SET_MODE_OWNER_PID: synchronized (mSetModeLock) { synchronized (mSetModeLock) { synchronized (mDeviceStateLock) { synchronized (mDeviceStateLock) { if (mModeOwnerPid != msg.arg1) { mModeOwnerPid = msg.arg1; mModeOwnerPid = msg.arg1; if (msg.arg2 != AudioSystem.MODE_RINGTONE) { if (msg.arg2 != AudioSystem.MODE_RINGTONE) { onUpdateCommunicationRoute("setNewModeOwner"); onUpdateCommunicationRoute("setNewModeOwner"); } } } } } } } break; break; case MSG_L_COMMUNICATION_ROUTE_CLIENT_DIED: case MSG_L_COMMUNICATION_ROUTE_CLIENT_DIED: synchronized (mSetModeLock) { synchronized (mSetModeLock) { Loading Loading @@ -1676,7 +1676,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @return selected forced usage for communication. * @return selected forced usage for communication. */ */ @GuardedBy("mDeviceStateLock") @GuardedBy("mDeviceStateLock") @Nullable private AudioDeviceAttributes getPreferredDeviceForComm() { @Nullable private AudioDeviceAttributes getPreferredCommunicationDevice() { boolean btSCoOn = mBluetoothScoOn && mBtHelper.isBluetoothScoOn(); boolean btSCoOn = mBluetoothScoOn && mBtHelper.isBluetoothScoOn(); if (btSCoOn) { if (btSCoOn) { // Use the SCO device known to BtHelper so that it matches exactly // Use the SCO device known to BtHelper so that it matches exactly Loading Loading @@ -1704,11 +1704,14 @@ import java.util.concurrent.atomic.AtomicBoolean; // @GuardedBy("mSetModeLock") // @GuardedBy("mSetModeLock") @GuardedBy("mDeviceStateLock") @GuardedBy("mDeviceStateLock") private void onUpdateCommunicationRoute(String eventSource) { private void onUpdateCommunicationRoute(String eventSource) { mPreferredCommunicationDevice = getPreferredDeviceForComm(); mPreferredCommunicationDevice = getPreferredCommunicationDevice(); if (AudioService.DEBUG_COMM_RTE) { if (AudioService.DEBUG_COMM_RTE) { Log.v(TAG, "onUpdateCommunicationRoute, mPreferredCommunicationDevice: " Log.v(TAG, "onUpdateCommunicationRoute, mPreferredCommunicationDevice: " + mPreferredCommunicationDevice + " eventSource: " + eventSource); + mPreferredCommunicationDevice + " eventSource: " + eventSource); } } AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( "onUpdateCommunicationRoute, mPreferredCommunicationDevice: " + mPreferredCommunicationDevice + " eventSource: " + eventSource))); if (mPreferredCommunicationDevice == null if (mPreferredCommunicationDevice == null || !AudioSystem.DEVICE_OUT_ALL_SCO_SET.contains( || !AudioSystem.DEVICE_OUT_ALL_SCO_SET.contains( Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -662,6 +662,11 @@ public class AudioDeviceInventory { /*package*/ int removePreferredDevicesForStrategySync(int strategy) { /*package*/ int removePreferredDevicesForStrategySync(int strategy) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( "removePreferredDevicesForStrategySync, strategy: " + strategy)).printLog(TAG)); final int status = mAudioSystem.removeDevicesRoleForStrategy( final int status = mAudioSystem.removeDevicesRoleForStrategy( strategy, AudioSystem.DEVICE_ROLE_PREFERRED); strategy, AudioSystem.DEVICE_ROLE_PREFERRED); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +12 −9 Original line number Original line Diff line number Diff line Loading @@ -424,7 +424,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @return true if speakerphone is active, false otherwise. * @return true if speakerphone is active, false otherwise. */ */ /*package*/ boolean isSpeakerphoneOn() { /*package*/ boolean isSpeakerphoneOn() { AudioDeviceAttributes device = getPreferredDeviceForComm(); AudioDeviceAttributes device = getPreferredCommunicationDevice(); if (device == null) { if (device == null) { return false; return false; } } Loading Loading @@ -595,7 +595,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @return true if Bluetooth SCO is active , false otherwise. * @return true if Bluetooth SCO is active , false otherwise. */ */ /*package*/ boolean isBluetoothScoOn() { /*package*/ boolean isBluetoothScoOn() { AudioDeviceAttributes device = getPreferredDeviceForComm(); AudioDeviceAttributes device = getPreferredCommunicationDevice(); if (device == null) { if (device == null) { return false; return false; } } Loading Loading @@ -1021,9 +1021,11 @@ import java.util.concurrent.atomic.AtomicBoolean; pw.println("\n" + prefix + "mPreferredCommunicationDevice: " pw.println("\n" + prefix + "mPreferredCommunicationDevice: " + mPreferredCommunicationDevice); + mPreferredCommunicationDevice); pw.println(prefix + "Selected Communication Device: " pw.println(prefix + "Selected Communication Device: " + ((getCommunicationDevice() == null) ? "None" + ((getCommunicationDevice() == null) ? "None" : new AudioDeviceAttributes(getCommunicationDevice()))); : new AudioDeviceAttributes(getCommunicationDevice()))); pw.println(prefix + "mCommunicationStrategyId: " pw.println(prefix + "mCommunicationStrategyId: " + mCommunicationStrategyId); + mCommunicationStrategyId); Loading Loading @@ -1213,14 +1215,12 @@ import java.util.concurrent.atomic.AtomicBoolean; case MSG_I_SET_MODE_OWNER_PID: case MSG_I_SET_MODE_OWNER_PID: synchronized (mSetModeLock) { synchronized (mSetModeLock) { synchronized (mDeviceStateLock) { synchronized (mDeviceStateLock) { if (mModeOwnerPid != msg.arg1) { mModeOwnerPid = msg.arg1; mModeOwnerPid = msg.arg1; if (msg.arg2 != AudioSystem.MODE_RINGTONE) { if (msg.arg2 != AudioSystem.MODE_RINGTONE) { onUpdateCommunicationRoute("setNewModeOwner"); onUpdateCommunicationRoute("setNewModeOwner"); } } } } } } } break; break; case MSG_L_COMMUNICATION_ROUTE_CLIENT_DIED: case MSG_L_COMMUNICATION_ROUTE_CLIENT_DIED: synchronized (mSetModeLock) { synchronized (mSetModeLock) { Loading Loading @@ -1676,7 +1676,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * @return selected forced usage for communication. * @return selected forced usage for communication. */ */ @GuardedBy("mDeviceStateLock") @GuardedBy("mDeviceStateLock") @Nullable private AudioDeviceAttributes getPreferredDeviceForComm() { @Nullable private AudioDeviceAttributes getPreferredCommunicationDevice() { boolean btSCoOn = mBluetoothScoOn && mBtHelper.isBluetoothScoOn(); boolean btSCoOn = mBluetoothScoOn && mBtHelper.isBluetoothScoOn(); if (btSCoOn) { if (btSCoOn) { // Use the SCO device known to BtHelper so that it matches exactly // Use the SCO device known to BtHelper so that it matches exactly Loading Loading @@ -1704,11 +1704,14 @@ import java.util.concurrent.atomic.AtomicBoolean; // @GuardedBy("mSetModeLock") // @GuardedBy("mSetModeLock") @GuardedBy("mDeviceStateLock") @GuardedBy("mDeviceStateLock") private void onUpdateCommunicationRoute(String eventSource) { private void onUpdateCommunicationRoute(String eventSource) { mPreferredCommunicationDevice = getPreferredDeviceForComm(); mPreferredCommunicationDevice = getPreferredCommunicationDevice(); if (AudioService.DEBUG_COMM_RTE) { if (AudioService.DEBUG_COMM_RTE) { Log.v(TAG, "onUpdateCommunicationRoute, mPreferredCommunicationDevice: " Log.v(TAG, "onUpdateCommunicationRoute, mPreferredCommunicationDevice: " + mPreferredCommunicationDevice + " eventSource: " + eventSource); + mPreferredCommunicationDevice + " eventSource: " + eventSource); } } AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( "onUpdateCommunicationRoute, mPreferredCommunicationDevice: " + mPreferredCommunicationDevice + " eventSource: " + eventSource))); if (mPreferredCommunicationDevice == null if (mPreferredCommunicationDevice == null || !AudioSystem.DEVICE_OUT_ALL_SCO_SET.contains( || !AudioSystem.DEVICE_OUT_ALL_SCO_SET.contains( Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -662,6 +662,11 @@ public class AudioDeviceInventory { /*package*/ int removePreferredDevicesForStrategySync(int strategy) { /*package*/ int removePreferredDevicesForStrategySync(int strategy) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( "removePreferredDevicesForStrategySync, strategy: " + strategy)).printLog(TAG)); final int status = mAudioSystem.removeDevicesRoleForStrategy( final int status = mAudioSystem.removeDevicesRoleForStrategy( strategy, AudioSystem.DEVICE_ROLE_PREFERRED); strategy, AudioSystem.DEVICE_ROLE_PREFERRED); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading