PhoneApp.java revision 99d10538d840f0103c36dafa44db9f649ca884c8
1b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project/* 2b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Copyright (C) 2006 The Android Open Source Project 3b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 4b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * you may not use this file except in compliance with the License. 6b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * You may obtain a copy of the License at 7b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 8b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 10b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * See the License for the specific language governing permissions and 14b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * limitations under the License. 15b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 16b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 17b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectpackage com.android.phone; 18b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 19b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.app.Activity; 20b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.app.Application; 21b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.app.KeyguardManager; 22b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.app.ProgressDialog; 23b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.bluetooth.BluetoothHeadset; 24b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.bluetooth.BluetoothIntent; 25b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.BroadcastReceiver; 26b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.ContentResolver; 27b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.Context; 28b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.Intent; 29b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.IntentFilter; 30d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillaiimport android.content.res.Configuration; 31b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.media.AudioManager; 32b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.net.Uri; 33b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.AsyncResult; 34b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Binder; 35b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Handler; 36b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.IBinder; 37b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.IPowerManager; 38b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.LocalPowerManager; 39b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Message; 40b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.PowerManager; 41b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.RemoteException; 42b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.ServiceManager; 43b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.SystemClock; 44b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.SystemProperties; 45b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.preference.PreferenceManager; 46b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.provider.Settings.System; 47404edc94de563aef5fd5ba48be9114a970cb93bbWink Savilleimport android.telephony.ServiceState; 48b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.util.Config; 49b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.util.Log; 50b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.view.KeyEvent; 51b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.widget.Toast; 52b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 53ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brownimport com.android.internal.telephony.Call; 54a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.IccCard; 55a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.MmiCode; 56a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.Phone; 57a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.PhoneFactory; 58a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.TelephonyIntents; 59ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brownimport com.android.internal.telephony.cdma.EriInfo; 606bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillaiimport com.android.phone.OtaUtils.CdmaOtaScreenState; 61a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 62b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project/** 63b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Top-level Application class for the Phone app. 64b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 65b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectpublic class PhoneApp extends Application { 66b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ static final String LOG_TAG = "PhoneApp"; 67796c70c99bc39295bf685061056f06ab8949c742David Brown 68796c70c99bc39295bf685061056f06ab8949c742David Brown /** 69796c70c99bc39295bf685061056f06ab8949c742David Brown * Phone app-wide debug level: 70796c70c99bc39295bf685061056f06ab8949c742David Brown * 0 - no debug logging 71796c70c99bc39295bf685061056f06ab8949c742David Brown * 1 - normal debug logging if ro.debuggable is set (which is true in 72796c70c99bc39295bf685061056f06ab8949c742David Brown * "eng" and "userdebug" builds but not "user" builds) 73796c70c99bc39295bf685061056f06ab8949c742David Brown * 2 - ultra-verbose debug logging 74796c70c99bc39295bf685061056f06ab8949c742David Brown * 75796c70c99bc39295bf685061056f06ab8949c742David Brown * Most individual classes in the phone app have a local DBG constant, 76796c70c99bc39295bf685061056f06ab8949c742David Brown * typically set to 77796c70c99bc39295bf685061056f06ab8949c742David Brown * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1) 78796c70c99bc39295bf685061056f06ab8949c742David Brown * or else 79796c70c99bc39295bf685061056f06ab8949c742David Brown * (PhoneApp.DBG_LEVEL >= 2) 80796c70c99bc39295bf685061056f06ab8949c742David Brown * depending on the desired verbosity. 81796c70c99bc39295bf685061056f06ab8949c742David Brown */ 82796c70c99bc39295bf685061056f06ab8949c742David Brown /* package */ static final int DBG_LEVEL = 1; 83796c70c99bc39295bf685061056f06ab8949c742David Brown 84796c70c99bc39295bf685061056f06ab8949c742David Brown private static final boolean DBG = 85796c70c99bc39295bf685061056f06ab8949c742David Brown (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1); 86796c70c99bc39295bf685061056f06ab8949c742David Brown private static final boolean VDBG = (PhoneApp.DBG_LEVEL >= 2); 87b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 88b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Message codes; see mHandler below. 89b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_ABSENT = 1; 90b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_LOCKED = 2; 91b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_NETWORK_LOCKED = 3; 92b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_WIRED_HEADSET_PLUG = 7; 93b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_STATE_CHANGED = 8; 948bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project private static final int EVENT_UPDATE_INCALL_NOTIFICATION = 9; 954079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10; 964079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project private static final int EVENT_DATA_ROAMING_OK = 11; 97404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12; 98b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 99b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The MMI codes are also used by the InCallScreen. 1004079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project public static final int MMI_INITIATE = 51; 1014079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project public static final int MMI_COMPLETE = 52; 1024079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project public static final int MMI_CANCEL = 53; 103b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Don't use message codes larger than 99 here; those are reserved for 104b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the individual Activities of the Phone UI. 105b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 106b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 107b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Allowable values for the poke lock code (timeout between a user activity and the 108b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * going to sleep), please refer to {@link com.android.server.PowerManagerService} 109b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * for additional reference. 110b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * SHORT uses the short delay for the timeout (SHORT_KEYLIGHT_DELAY, 6 sec) 111b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * MEDIUM uses the medium delay for the timeout (MEDIUM_KEYLIGHT_DELAY, 15 sec) 112b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * DEFAULT is the system-wide default delay for the timeout (1 min) 113b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 114b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public enum ScreenTimeoutDuration { 115b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project SHORT, 116b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project MEDIUM, 117b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project DEFAULT 118b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 119b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 120b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 121b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Allowable values for the wake lock code. 122b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * SLEEP means the device can be put to sleep. 123b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * PARTIAL means wake the processor, but we display can be kept off. 124b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * FULL means wake both the processor and the display. 125b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 126b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public enum WakeState { 127b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project SLEEP, 128b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PARTIAL, 129b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project FULL 130b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 131b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 132b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static PhoneApp sMe; 133b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 134b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // A few important fields we expose to the rest of the package 135b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // directly (rather than thru set/get methods) for efficiency. 136b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Phone phone; 137b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project CallNotifier notifier; 138b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Ringer ringer; 139b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project BluetoothHandsfree mBtHandsfree; 140b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneInterfaceManager phoneMgr; 1418bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project int mBluetoothHeadsetState = BluetoothHeadset.STATE_ERROR; 1424b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project int mBluetoothHeadsetAudioState = BluetoothHeadset.STATE_ERROR; 1438bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project boolean mShowBluetoothIndication = false; 144b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1450fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // Internal PhoneApp Call state tracker 1460fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville CdmaPhoneCallState cdmaPhoneCallState; 1470fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville 148b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The InCallScreen instance (or null if the InCallScreen hasn't been 149b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // created yet.) 150b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private InCallScreen mInCallScreen; 151b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 152b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The currently-active PUK entry activity and progress dialog. 153b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Normally, these are the Emergency Dialer and the subsequent 154b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // progress dialog. null if there is are no such objects in 155b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the foreground. 156b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private Activity mPUKEntryActivity; 157b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private ProgressDialog mPUKEntryProgressDialog; 158b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 159b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private boolean mIsSimPinEnabled; 160b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private String mCachedSimPin; 161b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 162b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if a wired headset is currently plugged in, based on the state 163b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // from the latest Intent.ACTION_HEADSET_PLUG broadcast we received in 164b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // mReceiver.onReceive(). 165b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private boolean mIsHeadsetPlugged; 166b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 167d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // True if the keyboard is currently *not* hidden 168d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Gets updated whenever there is a Configuration change 169d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai private boolean mIsHardKeyboardOpen; 170d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 171445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // True if we are beginning a call, but the phone state has not changed yet 172445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood private boolean mBeginningCall; 173445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 174445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // Last phone state seen by updatePhoneState() 175445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood Phone.State mLastPhoneState = Phone.State.IDLE; 176445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 177b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private WakeState mWakeState = WakeState.SLEEP; 1784472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown private ScreenTimeoutDuration mScreenTimeoutDuration = ScreenTimeoutDuration.DEFAULT; 1794472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown private boolean mIgnoreTouchUserActivity = false; 180b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private IBinder mPokeLockToken = new Binder(); 181b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private IPowerManager mPowerManagerService; 182b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private PowerManager.WakeLock mWakeLock; 183b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private PowerManager.WakeLock mPartialWakeLock; 18458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown private PowerManager.WakeLock mProximityWakeLock; 185b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private KeyguardManager mKeyguardManager; 186b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private KeyguardManager.KeyguardLock mKeyguardLock; 187b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 188b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Broadcast receiver for various intent broadcasts (see onCreate()) 189b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver(); 190b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 191b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Broadcast receiver purely for ACTION_MEDIA_BUTTON broadcasts 192b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private final BroadcastReceiver mMediaButtonReceiver = new MediaButtonBroadcastReceiver(); 193b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 194b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** boolean indicating restoring mute state on InCallScreen.onResume() */ 195b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private boolean mShouldRestoreMuteOnInCallResume; 196b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 197af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // Following are the CDMA OTA information Objects used during OTA Call. 198af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // cdmaOtaProvisionData object store static OTA information that needs 199af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // to be maintained even during Slider open/close scenarios. 200af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // cdmaOtaConfigData object stores configuration info to control visiblity 201af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // of each OTA Screens. 202af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // cdmaOtaScreenState object store OTA Screen State information. 203af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public OtaUtils.CdmaOtaProvisionData cdmaOtaProvisionData; 204af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public OtaUtils.CdmaOtaConfigData cdmaOtaConfigData; 205af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public OtaUtils.CdmaOtaScreenState cdmaOtaScreenState; 206af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 207b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 208b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Set the restore mute state flag. Used when we are setting the mute state 209b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * OUTSIDE of user interaction {@link PhoneUtils#startNewCall(Phone)} 210b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 211b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /*package*/void setRestoreMuteOnInCallResume (boolean mode) { 212b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mShouldRestoreMuteOnInCallResume = mode; 213b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 214b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 215b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 216b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Get the restore mute state flag. 217b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This is used by the InCallScreen {@link InCallScreen#onResume()} to figure 218b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * out if we need to restore the mute state for the current active call. 219b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 220b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /*package*/boolean getRestoreMuteOnInCallResume () { 221b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mShouldRestoreMuteOnInCallResume; 222b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 223b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 224b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Handler mHandler = new Handler() { 225b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 226b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void handleMessage(Message msg) { 227b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project switch (msg.what) { 228b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_LOCKED: 229b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// mIsSimPinEnabled = true; 230b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// 231b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// if (Config.LOGV) Log.v(LOG_TAG, "show sim unlock panel"); 232b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// SimPinUnlockPanel pinUnlockPanel = new SimPinUnlockPanel( 233b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// PhoneApp.getInstance()); 234b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// pinUnlockPanel.show(); 235b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 236b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 237b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_ABSENT: 238b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// Don't need this now that the lock screen handles this case 239b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// if (Config.LOGV) Log.v(LOG_TAG, "show sim missing panel"); 240b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// SimMissingPanel missingPanel = new SimMissingPanel( 241b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// PhoneApp.getInstance()); 242b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// missingPanel.show(); 243b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 244b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 245b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_NETWORK_LOCKED: 24609328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown if (getResources().getBoolean(R.bool.ignore_sim_network_locked_events)) { 24709328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // Some products don't have the concept of a "SIM network lock" 24809328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; " 24909328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown + "not showing 'SIM network unlock' PIN entry screen"); 25009328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown } else { 25109328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // Normal case: show the "SIM network unlock" PIN entry screen. 25209328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // The user won't be able to do anything else until 25309328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // they enter a valid SIM network PIN. 25409328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown Log.i(LOG_TAG, "show sim depersonal panel"); 25509328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown IccNetworkDepersonalizationPanel ndpPanel = 25609328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown new IccNetworkDepersonalizationPanel(PhoneApp.getInstance()); 25709328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown ndpPanel.show(); 25809328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown } 259b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 260b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 2618bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project case EVENT_UPDATE_INCALL_NOTIFICATION: 2628bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // Tell the NotificationMgr to update the "ongoing 2638bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // call" icon in the status bar, if necessary. 2648bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // Currently, this is triggered by a bluetooth headset 2658bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // state change (since the status bar icon needs to 2668bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // turn blue when bluetooth is active.) 2678bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project NotificationMgr.getDefault().updateInCallNotification(); 2688bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project break; 2698bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 2704079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project case EVENT_DATA_ROAMING_DISCONNECTED: 2714079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project NotificationMgr.getDefault().showDataDisconnectedRoaming(); 272b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 2734079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project 2744079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project case EVENT_DATA_ROAMING_OK: 2754079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project NotificationMgr.getDefault().hideDataDisconnectedRoaming(); 2764079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project break; 2774079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project 278b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case MMI_COMPLETE: 279b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project onMMIComplete((AsyncResult) msg.obj); 280b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 281b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 282b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case MMI_CANCEL: 283b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.cancelMmiCode(phone); 284b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 285b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 286b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_WIRED_HEADSET_PLUG: 287b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Since the presence of a wired headset or bluetooth affects the 288b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // speakerphone, update the "speaker" state. We ONLY want to do 289b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // this on the wired headset connect / disconnect events for now 290b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // though, so we're only triggering on EVENT_WIRED_HEADSET_PLUG. 291425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent // If in call screen is showing, let InCallScreen handle the speaker. 292425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent if (!isShowingCallScreen() && 293425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent (mBtHandsfree == null || !mBtHandsfree.isAudioOn())) { 294425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent if (!isHeadsetPlugged()) { 295425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent // if the state is "not connected", restore the speaker state. 296425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent PhoneUtils.restoreSpeakerMode(getApplicationContext()); 297425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent } else { 29899d10538d840f0103c36dafa44db9f649ca884c8johnwang // if the state is "connected", force the speaker off without 299425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent // storing the state. 300425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent PhoneUtils.turnOnSpeaker(getApplicationContext(), false, false); 301425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent } 302b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 303d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Update the Proximity sensor based on headset state 304d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai updateProximitySensorMode(phone.getState()); 305b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 306b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 307b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_STATE_CHANGED: 308b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Marks the event where the SIM goes into ready state. 309b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Right now, this is only used for the PUK-unlocking 310b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // process. 311a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville if (msg.obj.equals(IccCard.INTENT_VALUE_ICC_READY)) { 312b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // when the right event is triggered and there 313b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // are UI objects in the foreground, we close 314b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // them to display the lock panel. 315b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPUKEntryActivity != null) { 316b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryActivity.finish(); 317b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryActivity = null; 318b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 319b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPUKEntryProgressDialog != null) { 320b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryProgressDialog.dismiss(); 321b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryProgressDialog = null; 322b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 323b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 324b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 325404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 326404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville case EVENT_UNSOL_CDMA_INFO_RECORD: 327404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville //TODO: handle message here; 328404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville break; 329b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 330b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 331b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project }; 332b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 333b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public PhoneApp() { 334b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sMe = this; 335b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 336b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 337b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 338b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onCreate() { 339b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (Config.LOGV) Log.v(LOG_TAG, "onCreate()..."); 340b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 341b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ContentResolver resolver = getContentResolver(); 342b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 343b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (phone == null) { 344b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Initialize the telephony framework 345b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneFactory.makeDefaultPhones(this); 346b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 347b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Get the default phone 348b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project phone = PhoneFactory.getDefaultPhone(); 349b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 350b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project NotificationMgr.init(this); 351b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 352b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project phoneMgr = new PhoneInterfaceManager(this, phone); 353c9d9ed30aa547b79b81adc13a4d148a003b6ee62w 354c9d9ed30aa547b79b81adc13a4d148a003b6ee62w if (phone.getPhoneName().equals("CDMA")) { 355c9d9ed30aa547b79b81adc13a4d148a003b6ee62w // Create an instance of CdmaPhoneCallState and initialize it to IDLE 356c9d9ed30aa547b79b81adc13a4d148a003b6ee62w cdmaPhoneCallState = new CdmaPhoneCallState(); 357c9d9ed30aa547b79b81adc13a4d148a003b6ee62w cdmaPhoneCallState.CdmaPhoneCallStateInit(); 358c9d9ed30aa547b79b81adc13a4d148a003b6ee62w } 359c9d9ed30aa547b79b81adc13a4d148a003b6ee62w 360b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (getSystemService(Context.BLUETOOTH_SERVICE) != null) { 361b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mBtHandsfree = new BluetoothHandsfree(this, phone); 362b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project startService(new Intent(this, BluetoothHeadsetService.class)); 363b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else { 364b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Device is not bluetooth capable 365b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mBtHandsfree = null; 366b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 367b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 368b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ringer = new Ringer(phone); 369b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 370b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // before registering for phone state changes 371b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 372b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK 373b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | PowerManager.ACQUIRE_CAUSES_WAKEUP 374b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | PowerManager.ON_AFTER_RELEASE, LOG_TAG); 375b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // lock used to keep the processor awake, when we don't care for the display. 376b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK 377b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | PowerManager.ON_AFTER_RELEASE, LOG_TAG); 37858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // Wake lock used to control proximity sensor behavior. 37958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if ((pm.getSupportedWakeLockFlags() 38058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown & PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) != 0x0) { 38158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown mProximityWakeLock = 38258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, LOG_TAG); 38358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 38458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (DBG) Log.d(LOG_TAG, "mProximityWakeLock: " + mProximityWakeLock); 38558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown 386b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 387b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardLock = mKeyguardManager.newKeyguardLock(LOG_TAG); 388b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 389b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // get a handle to the service so that we can use it later when we 390b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // want to set the poke lock. 391b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService = IPowerManager.Stub.asInterface( 392b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ServiceManager.getService("power")); 393b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 394b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project notifier = new CallNotifier(this, phone, ringer, mBtHandsfree); 395b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 396a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville // register for ICC status 397a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville IccCard sim = phone.getIccCard(); 398b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (sim != null) { 399a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville if (Config.LOGV) Log.v(LOG_TAG, "register for ICC status"); 400b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null); 401b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null); 402b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null); 403b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 404b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 405b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // register for MMI/USSD 406fa3fbeedf018e40f8d6696a382bbf316219cf4aeReli Tal if (phone.getPhoneName().equals("GSM")) { 407fa3fbeedf018e40f8d6696a382bbf316219cf4aeReli Tal phone.registerForMmiComplete(mHandler, MMI_COMPLETE, null); 408fa3fbeedf018e40f8d6696a382bbf316219cf4aeReli Tal } 409b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 410b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // register connection tracking to PhoneUtils 411b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.initializeConnectionHandler(phone); 412b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 413b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Register for misc other intent broadcasts. 414b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project IntentFilter intentFilter = 415b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED); 416b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION); 4174b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project intentFilter.addAction(BluetoothIntent.HEADSET_AUDIO_STATE_CHANGED_ACTION); 418b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); 419b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(Intent.ACTION_HEADSET_PLUG); 420b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(Intent.ACTION_BATTERY_LOW); 421b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); 422a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED); 423404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); 424abeff00b5242e795baa8f5271525c5911f649993Wink Saville intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); 425b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project registerReceiver(mReceiver, intentFilter); 426b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 427b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Use a separate receiver for ACTION_MEDIA_BUTTON broadcasts, 428b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // since we need to manually adjust its priority (to make sure 429b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // we get these intents *before* the media player.) 430b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project IntentFilter mediaButtonIntentFilter = 431b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project new IntentFilter(Intent.ACTION_MEDIA_BUTTON); 432b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 433b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Make sure we're higher priority than the media player's 434b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // MediaButtonIntentReceiver (which currently has the default 435b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // priority of zero; see apps/Music/AndroidManifest.xml.) 436b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mediaButtonIntentFilter.setPriority(1); 437b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 438b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project registerReceiver(mMediaButtonReceiver, mediaButtonIntentFilter); 439b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 440b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project //set the default values for the preferences in the phone. 441b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PreferenceManager.setDefaultValues(this, R.xml.network_setting, false); 442cd0189299f484dcbd51400b994daf585923e9e8dDavid Krause 443cd0189299f484dcbd51400b994daf585923e9e8dDavid Krause PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false); 444b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 445b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Make sure the audio mode (along with some 446b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // audio-mode-related state of our own) is initialized 447b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // correctly, given the current state of the phone. 448b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project switch (phone.getState()) { 449b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case IDLE: 450b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: IDLE"); 451b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_IDLE); 452b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioMode(this, AudioManager.MODE_NORMAL); 453b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 454b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case RINGING: 455b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: RINGING"); 456b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_RINGING); 457b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioMode(this, AudioManager.MODE_RINGTONE); 458b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 459b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case OFFHOOK: 460b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: OFFHOOK"); 461b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_OFFHOOK); 462b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioMode(this, AudioManager.MODE_IN_CALL); 463b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 464b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 465b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 466b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 467af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (phone.getPhoneName().equals("CDMA")) { 468af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData(); 469af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData(); 470af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState(); 471af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 472af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 473b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // XXX pre-load the SimProvider so that it's ready 474a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville resolver.getType(Uri.parse("content://icc/adn")); 475b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 476b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // start with the default value to set the mute state. 477b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mShouldRestoreMuteOnInCallResume = false; 478404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 4790fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // Register for Cdma Information Records 4800fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // TODO(Moto): Merge 4810fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null); 4820fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville 4837fe7f7e57aaa38290c37ab48867d34a279d198f3w // Read TTY settings and store it into BP NV. 4847fe7f7e57aaa38290c37ab48867d34a279d198f3w // AP owns (i.e. stores) the TTY setting in AP settings database and pushes the setting 4857fe7f7e57aaa38290c37ab48867d34a279d198f3w // to BP at power up (BP does not need to make the TTY setting persistent storage). 4867fe7f7e57aaa38290c37ab48867d34a279d198f3w // This way, there is a single owner (i.e AP) for the TTY setting in the phone. 4877fe7f7e57aaa38290c37ab48867d34a279d198f3w if (phone.getPhoneName().equals("CDMA")) { 4887fe7f7e57aaa38290c37ab48867d34a279d198f3w int settingsTtyMode = android.provider.Settings.Secure.getInt( 4897fe7f7e57aaa38290c37ab48867d34a279d198f3w phone.getContext().getContentResolver(), 4907fe7f7e57aaa38290c37ab48867d34a279d198f3w android.provider.Settings.Secure.PREFERRED_TTY_MODE, 4917fe7f7e57aaa38290c37ab48867d34a279d198f3w Phone.TTY_MODE_OFF); 4927fe7f7e57aaa38290c37ab48867d34a279d198f3w phone.setTTYMode(settingsTtyMode, null); 4937fe7f7e57aaa38290c37ab48867d34a279d198f3w } 494b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 495b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 496d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai @Override 497d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai public void onConfigurationChanged(Configuration newConfig) { 498d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { 499d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai mIsHardKeyboardOpen = true; 500d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai } else { 501d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai mIsHardKeyboardOpen = false; 502d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai } 503d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 504d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Update the Proximity sensor based on keyboard state 505d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai updateProximitySensorMode(phone.getState()); 506d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai super.onConfigurationChanged(newConfig); 507d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai } 508d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 509b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 510b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Returns the singleton instance of the PhoneApp. 511b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 512b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project static PhoneApp getInstance() { 513b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return sMe; 514b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 515b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 516b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Ringer getRinger() { 517b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return ringer; 518b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 519b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 520b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project BluetoothHandsfree getBluetoothHandsfree() { 521b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mBtHandsfree; 522b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 523b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 524b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project static Intent createCallLogIntent() { 525b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Intent intent = new Intent(Intent.ACTION_VIEW, null); 526b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.setType("vnd.android.cursor.dir/calls"); 527b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return intent; 528b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 529b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 530b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 531b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Return an Intent that can be used to bring up the in-call screen. 532b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 533b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This intent can only be used from within the Phone app, since the 534b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * InCallScreen is not exported from our AndroidManifest. 535b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 536b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ static Intent createInCallIntent() { 537b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Intent intent = new Intent(Intent.ACTION_MAIN, null); 538b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 539b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS 540b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | Intent.FLAG_ACTIVITY_NO_USER_ACTION); 541b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.setClassName("com.android.phone", getCallScreenClassName()); 542b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return intent; 543b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 544b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 545b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 546b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Variation of createInCallIntent() that also specifies whether the 547b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * DTMF dialpad should be initially visible when the InCallScreen 548b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * comes up. 549b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 550b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ static Intent createInCallIntent(boolean showDialpad) { 551b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Intent intent = createInCallIntent(); 552b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.putExtra(InCallScreen.SHOW_DIALPAD_EXTRA, showDialpad); 553b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return intent; 554b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 555b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 556b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project static String getCallScreenClassName() { 557b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return InCallScreen.class.getName(); 558b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 559b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 560b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 561b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Starts the InCallScreen Activity. 562b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 563b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void displayCallScreen() { 564796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "displayCallScreen()..."); 565b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project startActivity(createInCallIntent()); 566b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Profiler.callScreenRequested(); 567b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 568b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 569b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 570b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Helper function to check for one special feature of the CALL key: 571b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Normally, when the phone is idle, CALL takes you to the call log 572b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * (see the handler for KEYCODE_CALL in PhoneWindow.onKeyUp().) 573b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * But if the phone is in use (either off-hook or ringing) we instead 574b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * handle the CALL button by taking you to the in-call UI. 575b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 576b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @return true if we intercepted the CALL keypress (i.e. the phone 577b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * was in use) 578b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 579b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @see DialerActivity#onCreate 580b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 581b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean handleInCallOrRinging() { 582b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (phone.getState() != Phone.State.IDLE) { 583b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Phone is OFFHOOK or RINGING. 584b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.v(LOG_TAG, 585b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project "handleInCallOrRinging: show call screen"); 586b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project displayCallScreen(); 587b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return true; 588b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 589b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return false; 590b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 591b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 592b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isSimPinEnabled() { 593b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mIsSimPinEnabled; 594b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 595b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 596b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean authenticateAgainstCachedSimPin(String pin) { 597b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return (mCachedSimPin != null && mCachedSimPin.equals(pin)); 598b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 599b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 600b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setCachedSimPin(String pin) { 601b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mCachedSimPin = pin; 602b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 603b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 604b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setInCallScreenInstance(InCallScreen inCallScreen) { 605b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mInCallScreen = inCallScreen; 606b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 607b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 608b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 609b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @return true if the in-call UI is running as the foreground 610b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * activity. (In other words, from the perspective of the 611b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * InCallScreen activity, return true between onResume() and 612b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * onPause().) 613b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 614b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Note this method will return false if the screen is currently off, 615b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * even if the InCallScreen *was* in the foreground just before the 616b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * screen turned off. (This is because the foreground activity is 617b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * always "paused" while the screen is off.) 618b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 619b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isShowingCallScreen() { 620b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mInCallScreen == null) return false; 621b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mInCallScreen.isForegroundActivity(); 622b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 623b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 624b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 625b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Dismisses the in-call UI. 626b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 627b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This also ensures that you won't be able to get back to the in-call 628b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * UI via the BACK button (since this call removes the InCallScreen 629b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * from the activity history.) 630af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * For OTA Call, it call InCallScreen api to handle OTA Call End scenario 631af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * to display OTA Call End screen. 632b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 633b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void dismissCallScreen() { 634b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mInCallScreen != null) { 6356bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai if (mInCallScreen.isOtaCallInActiveState() 6366bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai || mInCallScreen.isOtaCallInEndState() 6376bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai || ((cdmaOtaScreenState != null) 6386bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai && (cdmaOtaScreenState.otaScreenState 6396bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai != CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED))) { 640af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // TODO(Moto): During OTA Call, display should not become dark to 641af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // allow user to see OTA UI update. Phone app needs to hold a SCREEN_DIM_WAKE_LOCK 642af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // wake lock during the entire OTA call. 643af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville wakeUpScreen(); 6446bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai // If InCallScreen is not in foreground we resume it to show the OTA call end screen 6456bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai // Fire off the InCallScreen intent 6466bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai displayCallScreen(); 6476bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai 648af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville mInCallScreen.handleOtaCallEnd(); 649af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville return; 650af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } else { 651af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville mInCallScreen.finish(); 652af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 653b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 654b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 655b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 656b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 657af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Handle OTA events 658af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * 659af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * When OTA call is active and display becomes dark, then CallNotifier will 660af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * handle OTA Events by calling this api which then calls OtaUtil function. 661af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville */ 662af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville void handleOtaEvents(Message msg) { 663af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 664af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (DBG) Log.d(LOG_TAG, "Enter handleOtaEvents"); 665af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if ((mInCallScreen != null) && (!isShowingCallScreen())) { 666af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (mInCallScreen.otaUtils != null) { 667af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville mInCallScreen.otaUtils.onOtaProvisionStatusChanged((AsyncResult) msg.obj); 668af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 669af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 670af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 671af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 672af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 673af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville /** 674b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Sets the activity responsible for un-PUK-blocking the device 675b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * so that we may close it when we receive a positive result. 676b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * mPUKEntryActivity is also used to indicate to the device that 677b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * we are trying to un-PUK-lock the phone. In other words, iff 678b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * it is NOT null, then we are trying to unlock and waiting for 679b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * the SIM to move to READY state. 680b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 681b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param activity is the activity to close when PUK has 682b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * finished unlocking. Can be set to null to indicate the unlock 683b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * or SIM READYing process is over. 684b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 685b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setPukEntryActivity(Activity activity) { 686b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryActivity = activity; 687b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 688b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 689b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Activity getPUKEntryActivity() { 690b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mPUKEntryActivity; 691b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 692b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 693b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 694b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Sets the dialog responsible for notifying the user of un-PUK- 695b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * blocking - SIM READYing progress, so that we may dismiss it 696b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * when we receive a positive result. 697b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 698b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param dialog indicates the progress dialog informing the user 699b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * of the state of the device. Dismissed upon completion of 700b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * READYing process 701b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 702b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setPukEntryProgressDialog(ProgressDialog dialog) { 703b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryProgressDialog = dialog; 704b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 705b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 706b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ProgressDialog getPUKEntryProgressDialog() { 707b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mPUKEntryProgressDialog; 708b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 709b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 710b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 711b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Disables the keyguard. This is used by the phone app to allow 712b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * interaction with the Phone UI when the keyguard would otherwise be 713b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * active (like receiving an incoming call while the device is 714b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * locked.) 715b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 716b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Any call to this method MUST be followed (eventually) 717b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * by a corresponding reenableKeyguard() call. 718b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 719b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void disableKeyguard() { 720b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "disable keyguard"); 721b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // if (DBG) Log.d(LOG_TAG, "disableKeyguard()...", new Throwable("stack dump")); 722b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardLock.disableKeyguard(); 723b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 724b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 725b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 726b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Re-enables the keyguard after a previous disableKeyguard() call. 727b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 728b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Any call to this method MUST correspond to (i.e. be balanced with) 729b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * a previous disableKeyguard() call. 730b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 731b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void reenableKeyguard() { 732b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "re-enable keyguard"); 733b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // if (DBG) Log.d(LOG_TAG, "reenableKeyguard()...", new Throwable("stack dump")); 734b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardLock.reenableKeyguard(); 735b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 736b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 737b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 738b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Controls how quickly the screen times out. 739b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 740b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * The poke lock controls how long it takes before the screen powers 741b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * down, and therefore has no immediate effect when the current 742b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * WakeState (see {@link PhoneApp#requestWakeState}) is FULL. 743b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * If we're in a state where the screen *is* allowed to turn off, 744b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * though, the poke lock will determine the timeout interval (long or 745b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * short). 746b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 747b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param shortPokeLock tells the device the timeout duration to use 748b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * before going to sleep 749b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * {@link com.android.server.PowerManagerService#SHORT_KEYLIGHT_DELAY}. 750b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 751b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void setScreenTimeout(ScreenTimeoutDuration duration) { 752796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "setScreenTimeout(" + duration + ")..."); 753b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 754b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // make sure we don't set the poke lock repeatedly so that we 755b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // avoid triggering the userActivity calls in 756b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // PowerManagerService.setPokeLock(). 7574472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (duration == mScreenTimeoutDuration) { 758b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return; 759b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 760039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood // stick with default timeout if we are using the proximity sensor 761039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood if (proximitySensorModeEnabled()) { 762039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood return; 763039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood } 7644472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown mScreenTimeoutDuration = duration; 7654472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown updatePokeLock(); 7664472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 767b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 7684472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /** 7694472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Update the state of the poke lock held by the phone app, 7704472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * based on the current desired screen timeout and the 7714472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * current "ignore user activity on touch" flag. 7724472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown */ 7734472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown private void updatePokeLock() { 774b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // This is kind of convoluted, but the basic thing to remember is 775b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // that the poke lock just sends a message to the screen to tell 776b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // it to stay on for a while. 777b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The default is 0, for a long timeout and should be set that way 778b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // when we are heading back into a the keyguard / screen off 779b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // state, and also when we're trying to keep the screen alive 780b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // while ringing. We'll also want to ignore the cheek events 781b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // regardless of the timeout duration. 782b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The short timeout is really used whenever we want to give up 783b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the screen lock, such as when we're in call. 784b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project int pokeLockSetting = LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS; 7854472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown switch (mScreenTimeoutDuration) { 786b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case SHORT: 787b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Set the poke lock to timeout the display after a short 788b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // timeout (5s). This ensures that the screen goes to sleep 789b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // as soon as acceptably possible after we the wake lock 790b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // has been released. 791b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project pokeLockSetting |= LocalPowerManager.POKE_LOCK_SHORT_TIMEOUT; 792b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 793b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 794b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case MEDIUM: 795b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Set the poke lock to timeout the display after a medium 796b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // timeout (15s). This ensures that the screen goes to sleep 797b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // as soon as acceptably possible after we the wake lock 798b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // has been released. 799b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project pokeLockSetting |= LocalPowerManager.POKE_LOCK_MEDIUM_TIMEOUT; 800b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 801b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 802b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case DEFAULT: 803b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project default: 804b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // set the poke lock to timeout the display after a long 805b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // delay by default. 806b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // TODO: it may be nice to be able to disable cheek presses 807b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // for long poke locks (emergency dialer, for instance). 808b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 809b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 810b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 8114472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (mIgnoreTouchUserActivity) { 8124472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown pokeLockSetting |= LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS; 8134472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 8144472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown 815b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Send the request 816b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project try { 817b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService.setPokeLock(pokeLockSetting, mPokeLockToken, LOG_TAG); 818b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } catch (RemoteException e) { 8194472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown Log.w(LOG_TAG, "mPowerManagerService.setPokeLock() failed: " + e); 820b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 821b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 822b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 823b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 824b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Controls whether or not the screen is allowed to sleep. 825b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 826b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Once sleep is allowed (WakeState is SLEEP), it will rely on the 827b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * settings for the poke lock to determine when to timeout and let 828b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * the device sleep {@link PhoneApp#setScreenTimeout}. 829b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 830b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param ws tells the device to how to wake. 831b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 832b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void requestWakeState(WakeState ws) { 833796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "requestWakeState(" + ws + ")..."); 834b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeState != ws) { 835b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project switch (ws) { 836b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case PARTIAL: 837b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // acquire the processor wake lock, and release the FULL 838b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // lock if it is being held. 839b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock.acquire(); 840b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeLock.isHeld()) { 841b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock.release(); 842b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 843b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 844b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case FULL: 845b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // acquire the full wake lock, and release the PARTIAL 846b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // lock if it is being held. 847b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock.acquire(); 848b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPartialWakeLock.isHeld()) { 849b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock.release(); 850b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 851b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 852b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case SLEEP: 853b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project default: 854b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // release both the PARTIAL and FULL locks. 855b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeLock.isHeld()) { 856b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock.release(); 857b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 858b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPartialWakeLock.isHeld()) { 859b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock.release(); 860b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 861b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 862b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 863b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeState = ws; 864b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 865b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 866b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 867b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 868b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * If we are not currently keeping the screen on, then poke the power 869b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * manager to wake up the screen for the user activity timeout duration. 870b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 871b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void wakeUpScreen() { 872b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeState == WakeState.SLEEP) { 873b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "pulse screen lock"); 874b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project try { 875b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService.userActivityWithForce(SystemClock.uptimeMillis(), false, true); 876b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } catch (RemoteException ex) { 877b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Ignore -- the system process is dead. 878b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 879b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 880b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 881b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 882b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 883b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Sets the wake state and screen timeout based on the current state 884b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * of the phone, and the current state of the in-call UI. 885b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 886b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This method is a "UI Policy" wrapper around 887b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * {@link PhoneApp#requestWakeState} and {@link PhoneApp#setScreenTimeout}. 888b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 889b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * It's safe to call this method regardless of the state of the Phone 890b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * (e.g. whether or not it's idle), and regardless of the state of the 891b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Phone UI (e.g. whether or not the InCallScreen is active.) 892b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 893b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void updateWakeState() { 894b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Phone.State state = phone.getState(); 895b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 896b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if the in-call UI is the foreground activity. 897b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (Note this will be false if the screen is currently off, 898b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // since in that case *no* activity is in the foreground.) 899b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isShowingCallScreen = isShowingCallScreen(); 900b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 901b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if the InCallScreen's DTMF dialer is currently opened. 902b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (Note this does NOT imply whether or not the InCallScreen 903b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // itself is visible.) 904b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isDialerOpened = (mInCallScreen != null) && mInCallScreen.isDialerOpened(); 905b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 906b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if the speakerphone is in use. (If so, we *always* use 907b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the default timeout. Since the user is obviously not holding 908b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the phone up to his/her face, we don't need to worry about 909b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // false touches, and thus don't need to turn the screen off so 910b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // aggressively.) 911b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Note that we need to make a fresh call to this method any 912b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // time the speaker state changes. (That happens in 913b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // PhoneUtils.turnOnSpeaker().) 914b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isSpeakerInUse = (state == Phone.State.OFFHOOK) && PhoneUtils.isSpeakerOn(this); 915b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 916b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // TODO (bug 1440854): The screen timeout *might* also need to 917b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // depend on the bluetooth state, but this isn't as clear-cut as 918b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the speaker state (since while using BT it's common for the 919b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // user to put the phone straight into a pocket, in which case the 920b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // timeout should probably still be short.) 921b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 922796c70c99bc39295bf685061056f06ab8949c742David Brown if (DBG) Log.d(LOG_TAG, "updateWakeState: callscreen " + isShowingCallScreen 923796c70c99bc39295bf685061056f06ab8949c742David Brown + ", dialer " + isDialerOpened 924796c70c99bc39295bf685061056f06ab8949c742David Brown + ", speaker " + isSpeakerInUse + "..."); 925b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 926b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 927b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (1) Set the screen timeout. 928b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 929b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Note that the "screen timeout" value we determine here is 930b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // meaningless if the screen is forced on (see (2) below.) 931b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 932b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (!isShowingCallScreen || isSpeakerInUse) { 933b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Use the system-wide default timeout. 934b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setScreenTimeout(ScreenTimeoutDuration.DEFAULT); 935b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else { 936b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // We're on the in-call screen, and *not* using the speakerphone. 937b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (isDialerOpened) { 938b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The DTMF dialpad is up. This case is special because 939b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the in-call UI has its own "touch lock" mechanism to 940b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // disable the dialpad after a very short amount of idle 941b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // time (to avoid false touches from the user's face while 942b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // in-call.) 943b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 944b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // In this case the *physical* screen just uses the 945b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // system-wide default timeout. 946b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setScreenTimeout(ScreenTimeoutDuration.DEFAULT); 947b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else { 948b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // We're on the in-call screen, and not using the DTMF dialpad. 949b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // There's actually no touchable UI onscreen at all in 950b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // this state. Also, the user is (most likely) not 951b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // looking at the screen at all, since they're probably 952b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // holding the phone up to their face. Here we use a 953b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // special screen timeout value specific to the in-call 954b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // screen, purely to save battery life. 955b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setScreenTimeout(ScreenTimeoutDuration.MEDIUM); 956b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 957b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 958b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 959b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 960b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (2) Decide whether to force the screen on or not. 961b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 962ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown // Force the screen to be on if the phone is ringing or dialing, 963ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown // or if we're displaying the "Call ended" UI for a connection in 964ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown // the "disconnected" state. 965b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 966b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isRinging = (state == Phone.State.RINGING); 967ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown boolean isDialing = (phone.getForegroundCall().getState() == Call.State.DIALING); 968b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean showingDisconnectedConnection = 969b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.hasDisconnectedConnections(phone) && isShowingCallScreen; 970ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown boolean keepScreenOn = isRinging || isDialing || showingDisconnectedConnection; 971b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "updateWakeState: keepScreenOn = " + keepScreenOn 972b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project + " (isRinging " + isRinging 973ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown + ", isDialing " + isDialing 974796c70c99bc39295bf685061056f06ab8949c742David Brown + ", showingDisc " + showingDisconnectedConnection + ")"); 975b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // keepScreenOn == true means we'll hold a full wake lock: 976b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP); 977b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 978b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 979b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 980b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Wrapper around the PowerManagerService.preventScreenOn() API. 981b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This allows the in-call UI to prevent the screen from turning on 982b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * even if a subsequent call to updateWakeState() causes us to acquire 983b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * a full wake lock. 984b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 985b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void preventScreenOn(boolean prevent) { 986796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "- preventScreenOn(" + prevent + ")..."); 987b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project try { 988b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService.preventScreenOn(prevent); 989b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } catch (RemoteException e) { 990b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Log.w(LOG_TAG, "mPowerManagerService.preventScreenOn() failed: " + e); 991b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 992b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 993b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 9944472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /** 9954472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Sets or clears the flag that tells the PowerManager that touch 9964472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * (and cheek) events should NOT be considered "user activity". 9974472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * 9984472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Since the in-call UI is totally insensitive to touch in most 9994472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * states, we set this flag whenever the InCallScreen is in the 10004472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * foreground. (Otherwise, repeated unintentional touches could 10014472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * prevent the device from going to sleep.) 10024472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * 10034472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * There *are* some some touch events that really do count as user 10044472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * activity, though. For those, we need to manually poke the 10054472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * PowerManager's userActivity method; see pokeUserActivity(). 10064472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown */ 10074472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /* package */ void setIgnoreTouchUserActivity(boolean ignore) { 10084472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (VDBG) Log.d(LOG_TAG, "setIgnoreTouchUserActivity(" + ignore + ")..."); 10094472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown mIgnoreTouchUserActivity = ignore; 10104472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown updatePokeLock(); 10114472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 10124472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown 10134472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /** 10144472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Manually pokes the PowerManager's userActivity method. Since we 10154472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * hold the POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS poke lock while 10164472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * the InCallScreen is active, we need to do this for touch events 10174472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * that really do count as user activity (like DTMF key presses, or 10184472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * unlocking the "touch lock" overlay.) 10194472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown */ 10204472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /* package */ void pokeUserActivity() { 10214472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (VDBG) Log.d(LOG_TAG, "pokeUserActivity()..."); 10224472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown try { 10234472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown mPowerManagerService.userActivity(SystemClock.uptimeMillis(), false); 10244472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } catch (RemoteException e) { 10254472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown Log.w(LOG_TAG, "mPowerManagerService.userActivity() failed: " + e); 10264472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 10274472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 10284472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown 102958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown /** 1030445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Set when a new outgoing call is beginning, so we can update 1031445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * the proximity sensor state. 1032445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Cleared when the InCallScreen is no longer in the foreground, 1033445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * in case the call fails without changing the telephony state. 1034445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood */ 1035445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /* package */ void setBeginningCall(boolean beginning) { 1036445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // Note that we are beginning a new call, for proximity sensor support 1037445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood mBeginningCall = beginning; 1038445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // Update the Proximity sensor based on mBeginningCall state 1039445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood updateProximitySensorMode(phone.getState()); 1040445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood } 1041445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 1042445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /** 104358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * Updates the wake lock used to control proximity sensor behavior, 104458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * based on the current state of the phone. This method is called 104558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * from the CallNotifier on any phone state change. 104658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 104758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * On devices that have a proximity sensor, to avoid false touches 104858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * during a call, we hold a PROXIMITY_SCREEN_OFF_WAKE_LOCK wake lock 104958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * whenever the phone is off hook. (When held, that wake lock causes 105058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * the screen to turn off automatically when the sensor detects an 105158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * object close to the screen.) 105258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 105358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * This method is a no-op for devices that don't have a proximity 105458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * sensor. 105558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 105658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * Note this method doesn't care if the InCallScreen is the foreground 105758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * activity or not. That's because we want the proximity sensor to be 105858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * enabled any time the phone is in use, to avoid false cheek events 105958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * for whatever app you happen to be running. 106058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 1061d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * Proximity wake lock will *not* be held if any one of the 1062d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * conditions is true while on a call: 1063d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 1) If the audio is routed via Bluetooth 1064d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 2) If a wired headset is connected 1065d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 3) if the speaker is ON 1066d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 4) If the slider is open(i.e. the hardkeyboard is *not* hidden) 106758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 106858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * @param state current state of the phone (see {@link Phone#State}) 106958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown */ 107058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown /* package */ void updateProximitySensorMode(Phone.State state) { 1071445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: state = " + state); 1072d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 1073039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood if (proximitySensorModeEnabled()) { 1074445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (((state == Phone.State.OFFHOOK) || mBeginningCall) 1075d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai && !(isHeadsetPlugged() 1076d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai || PhoneUtils.isSpeakerOn(this) 1077d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai || ((mBtHandsfree != null) && mBtHandsfree.isAudioOn()) 1078d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai || mIsHardKeyboardOpen)) { 107958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // Phone is in use! Arrange for the screen to turn off 108058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // automatically when the sensor detects a close object. 108158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (!mProximityWakeLock.isHeld()) { 108258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (DBG) Log.d(LOG_TAG, "updateProximitySensorMode: acquiring..."); 108358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown mProximityWakeLock.acquire(); 1084f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown } else { 1085445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: lock already held."); 108658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 108758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } else { 108858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // Phone is either idle, or ringing. We don't want any 108958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // special proximity sensor behavior in either case. 109058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (mProximityWakeLock.isHeld()) { 109158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (DBG) Log.d(LOG_TAG, "updateProximitySensorMode: releasing..."); 109258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown mProximityWakeLock.release(); 1093f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown } else { 1094445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: lock already released."); 109558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 109658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 109758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 109858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 109958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown 1100f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown /** 1101445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Notifies the phone app when the phone state changes. 1102445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Currently used only for proximity sensor support. 1103445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood */ 1104445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /* package */ void updatePhoneState(Phone.State state) { 1105445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (state != mLastPhoneState) { 1106445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood mLastPhoneState = state; 1107445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood updateProximitySensorMode(state); 1108445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // clear our beginning call flag 1109445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood mBeginningCall = false; 1110445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood } 1111445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood } 1112445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 1113445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /** 1114f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown * @return true if this device supports the "proximity sensor 1115f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown * auto-lock" feature while in-call (see updateProximitySensorMode()). 1116f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown */ 1117f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown /* package */ boolean proximitySensorModeEnabled() { 1118f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown return (mProximityWakeLock != null); 1119f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown } 1120f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown 1121b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project KeyguardManager getKeyguardManager() { 1122b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mKeyguardManager; 1123b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1124b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1125b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private void onMMIComplete(AsyncResult r) { 1126796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "onMMIComplete()..."); 1127b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project MmiCode mmiCode = (MmiCode) r.result; 1128b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.displayMMIComplete(phone, getInstance(), mmiCode, null, null); 1129b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1130b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1131a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville private void initForNewRadioTechnology() { 113287258b2b589c3afea4b89b840251012378e0d3b4David Brown if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology..."); 1133a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 113460877272381161201c6969dea501e683705d6e32w if (phone.getPhoneName().equals("CDMA")) { 113560877272381161201c6969dea501e683705d6e32w // Create an instance of CdmaPhoneCallState and initialize it to IDLE 113660877272381161201c6969dea501e683705d6e32w cdmaPhoneCallState = new CdmaPhoneCallState(); 113760877272381161201c6969dea501e683705d6e32w cdmaPhoneCallState.CdmaPhoneCallStateInit(); 113860877272381161201c6969dea501e683705d6e32w 113960877272381161201c6969dea501e683705d6e32w //create instances of CDMA OTA data classes 114060877272381161201c6969dea501e683705d6e32w if (cdmaOtaProvisionData == null) { 114160877272381161201c6969dea501e683705d6e32w cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData(); 114260877272381161201c6969dea501e683705d6e32w } 114360877272381161201c6969dea501e683705d6e32w if (cdmaOtaConfigData == null) { 114460877272381161201c6969dea501e683705d6e32w cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData(); 114560877272381161201c6969dea501e683705d6e32w } 114660877272381161201c6969dea501e683705d6e32w if (cdmaOtaScreenState == null) { 114760877272381161201c6969dea501e683705d6e32w cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState(); 114860877272381161201c6969dea501e683705d6e32w } 114960877272381161201c6969dea501e683705d6e32w } 115060877272381161201c6969dea501e683705d6e32w 1151a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville ringer.updateRingerContextAfterRadioTechnologyChange(this.phone); 1152a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange(); 115387258b2b589c3afea4b89b840251012378e0d3b4David Brown if (mBtHandsfree != null) { 1154a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville mBtHandsfree.updateBtHandsfreeAfterRadioTechnologyChange(); 1155a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } 115687258b2b589c3afea4b89b840251012378e0d3b4David Brown if (mInCallScreen != null) { 115787258b2b589c3afea4b89b840251012378e0d3b4David Brown mInCallScreen.updateAfterRadioTechnologyChange(); 115887258b2b589c3afea4b89b840251012378e0d3b4David Brown } 1159a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 116087258b2b589c3afea4b89b840251012378e0d3b4David Brown // Update registration for ICC status after radio technology change 1161a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville IccCard sim = phone.getIccCard(); 1162a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville if (sim != null) { 116387258b2b589c3afea4b89b840251012378e0d3b4David Brown if (DBG) Log.d(LOG_TAG, "Update registration for ICC status..."); 1164a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 1165a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville //Register all events new to the new active phone 1166a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null); 1167a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null); 1168a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null); 1169a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } 1170a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } 1171a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 1172404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1173404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville /** 1174b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @return true if a wired headset is currently plugged in. 1175b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 1176b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @see Intent.ACTION_HEADSET_PLUG (which we listen for in mReceiver.onReceive()) 1177b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 1178b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isHeadsetPlugged() { 1179b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mIsHeadsetPlugged; 1180b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1181b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 11828bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /** 11838bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @return true if the onscreen UI should currently be showing the 11848bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * special "bluetooth is active" indication in a couple of places (in 11858bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * which UI elements turn blue and/or show the bluetooth logo.) 11868bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 11878bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * This depends on the BluetoothHeadset state *and* the current 11888bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * telephony state; see shouldShowBluetoothIndication(). 11898bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 11908bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @see CallCard 11918bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @see NotificationMgr.updateInCallNotification 11928bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project */ 11938bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /* package */ boolean showBluetoothIndication() { 11948bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project return mShowBluetoothIndication; 11958bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 11968bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 11978bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /** 11988bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * Recomputes the mShowBluetoothIndication flag based on the current 11998bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * bluetooth state and current telephony state. 12008bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 12018bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * This needs to be called any time the bluetooth headset state or the 12028bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * telephony state changes. 12034b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project * 12044b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project * @param forceUiUpdate if true, force the UI elements that care 12054b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project * about this flag to update themselves. 12068bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project */ 12074b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project /* package */ void updateBluetoothIndication(boolean forceUiUpdate) { 12088bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project mShowBluetoothIndication = shouldShowBluetoothIndication(mBluetoothHeadsetState, 12094b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project mBluetoothHeadsetAudioState, 12108bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project phone); 12114b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project if (forceUiUpdate) { 12124b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // Post Handler messages to the various components that might 12134b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // need to be refreshed based on the new state. 12144b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project if (isShowingCallScreen()) mInCallScreen.updateBluetoothIndication(); 12154b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project mHandler.sendEmptyMessage(EVENT_UPDATE_INCALL_NOTIFICATION); 12164b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project } 1217d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 1218d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Update the Proximity sensor based on Bluetooth audio state 1219d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai updateProximitySensorMode(phone.getState()); 12208bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12218bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12228bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /** 12238bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * UI policy helper function for the couple of places in the UI that 12248bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * have some way of indicating that "bluetooth is in use." 12258bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 12268bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @return true if the onscreen UI should indicate that "bluetooth is in use", 12278bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * based on the specified bluetooth headset state, and the 12288bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * current state of the phone. 12298bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @see showBluetoothIndication() 12308bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project */ 12318bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project private static boolean shouldShowBluetoothIndication(int bluetoothState, 12324b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project int bluetoothAudioState, 12338bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project Phone phone) { 12348bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // We want the UI to indicate that "bluetooth is in use" in two 12358bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // slightly different cases: 12368bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // 12378bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // (a) The obvious case: if a bluetooth headset is currently in 12388bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // use for an ongoing call. 12398bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // 12408bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // (b) The not-so-obvious case: if an incoming call is ringing, 12418bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // and we expect that audio *will* be routed to a bluetooth 12428bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // headset once the call is answered. 12438bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12448bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project switch (phone.getState()) { 12458bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project case OFFHOOK: 12468bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // This covers normal active calls, and also the case if 12474b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // the foreground call is DIALING or ALERTING. In this 12484b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // case, bluetooth is considered "active" if a headset 12494b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // is connected *and* audio is being routed to it. 12504b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project return ((bluetoothState == BluetoothHeadset.STATE_CONNECTED) 12514b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project && (bluetoothAudioState == BluetoothHeadset.AUDIO_STATE_CONNECTED)); 12528bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12538bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project case RINGING: 12548bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // If an incoming call is ringing, we're *not* yet routing 12558bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // audio to the headset (since there's no in-call audio 12568bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // yet!) In this case, if a bluetooth headset is 12578bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // connected at all, we assume that it'll become active 12588bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // once the user answers the phone. 12598bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project return (bluetoothState == BluetoothHeadset.STATE_CONNECTED); 12608bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12618bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project default: // Presumably IDLE 12628bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project return false; 12638bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12648bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12658bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 1266b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1267b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 1268b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Receiver for misc intent broadcasts the Phone app cares about. 1269b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 1270b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private class PhoneAppBroadcastReceiver extends BroadcastReceiver { 1271b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 1272b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onReceive(Context context, Intent intent) { 1273b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project String action = intent.getAction(); 1274b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) { 1275b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean enabled = System.getInt(getContentResolver(), 1276b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project System.AIRPLANE_MODE_ON, 0) == 0; 1277b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project phone.setRadioPower(enabled); 1278b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) { 12798bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project mBluetoothHeadsetState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, 12808bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project BluetoothHeadset.STATE_ERROR); 1281796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: HEADSET_STATE_CHANGED_ACTION"); 1282796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "==> new state: " + mBluetoothHeadsetState); 12834b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project updateBluetoothIndication(true); // Also update any visible UI if necessary 12844b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project } else if (action.equals(BluetoothIntent.HEADSET_AUDIO_STATE_CHANGED_ACTION)) { 12854b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project mBluetoothHeadsetAudioState = 12864b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project intent.getIntExtra(BluetoothIntent.HEADSET_AUDIO_STATE, 12874b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project BluetoothHeadset.STATE_ERROR); 1288796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: HEADSET_AUDIO_STATE_CHANGED_ACTION"); 1289796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "==> new state: " + mBluetoothHeadsetAudioState); 12904b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project updateBluetoothIndication(true); // Also update any visible UI if necessary 1291b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { 129287258b2b589c3afea4b89b840251012378e0d3b4David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED"); 129387258b2b589c3afea4b89b840251012378e0d3b4David Brown if (VDBG) Log.d(LOG_TAG, "- state: " + intent.getStringExtra(Phone.STATE_KEY)); 129487258b2b589c3afea4b89b840251012378e0d3b4David Brown if (VDBG) Log.d(LOG_TAG, "- reason: " 129587258b2b589c3afea4b89b840251012378e0d3b4David Brown + intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY)); 12964079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project 12974079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // The "data disconnected due to roaming" notification is 12984079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // visible if you've lost data connectivity because you're 12994079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // roaming and you have the "data roaming" feature turned off. 13004079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project boolean disconnectedDueToRoaming = false; 1301b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if ("DISCONNECTED".equals(intent.getStringExtra(Phone.STATE_KEY))) { 1302b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY); 1303b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (Phone.REASON_ROAMING_ON.equals(reason)) { 13044079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // We just lost our data connection, and the reason 13054079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // is that we started roaming. This implies that 13064079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // the user has data roaming turned off. 13074079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project disconnectedDueToRoaming = true; 1308b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1309b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 13104079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project mHandler.sendEmptyMessage(disconnectedDueToRoaming 13114079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project ? EVENT_DATA_ROAMING_DISCONNECTED 13124079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project : EVENT_DATA_ROAMING_OK); 1313b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(Intent.ACTION_HEADSET_PLUG)) { 1314796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_HEADSET_PLUG"); 1315796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, " state: " + intent.getIntExtra("state", 0)); 1316796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, " name: " + intent.getStringExtra("name")); 1317b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mIsHeadsetPlugged = (intent.getIntExtra("state", 0) == 1); 1318b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mHandler.sendMessage(mHandler.obtainMessage(EVENT_WIRED_HEADSET_PLUG, 0)); 1319b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(Intent.ACTION_BATTERY_LOW)) { 1320796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_BATTERY_LOW"); 1321b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project notifier.sendBatteryLow(); // Play a warning tone if in-call 1322b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if ((action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) && 1323b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project (mPUKEntryActivity != null)) { 1324b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // if an attempt to un-PUK-lock the device was made, while we're 1325b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // receiving this state change notification, notify the handler. 1326b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has 1327b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // been attempted. 1328b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED, 1329a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE))); 1330a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) { 1331a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville String newPhone = intent.getStringExtra(Phone.PHONE_NAME_KEY); 1332a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active."); 1333a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville initForNewRadioTechnology(); 1334404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) { 1335404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville handleServiceStateChanged(intent); 1336abeff00b5242e795baa8f5271525c5911f649993Wink Saville } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) { 13374e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski if(phone.getPhoneName().equals("CDMA")) { 13384e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp."); 13394e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski // Start Emergency Callback Mode service 13404e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski if (intent.getBooleanExtra("phoneinECMState", false)) { 13414e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski context.startService(new Intent(context, 13424e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski EmergencyCallbackModeService.class)); 13434e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski } 13444e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski } else { 13454e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski Log.e(LOG_TAG, "Error! Emergency Callback Mode not supported for " + 13464e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski phone.getPhoneName() + " phones"); 13474e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski } 1348b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1349b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1350b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1351b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1352b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 1353b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Broadcast receiver for the ACTION_MEDIA_BUTTON broadcast intent. 1354b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 1355b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This functionality isn't lumped in with the other intents in 1356b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * PhoneAppBroadcastReceiver because we instantiate this as a totally 1357b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * separate BroadcastReceiver instance, since we need to manually 1358b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * adjust its IntentFilter's priority (to make sure we get these 1359b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * intents *before* the media player.) 1360b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 1361b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private class MediaButtonBroadcastReceiver extends BroadcastReceiver { 1362b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 1363b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onReceive(Context context, Intent intent) { 1364b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); 1365796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, 1366b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project "MediaButtonBroadcastReceiver.onReceive()... event = " + event); 1367b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if ((event != null) 1368b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project && (event.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK) 1369b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project && (event.getAction() == KeyEvent.ACTION_DOWN)) { 1370b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1371b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (event.getRepeatCount() == 0) { 1372b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Mute ONLY on the initial keypress. 1373796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "MediaButtonBroadcastReceiver: HEADSETHOOK down!"); 1374b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean consumed = PhoneUtils.handleHeadsetHook(phone); 1375796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "==> handleHeadsetHook(): consumed = " + consumed); 1376b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (consumed) { 1377b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project abortBroadcast(); 1378b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 13794079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project } else if (phone.getState() != Phone.State.IDLE) { 13804079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // As for any DOWN events other than the initial press, we consume 13814079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // (and ignore) those too if the phone is in use. (Otherwise the 13824079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // music player will handle them, which would be confusing.) 1383b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project abortBroadcast(); 1384b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1385b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1386b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1387b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1388404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1389404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville private void handleServiceStateChanged(Intent intent) { 13904e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville /** 13914e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * This used to handle updating EriTextWidgetProvider this routine 13924e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * and and listening for ACTION_SERVICE_STATE_CHANGED intents could 13934e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * be removed. But leaving just in case it might be needed in the near 13944e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * future. 13954e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville */ 13964e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville 1397404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville // If service just returned, start sending out the queued messages 1398404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville ServiceState ss = ServiceState.newFromBundle(intent.getExtras()); 1399404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1400404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville boolean hasService = true; 1401404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville boolean isCdma = false; 1402404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville String eriText = ""; 1403404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1404404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville if (ss != null) { 1405404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville int state = ss.getState(); 140699d10538d840f0103c36dafa44db9f649ca884c8johnwang NotificationMgr.getDefault().updateNetworkSelection(state); 1407404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville switch (state) { 1408404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville case ServiceState.STATE_OUT_OF_SERVICE: 1409404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville case ServiceState.STATE_POWER_OFF: 1410404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville hasService = false; 1411404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville break; 1412404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } 1413404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } else { 1414404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville hasService = false; 1415404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } 1416404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } 1417af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 1418af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public boolean isOtaCallInActiveState() { 1419af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville boolean otaCallActive = false; 1420af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (mInCallScreen != null) { 1421af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville otaCallActive = mInCallScreen.isOtaCallInActiveState(); 1422af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 1423af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (DBG) Log.d(LOG_TAG, "PhoneApp - isOtaCallInActiveState " + otaCallActive); 1424af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville return otaCallActive; 1425af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 1426af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 1427af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public boolean isOtaCallInEndState() { 1428af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville boolean otaCallEnded = false; 1429af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (mInCallScreen != null) { 1430af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville otaCallEnded = mInCallScreen.isOtaCallInEndState(); 1431af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 1432af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (DBG) Log.d(LOG_TAG, "PhoneApp - isOtaCallInEndState " + otaCallEnded); 1433af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville return otaCallEnded; 1434af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 143573caead845b30580010a7502e4b7551d21dfa265Matthew Sun 143673caead845b30580010a7502e4b7551d21dfa265Matthew Sun // it is safe to call clearOtaState() even if the InCallScreen isn't active 143773caead845b30580010a7502e4b7551d21dfa265Matthew Sun public void clearOtaState() { 143873caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - clearOtaState ..."); 143973caead845b30580010a7502e4b7551d21dfa265Matthew Sun if ((mInCallScreen != null) 144073caead845b30580010a7502e4b7551d21dfa265Matthew Sun && (mInCallScreen.otaUtils != null)) { 144173caead845b30580010a7502e4b7551d21dfa265Matthew Sun mInCallScreen.otaUtils.cleanOtaScreen(); 144273caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - clearOtaState clears OTA screen"); 144373caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 144473caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 144573caead845b30580010a7502e4b7551d21dfa265Matthew Sun 144673caead845b30580010a7502e4b7551d21dfa265Matthew Sun // it is safe to call dismissOtaDialogs() even if the InCallScreen isn't active 144773caead845b30580010a7502e4b7551d21dfa265Matthew Sun public void dismissOtaDialogs() { 144873caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - dismissOtaDialogs ..."); 144973caead845b30580010a7502e4b7551d21dfa265Matthew Sun if ((mInCallScreen != null) 145073caead845b30580010a7502e4b7551d21dfa265Matthew Sun && (mInCallScreen.otaUtils != null)) { 145173caead845b30580010a7502e4b7551d21dfa265Matthew Sun mInCallScreen.otaUtils.dismissAllOtaDialogs(); 145273caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - dismissOtaDialogs clears OTA dialogs"); 145373caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 145473caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 145573caead845b30580010a7502e4b7551d21dfa265Matthew Sun 145673caead845b30580010a7502e4b7551d21dfa265Matthew Sun // it is safe to call clearInCallScreenMode() even if the InCallScreen isn't active 145773caead845b30580010a7502e4b7551d21dfa265Matthew Sun public void clearInCallScreenMode() { 145873caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - clearInCallScreenMode ..."); 145973caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (mInCallScreen != null) { 146073caead845b30580010a7502e4b7551d21dfa265Matthew Sun mInCallScreen.resetInCallScreenMode(); 146173caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 146273caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 1463b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project} 1464