Loading media/java/android/media/AudioManager.java +32 −0 Original line number Diff line number Diff line Loading @@ -1505,6 +1505,38 @@ public class AudioManager { */ public static final int MODE_IN_COMMUNICATION = AudioSystem.MODE_IN_COMMUNICATION; /* Calls states for Voice calls */ /** * @hide Call state for inactive call state. */ public static final int CALL_INACTIVE = AudioSystem.CALL_INACTIVE; /** * @hide Call state for active call state. */ public static final int CALL_ACTIVE = AudioSystem.CALL_ACTIVE; /** * @hide Call state for hold call state. */ public static final int CALL_HOLD = AudioSystem.CALL_HOLD; /** * @hide Call state for local call hold state. */ public static final int CALL_LOCAL_HOLD = AudioSystem.CALL_LOCAL_HOLD; /* Key used in setParameters for VSID and Call_state */ /** * @hide Key for vsid used in setParameters. */ public static final String VSID_KEY = AudioSystem.VSID_KEY; /** * @hide Key for call_state used in setParameters. */ public static final String CALL_STATE_KEY = AudioSystem.CALL_STATE_KEY; /** * @hide Key for all_call_states used in getParameters. */ public static final String ALL_CALL_STATES_KEY = AudioSystem.ALL_CALL_STATES_KEY; /* Routing bits for setRouting/getRouting API */ /** * Routing audio output to earpiece Loading media/java/android/media/AudioSystem.java +17 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,23 @@ public class AudioSystem public static final int NUM_MODES = 4; /* Call states for Voice calls */ /* @hide Call state for inactive call state. */ public static final int CALL_INACTIVE = 0x1; /* @hide Call state for active call state. */ public static final int CALL_ACTIVE = 0x2; /* @hide Call state for hold call state. */ public static final int CALL_HOLD = 0x3; /* @hide Call state for local hold call state. */ public static final int CALL_LOCAL_HOLD = 0x4; /* @hide Key for vsid used in setParameters */ public static final String VSID_KEY = "vsid"; /* @hide Key for call_state used in setParameters */ public static final String CALL_STATE_KEY = "call_state"; /* @hide Key for all_call_states used in getParameters */ public static final String ALL_CALL_STATES_KEY = "all_call_states"; /* Routing bits for the former setRouting/getRouting API */ /** @deprecated */ @Deprecated public static final int ROUTE_EARPIECE = (1 << 0); Loading media/java/android/media/FocusRequester.java +4 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,10 @@ class FocusRequester { return mStreamType; } String getClientId() { return mClientId; } private static String focusChangeToString(int focus) { switch(focus) { Loading media/java/android/media/MediaFocusControl.java +30 −3 Original line number Diff line number Diff line Loading @@ -474,7 +474,7 @@ public class MediaFocusControl implements OnFinished { private void notifyTopOfAudioFocusStack() { // notify the top of the stack it gained focus if (!mFocusStack.empty()) { if (canReassignAudioFocus()) { if (canReassignAudioFocus(mFocusStack.peek().getClientId())) { mFocusStack.peek().handleFocusGain(AudioManager.AUDIOFOCUS_GAIN); } } Loading Loading @@ -581,14 +581,37 @@ public class MediaFocusControl implements OnFinished { } } /* Constant to identify focus stack entry clientid for QCHAT client */ private static final String CLIENT_ID_QCHAT = "QCHAT"; /** * Helper function: * Returns true if the system is in a state where the focus can be reevaluated, false otherwise. */ private boolean canReassignAudioFocus() { private boolean canReassignAudioFocus(String clientId) { // focus requests are rejected during a phone call or when the phone is ringing // this is equivalent to IN_VOICE_COMM_FOCUS_ID having the focus // Also focus request is granted to QCHAT client even when voice call is active. QCHAT // client will first check if any voice calls are in CALL_INACTIVE/CALL_HOLD state if (!mFocusStack.isEmpty() && mFocusStack.peek().hasSameClient(IN_VOICE_COMM_FOCUS_ID)) { if (clientId.contains(CLIENT_ID_QCHAT)) return true; else return false; } return true; } /** * Helper function: * Returns true if the system is in a state where the focus can be reevaluated , false otherwise. */ private boolean canReassignAudioFocusFromQchat(int streamType, String clientId) { // Focus request is rejected for Music Player and for QChat client if the focus is already // acquired by a QChat client if (!mFocusStack.isEmpty() && mFocusStack.peek().getClientId().contains(CLIENT_ID_QCHAT) && (clientId.contains(CLIENT_ID_QCHAT) || (streamType == AudioManager.STREAM_MUSIC))) { return false; } return true; Loading Loading @@ -643,7 +666,11 @@ public class MediaFocusControl implements OnFinished { } synchronized(mAudioFocusLock) { if (!canReassignAudioFocus()) { if (!canReassignAudioFocus(clientId)) { return AudioManager.AUDIOFOCUS_REQUEST_FAILED; } if (!canReassignAudioFocusFromQchat(mainStreamType, clientId)) { return AudioManager.AUDIOFOCUS_REQUEST_FAILED; } Loading Loading
media/java/android/media/AudioManager.java +32 −0 Original line number Diff line number Diff line Loading @@ -1505,6 +1505,38 @@ public class AudioManager { */ public static final int MODE_IN_COMMUNICATION = AudioSystem.MODE_IN_COMMUNICATION; /* Calls states for Voice calls */ /** * @hide Call state for inactive call state. */ public static final int CALL_INACTIVE = AudioSystem.CALL_INACTIVE; /** * @hide Call state for active call state. */ public static final int CALL_ACTIVE = AudioSystem.CALL_ACTIVE; /** * @hide Call state for hold call state. */ public static final int CALL_HOLD = AudioSystem.CALL_HOLD; /** * @hide Call state for local call hold state. */ public static final int CALL_LOCAL_HOLD = AudioSystem.CALL_LOCAL_HOLD; /* Key used in setParameters for VSID and Call_state */ /** * @hide Key for vsid used in setParameters. */ public static final String VSID_KEY = AudioSystem.VSID_KEY; /** * @hide Key for call_state used in setParameters. */ public static final String CALL_STATE_KEY = AudioSystem.CALL_STATE_KEY; /** * @hide Key for all_call_states used in getParameters. */ public static final String ALL_CALL_STATES_KEY = AudioSystem.ALL_CALL_STATES_KEY; /* Routing bits for setRouting/getRouting API */ /** * Routing audio output to earpiece Loading
media/java/android/media/AudioSystem.java +17 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,23 @@ public class AudioSystem public static final int NUM_MODES = 4; /* Call states for Voice calls */ /* @hide Call state for inactive call state. */ public static final int CALL_INACTIVE = 0x1; /* @hide Call state for active call state. */ public static final int CALL_ACTIVE = 0x2; /* @hide Call state for hold call state. */ public static final int CALL_HOLD = 0x3; /* @hide Call state for local hold call state. */ public static final int CALL_LOCAL_HOLD = 0x4; /* @hide Key for vsid used in setParameters */ public static final String VSID_KEY = "vsid"; /* @hide Key for call_state used in setParameters */ public static final String CALL_STATE_KEY = "call_state"; /* @hide Key for all_call_states used in getParameters */ public static final String ALL_CALL_STATES_KEY = "all_call_states"; /* Routing bits for the former setRouting/getRouting API */ /** @deprecated */ @Deprecated public static final int ROUTE_EARPIECE = (1 << 0); Loading
media/java/android/media/FocusRequester.java +4 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,10 @@ class FocusRequester { return mStreamType; } String getClientId() { return mClientId; } private static String focusChangeToString(int focus) { switch(focus) { Loading
media/java/android/media/MediaFocusControl.java +30 −3 Original line number Diff line number Diff line Loading @@ -474,7 +474,7 @@ public class MediaFocusControl implements OnFinished { private void notifyTopOfAudioFocusStack() { // notify the top of the stack it gained focus if (!mFocusStack.empty()) { if (canReassignAudioFocus()) { if (canReassignAudioFocus(mFocusStack.peek().getClientId())) { mFocusStack.peek().handleFocusGain(AudioManager.AUDIOFOCUS_GAIN); } } Loading Loading @@ -581,14 +581,37 @@ public class MediaFocusControl implements OnFinished { } } /* Constant to identify focus stack entry clientid for QCHAT client */ private static final String CLIENT_ID_QCHAT = "QCHAT"; /** * Helper function: * Returns true if the system is in a state where the focus can be reevaluated, false otherwise. */ private boolean canReassignAudioFocus() { private boolean canReassignAudioFocus(String clientId) { // focus requests are rejected during a phone call or when the phone is ringing // this is equivalent to IN_VOICE_COMM_FOCUS_ID having the focus // Also focus request is granted to QCHAT client even when voice call is active. QCHAT // client will first check if any voice calls are in CALL_INACTIVE/CALL_HOLD state if (!mFocusStack.isEmpty() && mFocusStack.peek().hasSameClient(IN_VOICE_COMM_FOCUS_ID)) { if (clientId.contains(CLIENT_ID_QCHAT)) return true; else return false; } return true; } /** * Helper function: * Returns true if the system is in a state where the focus can be reevaluated , false otherwise. */ private boolean canReassignAudioFocusFromQchat(int streamType, String clientId) { // Focus request is rejected for Music Player and for QChat client if the focus is already // acquired by a QChat client if (!mFocusStack.isEmpty() && mFocusStack.peek().getClientId().contains(CLIENT_ID_QCHAT) && (clientId.contains(CLIENT_ID_QCHAT) || (streamType == AudioManager.STREAM_MUSIC))) { return false; } return true; Loading Loading @@ -643,7 +666,11 @@ public class MediaFocusControl implements OnFinished { } synchronized(mAudioFocusLock) { if (!canReassignAudioFocus()) { if (!canReassignAudioFocus(clientId)) { return AudioManager.AUDIOFOCUS_REQUEST_FAILED; } if (!canReassignAudioFocusFromQchat(mainStreamType, clientId)) { return AudioManager.AUDIOFOCUS_REQUEST_FAILED; } Loading