diff options
author | Hung-ying Tyan <tyanh@google.com> | 2010-08-17 10:53:44 +0800 |
---|---|---|
committer | Hung-ying Tyan <tyanh@google.com> | 2010-08-18 10:21:10 +0800 |
commit | a4cb657e3a14777fc0838e27fdfa2ad5c737cf43 (patch) | |
tree | 7a686fe4ce7336d318f82e22d8e4bb931b0094fd /telephony | |
parent | 8eac20eacd088793547c56e14d602b28d62fb278 (diff) | |
download | frameworks_base-a4cb657e3a14777fc0838e27fdfa2ad5c737cf43.zip frameworks_base-a4cb657e3a14777fc0838e27fdfa2ad5c737cf43.tar.gz frameworks_base-a4cb657e3a14777fc0838e27fdfa2ad5c737cf43.tar.bz2 |
CallManager: add setAudioMode()
When in a call, different audio modes need to be applied based on phone type.
(For example, SIP call needs to be in MODE_NORMAL while GSM call in MODE_IN_CALL.)
Originally, it's handled in PhoneUtils.setAudioMode(). It makes more sense now
to handle the actual logic in CallManager.
Change-Id: I58d8f31d6b4afe22f88da442daac2010781de801
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/com/android/internal/telephony/CallManager.java | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/telephony/java/com/android/internal/telephony/CallManager.java b/telephony/java/com/android/internal/telephony/CallManager.java index 511440e..8e08592 100644 --- a/telephony/java/com/android/internal/telephony/CallManager.java +++ b/telephony/java/com/android/internal/telephony/CallManager.java @@ -19,15 +19,14 @@ package com.android.internal.telephony; import com.android.internal.telephony.sip.SipPhone; import android.content.Context; +import android.media.AudioManager; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.RegistrantList; -import android.util.Log; - import android.telephony.PhoneStateListener; import android.telephony.ServiceState; - +import android.util.Log; import java.util.ArrayList; import java.util.Collections; @@ -54,7 +53,7 @@ import java.util.List; */ public final class CallManager { - private static final String LOG_TAG ="GSM"; + private static final String LOG_TAG ="Phone"; private static final boolean LOCAL_DEBUG = true; private static final int EVENT_DISCONNECT = 100; @@ -305,6 +304,32 @@ public final class CallManager { } } + public void setAudioMode() { + Context context = getContext(); + if (context == null) return; + AudioManager audioManager = (AudioManager) + context.getSystemService(Context.AUDIO_SERVICE); + + int mode = AudioManager.MODE_NORMAL; + switch (getState()) { + case RINGING: + mode = AudioManager.MODE_RINGTONE; + break; + case OFFHOOK: + Phone fgPhone = getFgPhone(); + if (!(fgPhone instanceof SipPhone)) { + mode = AudioManager.MODE_IN_CALL; + } + break; + } + audioManager.setMode(mode); + } + + private Context getContext() { + Phone defaultPhone = getDefaultPhone(); + return ((defaultPhone == null) ? null : defaultPhone.getContext()); + } + private void registerForPhoneStates(Phone phone) { phone.registerForPreciseCallStateChanged(mHandler, EVENT_PRECISE_CALL_STATE_CHANGED, null); phone.registerForDisconnect(mHandler, EVENT_DISCONNECT, null); |