diff options
author | Hung-ying Tyan <tyanh@google.com> | 2010-08-18 14:21:15 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-18 14:21:15 -0700 |
commit | f2b4a15e18d2d91169f9ca882ca8a26ecc8dd8dd (patch) | |
tree | 5e3bcf437124f81a84d40cf7a1974e3b7c795c5d /telephony | |
parent | a9abfa54d32718fb778b006b1eb94c2e64542b5b (diff) | |
parent | fa9a38c566d09a4c891d584ed3d3af9690967b31 (diff) | |
download | frameworks_base-f2b4a15e18d2d91169f9ca882ca8a26ecc8dd8dd.zip frameworks_base-f2b4a15e18d2d91169f9ca882ca8a26ecc8dd8dd.tar.gz frameworks_base-f2b4a15e18d2d91169f9ca882ca8a26ecc8dd8dd.tar.bz2 |
am fa9a38c5: am 6ab94608: Merge "CallManager: add setAudioMode()" into gingerbread
Merge commit 'fa9a38c566d09a4c891d584ed3d3af9690967b31'
* commit 'fa9a38c566d09a4c891d584ed3d3af9690967b31':
CallManager: add setAudioMode()
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); |