PhoneApp.java revision b8df8173e1a0ea8ba89cea984176216201c4d5e7
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.content.BroadcastReceiver; 25b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.ContentResolver; 26b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.Context; 27b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.Intent; 28b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.content.IntentFilter; 29d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillaiimport android.content.res.Configuration; 30b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.media.AudioManager; 31b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.net.Uri; 32b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.AsyncResult; 33b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Binder; 34b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Handler; 35b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.IBinder; 36b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.IPowerManager; 37b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.LocalPowerManager; 38b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Message; 39b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.PowerManager; 40b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.RemoteException; 41b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.ServiceManager; 42b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.SystemClock; 43b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.SystemProperties; 44b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.preference.PreferenceManager; 45b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.provider.Settings.System; 46404edc94de563aef5fd5ba48be9114a970cb93bbWink Savilleimport android.telephony.ServiceState; 47b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.util.Config; 48b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.util.Log; 49b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.view.KeyEvent; 50b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.widget.Toast; 51b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 52ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brownimport com.android.internal.telephony.Call; 53a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.IccCard; 54a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.MmiCode; 55a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.Phone; 56a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.PhoneFactory; 57a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Savilleimport com.android.internal.telephony.TelephonyIntents; 58ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brownimport com.android.internal.telephony.cdma.EriInfo; 596bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillaiimport com.android.phone.OtaUtils.CdmaOtaScreenState; 60a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 61b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project/** 62b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Top-level Application class for the Phone app. 63b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 64b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectpublic class PhoneApp extends Application { 65b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ static final String LOG_TAG = "PhoneApp"; 66796c70c99bc39295bf685061056f06ab8949c742David Brown 67796c70c99bc39295bf685061056f06ab8949c742David Brown /** 68796c70c99bc39295bf685061056f06ab8949c742David Brown * Phone app-wide debug level: 69796c70c99bc39295bf685061056f06ab8949c742David Brown * 0 - no debug logging 70796c70c99bc39295bf685061056f06ab8949c742David Brown * 1 - normal debug logging if ro.debuggable is set (which is true in 71796c70c99bc39295bf685061056f06ab8949c742David Brown * "eng" and "userdebug" builds but not "user" builds) 72796c70c99bc39295bf685061056f06ab8949c742David Brown * 2 - ultra-verbose debug logging 73796c70c99bc39295bf685061056f06ab8949c742David Brown * 74796c70c99bc39295bf685061056f06ab8949c742David Brown * Most individual classes in the phone app have a local DBG constant, 75796c70c99bc39295bf685061056f06ab8949c742David Brown * typically set to 76796c70c99bc39295bf685061056f06ab8949c742David Brown * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1) 77796c70c99bc39295bf685061056f06ab8949c742David Brown * or else 78796c70c99bc39295bf685061056f06ab8949c742David Brown * (PhoneApp.DBG_LEVEL >= 2) 79796c70c99bc39295bf685061056f06ab8949c742David Brown * depending on the desired verbosity. 80796c70c99bc39295bf685061056f06ab8949c742David Brown */ 81796c70c99bc39295bf685061056f06ab8949c742David Brown /* package */ static final int DBG_LEVEL = 1; 82796c70c99bc39295bf685061056f06ab8949c742David Brown 83796c70c99bc39295bf685061056f06ab8949c742David Brown private static final boolean DBG = 84796c70c99bc39295bf685061056f06ab8949c742David Brown (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1); 85796c70c99bc39295bf685061056f06ab8949c742David Brown private static final boolean VDBG = (PhoneApp.DBG_LEVEL >= 2); 86b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 87b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Message codes; see mHandler below. 88b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_ABSENT = 1; 89b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_LOCKED = 2; 90b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_NETWORK_LOCKED = 3; 91b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_WIRED_HEADSET_PLUG = 7; 92b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final int EVENT_SIM_STATE_CHANGED = 8; 938bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project private static final int EVENT_UPDATE_INCALL_NOTIFICATION = 9; 944079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10; 954079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project private static final int EVENT_DATA_ROAMING_OK = 11; 96404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12; 97b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 98b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The MMI codes are also used by the InCallScreen. 994079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project public static final int MMI_INITIATE = 51; 1004079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project public static final int MMI_COMPLETE = 52; 1014079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project public static final int MMI_CANCEL = 53; 102b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Don't use message codes larger than 99 here; those are reserved for 103b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the individual Activities of the Phone UI. 104b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 105b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 106b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Allowable values for the poke lock code (timeout between a user activity and the 107b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * going to sleep), please refer to {@link com.android.server.PowerManagerService} 108b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * for additional reference. 109b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * SHORT uses the short delay for the timeout (SHORT_KEYLIGHT_DELAY, 6 sec) 110b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * MEDIUM uses the medium delay for the timeout (MEDIUM_KEYLIGHT_DELAY, 15 sec) 111b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * DEFAULT is the system-wide default delay for the timeout (1 min) 112b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 113b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public enum ScreenTimeoutDuration { 114b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project SHORT, 115b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project MEDIUM, 116b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project DEFAULT 117b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 118b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 119b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 120b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Allowable values for the wake lock code. 121b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * SLEEP means the device can be put to sleep. 122b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * PARTIAL means wake the processor, but we display can be kept off. 123b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * FULL means wake both the processor and the display. 124b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 125b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public enum WakeState { 126b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project SLEEP, 127b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PARTIAL, 128b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project FULL 129b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 130b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 131b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static PhoneApp sMe; 132b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 133b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // A few important fields we expose to the rest of the package 134b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // directly (rather than thru set/get methods) for efficiency. 135b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Phone phone; 136b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project CallNotifier notifier; 137b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Ringer ringer; 138b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project BluetoothHandsfree mBtHandsfree; 139b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneInterfaceManager phoneMgr; 1408bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project int mBluetoothHeadsetState = BluetoothHeadset.STATE_ERROR; 1414b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project int mBluetoothHeadsetAudioState = BluetoothHeadset.STATE_ERROR; 1428bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project boolean mShowBluetoothIndication = false; 143b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1440fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // Internal PhoneApp Call state tracker 1450fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville CdmaPhoneCallState cdmaPhoneCallState; 1460fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville 147b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The InCallScreen instance (or null if the InCallScreen hasn't been 148b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // created yet.) 149b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private InCallScreen mInCallScreen; 150b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 151b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The currently-active PUK entry activity and progress dialog. 152b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Normally, these are the Emergency Dialer and the subsequent 153b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // progress dialog. null if there is are no such objects in 154b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the foreground. 155b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private Activity mPUKEntryActivity; 156b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private ProgressDialog mPUKEntryProgressDialog; 157b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 158b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private boolean mIsSimPinEnabled; 159b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private String mCachedSimPin; 160b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 161b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if a wired headset is currently plugged in, based on the state 162b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // from the latest Intent.ACTION_HEADSET_PLUG broadcast we received in 163b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // mReceiver.onReceive(). 164b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private boolean mIsHeadsetPlugged; 165b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 166d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // True if the keyboard is currently *not* hidden 167d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Gets updated whenever there is a Configuration change 168d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai private boolean mIsHardKeyboardOpen; 169d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 170445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // True if we are beginning a call, but the phone state has not changed yet 171445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood private boolean mBeginningCall; 172445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 173445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // Last phone state seen by updatePhoneState() 174445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood Phone.State mLastPhoneState = Phone.State.IDLE; 175445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 176b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private WakeState mWakeState = WakeState.SLEEP; 1774472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown private ScreenTimeoutDuration mScreenTimeoutDuration = ScreenTimeoutDuration.DEFAULT; 1784472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown private boolean mIgnoreTouchUserActivity = false; 179b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private IBinder mPokeLockToken = new Binder(); 180b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private IPowerManager mPowerManagerService; 181b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private PowerManager.WakeLock mWakeLock; 182b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private PowerManager.WakeLock mPartialWakeLock; 18358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown private PowerManager.WakeLock mProximityWakeLock; 184b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private KeyguardManager mKeyguardManager; 185b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private KeyguardManager.KeyguardLock mKeyguardLock; 186b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 187b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Broadcast receiver for various intent broadcasts (see onCreate()) 188b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver(); 189b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 190b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Broadcast receiver purely for ACTION_MEDIA_BUTTON broadcasts 191b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private final BroadcastReceiver mMediaButtonReceiver = new MediaButtonBroadcastReceiver(); 192b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 193b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** boolean indicating restoring mute state on InCallScreen.onResume() */ 194b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private boolean mShouldRestoreMuteOnInCallResume; 195b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 196af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // Following are the CDMA OTA information Objects used during OTA Call. 197af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // cdmaOtaProvisionData object store static OTA information that needs 198af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // to be maintained even during Slider open/close scenarios. 199af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // cdmaOtaConfigData object stores configuration info to control visiblity 200af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // of each OTA Screens. 201af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // cdmaOtaScreenState object store OTA Screen State information. 202af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public OtaUtils.CdmaOtaProvisionData cdmaOtaProvisionData; 203af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public OtaUtils.CdmaOtaConfigData cdmaOtaConfigData; 204af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public OtaUtils.CdmaOtaScreenState cdmaOtaScreenState; 205af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 206b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 207b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Set the restore mute state flag. Used when we are setting the mute state 208b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * OUTSIDE of user interaction {@link PhoneUtils#startNewCall(Phone)} 209b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 210b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /*package*/void setRestoreMuteOnInCallResume (boolean mode) { 211b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mShouldRestoreMuteOnInCallResume = mode; 212b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 213b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 214b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 215b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Get the restore mute state flag. 216b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This is used by the InCallScreen {@link InCallScreen#onResume()} to figure 217b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * out if we need to restore the mute state for the current active call. 218b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 219b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /*package*/boolean getRestoreMuteOnInCallResume () { 220b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mShouldRestoreMuteOnInCallResume; 221b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 222b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 223b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Handler mHandler = new Handler() { 224b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 225b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void handleMessage(Message msg) { 226b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project switch (msg.what) { 227b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_LOCKED: 228b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// mIsSimPinEnabled = true; 229b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// 230b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// if (Config.LOGV) Log.v(LOG_TAG, "show sim unlock panel"); 231b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// SimPinUnlockPanel pinUnlockPanel = new SimPinUnlockPanel( 232b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// PhoneApp.getInstance()); 233b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// pinUnlockPanel.show(); 234b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 235b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 236b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_ABSENT: 237b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// Don't need this now that the lock screen handles this case 238b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// if (Config.LOGV) Log.v(LOG_TAG, "show sim missing panel"); 239b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// SimMissingPanel missingPanel = new SimMissingPanel( 240b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// PhoneApp.getInstance()); 241b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project// missingPanel.show(); 242b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 243b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 244b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_NETWORK_LOCKED: 24509328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown if (getResources().getBoolean(R.bool.ignore_sim_network_locked_events)) { 24609328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // Some products don't have the concept of a "SIM network lock" 24709328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; " 24809328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown + "not showing 'SIM network unlock' PIN entry screen"); 24909328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown } else { 25009328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // Normal case: show the "SIM network unlock" PIN entry screen. 25109328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // The user won't be able to do anything else until 25209328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown // they enter a valid SIM network PIN. 25309328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown Log.i(LOG_TAG, "show sim depersonal panel"); 25409328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown IccNetworkDepersonalizationPanel ndpPanel = 25509328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown new IccNetworkDepersonalizationPanel(PhoneApp.getInstance()); 25609328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown ndpPanel.show(); 25709328f1bd9acf6b16a9cb79d7d9fa59d322ac6c2David Brown } 258b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 259b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 2608bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project case EVENT_UPDATE_INCALL_NOTIFICATION: 2618bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // Tell the NotificationMgr to update the "ongoing 2628bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // call" icon in the status bar, if necessary. 2638bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // Currently, this is triggered by a bluetooth headset 2648bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // state change (since the status bar icon needs to 2658bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // turn blue when bluetooth is active.) 2668bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project NotificationMgr.getDefault().updateInCallNotification(); 2678bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project break; 2688bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 2694079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project case EVENT_DATA_ROAMING_DISCONNECTED: 2704079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project NotificationMgr.getDefault().showDataDisconnectedRoaming(); 271b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 2724079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project 2734079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project case EVENT_DATA_ROAMING_OK: 2744079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project NotificationMgr.getDefault().hideDataDisconnectedRoaming(); 2754079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project break; 2764079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project 277b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case MMI_COMPLETE: 278b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project onMMIComplete((AsyncResult) msg.obj); 279b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 280b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 281b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case MMI_CANCEL: 282b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.cancelMmiCode(phone); 283b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 284b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 285b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_WIRED_HEADSET_PLUG: 286b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Since the presence of a wired headset or bluetooth affects the 287b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // speakerphone, update the "speaker" state. We ONLY want to do 288b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // this on the wired headset connect / disconnect events for now 289b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // though, so we're only triggering on EVENT_WIRED_HEADSET_PLUG. 290425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent // If in call screen is showing, let InCallScreen handle the speaker. 2914a8cbde060e7876a5560346215c11078a9efc90eEric Laurent 2924a8cbde060e7876a5560346215c11078a9efc90eEric Laurent Phone.State phoneState = phone.getState(); 2934a8cbde060e7876a5560346215c11078a9efc90eEric Laurent // Do not change speaker state if phone is not off hook 2944a8cbde060e7876a5560346215c11078a9efc90eEric Laurent if (phoneState == Phone.State.OFFHOOK) { 2954a8cbde060e7876a5560346215c11078a9efc90eEric Laurent if (!isShowingCallScreen() && 2964a8cbde060e7876a5560346215c11078a9efc90eEric Laurent (mBtHandsfree == null || !mBtHandsfree.isAudioOn())) { 2974a8cbde060e7876a5560346215c11078a9efc90eEric Laurent if (!isHeadsetPlugged()) { 2984a8cbde060e7876a5560346215c11078a9efc90eEric Laurent // if the state is "not connected", restore the speaker state. 2994a8cbde060e7876a5560346215c11078a9efc90eEric Laurent PhoneUtils.restoreSpeakerMode(getApplicationContext()); 3004a8cbde060e7876a5560346215c11078a9efc90eEric Laurent } else { 3014a8cbde060e7876a5560346215c11078a9efc90eEric Laurent // if the state is "connected", force the speaker off without 3024a8cbde060e7876a5560346215c11078a9efc90eEric Laurent // storing the state. 3034a8cbde060e7876a5560346215c11078a9efc90eEric Laurent PhoneUtils.turnOnSpeaker(getApplicationContext(), false, false); 3044a8cbde060e7876a5560346215c11078a9efc90eEric Laurent } 305425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent } 306b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 307d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Update the Proximity sensor based on headset state 3084a8cbde060e7876a5560346215c11078a9efc90eEric Laurent updateProximitySensorMode(phoneState); 309b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 310b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 311b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case EVENT_SIM_STATE_CHANGED: 312b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Marks the event where the SIM goes into ready state. 313b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Right now, this is only used for the PUK-unlocking 314b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // process. 315a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville if (msg.obj.equals(IccCard.INTENT_VALUE_ICC_READY)) { 316b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // when the right event is triggered and there 317b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // are UI objects in the foreground, we close 318b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // them to display the lock panel. 319b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPUKEntryActivity != null) { 320b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryActivity.finish(); 321b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryActivity = null; 322b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 323b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPUKEntryProgressDialog != null) { 324b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryProgressDialog.dismiss(); 325b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryProgressDialog = null; 326b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 327b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 328b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 329404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 330404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville case EVENT_UNSOL_CDMA_INFO_RECORD: 331404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville //TODO: handle message here; 332404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville break; 333b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 334b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 335b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project }; 336b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 337b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public PhoneApp() { 338b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sMe = this; 339b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 340b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 341b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 342b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onCreate() { 343b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (Config.LOGV) Log.v(LOG_TAG, "onCreate()..."); 344b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 345b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ContentResolver resolver = getContentResolver(); 346b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 347b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (phone == null) { 348b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Initialize the telephony framework 349b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneFactory.makeDefaultPhones(this); 350b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 351b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Get the default phone 352b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project phone = PhoneFactory.getDefaultPhone(); 353b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 354b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project NotificationMgr.init(this); 355b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 356b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project phoneMgr = new PhoneInterfaceManager(this, phone); 357c9d9ed30aa547b79b81adc13a4d148a003b6ee62w 358c9d9ed30aa547b79b81adc13a4d148a003b6ee62w if (phone.getPhoneName().equals("CDMA")) { 359c9d9ed30aa547b79b81adc13a4d148a003b6ee62w // Create an instance of CdmaPhoneCallState and initialize it to IDLE 360c9d9ed30aa547b79b81adc13a4d148a003b6ee62w cdmaPhoneCallState = new CdmaPhoneCallState(); 361c9d9ed30aa547b79b81adc13a4d148a003b6ee62w cdmaPhoneCallState.CdmaPhoneCallStateInit(); 362c9d9ed30aa547b79b81adc13a4d148a003b6ee62w } 363c9d9ed30aa547b79b81adc13a4d148a003b6ee62w 364b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (getSystemService(Context.BLUETOOTH_SERVICE) != null) { 365b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mBtHandsfree = new BluetoothHandsfree(this, phone); 366b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project startService(new Intent(this, BluetoothHeadsetService.class)); 367b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else { 368b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Device is not bluetooth capable 369b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mBtHandsfree = null; 370b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 371b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 372b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ringer = new Ringer(phone); 373b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 374b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // before registering for phone state changes 375b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 376b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK 377b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | PowerManager.ACQUIRE_CAUSES_WAKEUP 378b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | PowerManager.ON_AFTER_RELEASE, LOG_TAG); 379b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // lock used to keep the processor awake, when we don't care for the display. 380b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK 381b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | PowerManager.ON_AFTER_RELEASE, LOG_TAG); 38258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // Wake lock used to control proximity sensor behavior. 38358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if ((pm.getSupportedWakeLockFlags() 38458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown & PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) != 0x0) { 38558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown mProximityWakeLock = 38658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, LOG_TAG); 38758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 38858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (DBG) Log.d(LOG_TAG, "mProximityWakeLock: " + mProximityWakeLock); 38958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown 390b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 391b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardLock = mKeyguardManager.newKeyguardLock(LOG_TAG); 392b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 393b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // get a handle to the service so that we can use it later when we 394b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // want to set the poke lock. 395b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService = IPowerManager.Stub.asInterface( 396b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ServiceManager.getService("power")); 397b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 398b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project notifier = new CallNotifier(this, phone, ringer, mBtHandsfree); 399b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 400a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville // register for ICC status 401a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville IccCard sim = phone.getIccCard(); 402b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (sim != null) { 403a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville if (Config.LOGV) Log.v(LOG_TAG, "register for ICC status"); 404b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null); 405b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null); 406b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null); 407b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 408b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 409b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // register for MMI/USSD 410fa3fbeedf018e40f8d6696a382bbf316219cf4aeReli Tal if (phone.getPhoneName().equals("GSM")) { 411fa3fbeedf018e40f8d6696a382bbf316219cf4aeReli Tal phone.registerForMmiComplete(mHandler, MMI_COMPLETE, null); 412fa3fbeedf018e40f8d6696a382bbf316219cf4aeReli Tal } 413b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 414b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // register connection tracking to PhoneUtils 415b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.initializeConnectionHandler(phone); 416b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 417b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Register for misc other intent broadcasts. 418b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project IntentFilter intentFilter = 419b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED); 42018e0a07cc700234f5a02fe10eee9b3ea10db58b3Nick Pelly intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED); 42118e0a07cc700234f5a02fe10eee9b3ea10db58b3Nick Pelly intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED); 422b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); 423b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(Intent.ACTION_HEADSET_PLUG); 424b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(Intent.ACTION_BATTERY_LOW); 425b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); 426a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED); 427404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); 428abeff00b5242e795baa8f5271525c5911f649993Wink Saville intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); 429b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project registerReceiver(mReceiver, intentFilter); 430b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 431b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Use a separate receiver for ACTION_MEDIA_BUTTON broadcasts, 432b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // since we need to manually adjust its priority (to make sure 433b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // we get these intents *before* the media player.) 434b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project IntentFilter mediaButtonIntentFilter = 435b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project new IntentFilter(Intent.ACTION_MEDIA_BUTTON); 436b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 437b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Make sure we're higher priority than the media player's 438b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // MediaButtonIntentReceiver (which currently has the default 439b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // priority of zero; see apps/Music/AndroidManifest.xml.) 440b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mediaButtonIntentFilter.setPriority(1); 441b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 442b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project registerReceiver(mMediaButtonReceiver, mediaButtonIntentFilter); 443b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 444b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project //set the default values for the preferences in the phone. 445b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PreferenceManager.setDefaultValues(this, R.xml.network_setting, false); 446cd0189299f484dcbd51400b994daf585923e9e8dDavid Krause 447cd0189299f484dcbd51400b994daf585923e9e8dDavid Krause PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false); 448b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 449b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Make sure the audio mode (along with some 450b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // audio-mode-related state of our own) is initialized 451b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // correctly, given the current state of the phone. 452b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project switch (phone.getState()) { 453b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case IDLE: 454b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: IDLE"); 455b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_IDLE); 456b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioMode(this, AudioManager.MODE_NORMAL); 457b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 458b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case RINGING: 459b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: RINGING"); 460b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_RINGING); 461b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioMode(this, AudioManager.MODE_RINGTONE); 462b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 463b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case OFFHOOK: 464b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: OFFHOOK"); 465b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_OFFHOOK); 466b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.setAudioMode(this, AudioManager.MODE_IN_CALL); 467b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 468b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 469b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 470b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 471af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (phone.getPhoneName().equals("CDMA")) { 472af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData(); 473af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData(); 474af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState(); 475af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 476af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 477b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // XXX pre-load the SimProvider so that it's ready 478a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville resolver.getType(Uri.parse("content://icc/adn")); 479b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 480b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // start with the default value to set the mute state. 481b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mShouldRestoreMuteOnInCallResume = false; 482404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 4830fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // Register for Cdma Information Records 4840fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // TODO(Moto): Merge 4850fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null); 4860fb2b4b8eff811fd3243aefdf536e7ba2b10f4e9Wink Saville 4877fe7f7e57aaa38290c37ab48867d34a279d198f3w // Read TTY settings and store it into BP NV. 4887fe7f7e57aaa38290c37ab48867d34a279d198f3w // AP owns (i.e. stores) the TTY setting in AP settings database and pushes the setting 4897fe7f7e57aaa38290c37ab48867d34a279d198f3w // to BP at power up (BP does not need to make the TTY setting persistent storage). 4907fe7f7e57aaa38290c37ab48867d34a279d198f3w // This way, there is a single owner (i.e AP) for the TTY setting in the phone. 4917fe7f7e57aaa38290c37ab48867d34a279d198f3w if (phone.getPhoneName().equals("CDMA")) { 4927fe7f7e57aaa38290c37ab48867d34a279d198f3w int settingsTtyMode = android.provider.Settings.Secure.getInt( 4937fe7f7e57aaa38290c37ab48867d34a279d198f3w phone.getContext().getContentResolver(), 4947fe7f7e57aaa38290c37ab48867d34a279d198f3w android.provider.Settings.Secure.PREFERRED_TTY_MODE, 4957fe7f7e57aaa38290c37ab48867d34a279d198f3w Phone.TTY_MODE_OFF); 4967fe7f7e57aaa38290c37ab48867d34a279d198f3w phone.setTTYMode(settingsTtyMode, null); 4977fe7f7e57aaa38290c37ab48867d34a279d198f3w } 498b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 499b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 500d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai @Override 501d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai public void onConfigurationChanged(Configuration newConfig) { 502d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { 503d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai mIsHardKeyboardOpen = true; 504d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai } else { 505d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai mIsHardKeyboardOpen = false; 506d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai } 507d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 508d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Update the Proximity sensor based on keyboard state 509d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai updateProximitySensorMode(phone.getState()); 510d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai super.onConfigurationChanged(newConfig); 511d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai } 512d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 513b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 514b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Returns the singleton instance of the PhoneApp. 515b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 516b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project static PhoneApp getInstance() { 517b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return sMe; 518b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 519b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 520b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Ringer getRinger() { 521b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return ringer; 522b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 523b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 524b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project BluetoothHandsfree getBluetoothHandsfree() { 525b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mBtHandsfree; 526b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 527b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 528b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project static Intent createCallLogIntent() { 529b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Intent intent = new Intent(Intent.ACTION_VIEW, null); 530b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.setType("vnd.android.cursor.dir/calls"); 531b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return intent; 532b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 533b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 534b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 535b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Return an Intent that can be used to bring up the in-call screen. 536b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 537b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This intent can only be used from within the Phone app, since the 538b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * InCallScreen is not exported from our AndroidManifest. 539b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 540b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ static Intent createInCallIntent() { 541b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Intent intent = new Intent(Intent.ACTION_MAIN, null); 542b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 543b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS 544b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project | Intent.FLAG_ACTIVITY_NO_USER_ACTION); 545b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.setClassName("com.android.phone", getCallScreenClassName()); 546b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return intent; 547b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 548b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 549b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 550b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Variation of createInCallIntent() that also specifies whether the 551b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * DTMF dialpad should be initially visible when the InCallScreen 552b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * comes up. 553b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 554b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ static Intent createInCallIntent(boolean showDialpad) { 555b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Intent intent = createInCallIntent(); 556b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project intent.putExtra(InCallScreen.SHOW_DIALPAD_EXTRA, showDialpad); 557b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return intent; 558b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 559b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 560b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project static String getCallScreenClassName() { 561b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return InCallScreen.class.getName(); 562b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 563b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 564b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 565b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Starts the InCallScreen Activity. 566b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 567b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void displayCallScreen() { 568796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "displayCallScreen()..."); 569b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project startActivity(createInCallIntent()); 570b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Profiler.callScreenRequested(); 571b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 572b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 573b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 574b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Helper function to check for one special feature of the CALL key: 575b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Normally, when the phone is idle, CALL takes you to the call log 576b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * (see the handler for KEYCODE_CALL in PhoneWindow.onKeyUp().) 577b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * But if the phone is in use (either off-hook or ringing) we instead 578b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * handle the CALL button by taking you to the in-call UI. 579b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 580b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @return true if we intercepted the CALL keypress (i.e. the phone 581b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * was in use) 582b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 583b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @see DialerActivity#onCreate 584b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 585b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean handleInCallOrRinging() { 586b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (phone.getState() != Phone.State.IDLE) { 587b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Phone is OFFHOOK or RINGING. 588b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.v(LOG_TAG, 589b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project "handleInCallOrRinging: show call screen"); 590b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project displayCallScreen(); 591b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return true; 592b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 593b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return false; 594b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 595b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 596b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isSimPinEnabled() { 597b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mIsSimPinEnabled; 598b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 599b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 600b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean authenticateAgainstCachedSimPin(String pin) { 601b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return (mCachedSimPin != null && mCachedSimPin.equals(pin)); 602b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 603b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 604b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setCachedSimPin(String pin) { 605b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mCachedSimPin = pin; 606b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 607b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 608b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setInCallScreenInstance(InCallScreen inCallScreen) { 609b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mInCallScreen = inCallScreen; 610b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 611b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 612b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 613b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @return true if the in-call UI is running as the foreground 614b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * activity. (In other words, from the perspective of the 615b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * InCallScreen activity, return true between onResume() and 616b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * onPause().) 617b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 618b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Note this method will return false if the screen is currently off, 619b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * even if the InCallScreen *was* in the foreground just before the 620b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * screen turned off. (This is because the foreground activity is 621b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * always "paused" while the screen is off.) 622b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 623b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isShowingCallScreen() { 624b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mInCallScreen == null) return false; 625b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mInCallScreen.isForegroundActivity(); 626b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 627b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 628b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 629b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Dismisses the in-call UI. 630b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 631b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This also ensures that you won't be able to get back to the in-call 632b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * UI via the BACK button (since this call removes the InCallScreen 633b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * from the activity history.) 634af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * For OTA Call, it call InCallScreen api to handle OTA Call End scenario 635af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * to display OTA Call End screen. 636b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 637b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void dismissCallScreen() { 638b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mInCallScreen != null) { 6396bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai if (mInCallScreen.isOtaCallInActiveState() 6406bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai || mInCallScreen.isOtaCallInEndState() 6416bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai || ((cdmaOtaScreenState != null) 6426bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai && (cdmaOtaScreenState.otaScreenState 6436bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai != CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED))) { 644af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // TODO(Moto): During OTA Call, display should not become dark to 645af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // allow user to see OTA UI update. Phone app needs to hold a SCREEN_DIM_WAKE_LOCK 646af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville // wake lock during the entire OTA call. 647af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville wakeUpScreen(); 6486bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai // If InCallScreen is not in foreground we resume it to show the OTA call end screen 6496bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai // Fire off the InCallScreen intent 6506bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai displayCallScreen(); 6516bdc4d568f008ca476c744d52056dde3e8db27f8Abhishek Pillai 652af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville mInCallScreen.handleOtaCallEnd(); 653af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville return; 654af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } else { 655af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville mInCallScreen.finish(); 656af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 657b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 658b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 659b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 660b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 661af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Handle OTA events 662af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * 663af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * When OTA call is active and display becomes dark, then CallNotifier will 664af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * handle OTA Events by calling this api which then calls OtaUtil function. 665af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville */ 666af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville void handleOtaEvents(Message msg) { 667af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 668af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (DBG) Log.d(LOG_TAG, "Enter handleOtaEvents"); 669af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if ((mInCallScreen != null) && (!isShowingCallScreen())) { 670af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (mInCallScreen.otaUtils != null) { 671af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville mInCallScreen.otaUtils.onOtaProvisionStatusChanged((AsyncResult) msg.obj); 672af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 673af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 674af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 675af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 676af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 677af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville /** 678b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Sets the activity responsible for un-PUK-blocking the device 679b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * so that we may close it when we receive a positive result. 680b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * mPUKEntryActivity is also used to indicate to the device that 681b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * we are trying to un-PUK-lock the phone. In other words, iff 682b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * it is NOT null, then we are trying to unlock and waiting for 683b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * the SIM to move to READY state. 684b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 685b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param activity is the activity to close when PUK has 686b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * finished unlocking. Can be set to null to indicate the unlock 687b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * or SIM READYing process is over. 688b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 689b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setPukEntryActivity(Activity activity) { 690b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryActivity = activity; 691b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 692b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 693b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Activity getPUKEntryActivity() { 694b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mPUKEntryActivity; 695b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 696b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 697b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 698b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Sets the dialog responsible for notifying the user of un-PUK- 699b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * blocking - SIM READYing progress, so that we may dismiss it 700b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * when we receive a positive result. 701b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 702b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param dialog indicates the progress dialog informing the user 703b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * of the state of the device. Dismissed upon completion of 704b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * READYing process 705b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 706b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project void setPukEntryProgressDialog(ProgressDialog dialog) { 707b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPUKEntryProgressDialog = dialog; 708b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 709b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 710b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project ProgressDialog getPUKEntryProgressDialog() { 711b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mPUKEntryProgressDialog; 712b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 713b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 714b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 715b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Disables the keyguard. This is used by the phone app to allow 716b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * interaction with the Phone UI when the keyguard would otherwise be 717b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * active (like receiving an incoming call while the device is 718b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * locked.) 719b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 720b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Any call to this method MUST be followed (eventually) 721b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * by a corresponding reenableKeyguard() call. 722b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 723b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void disableKeyguard() { 724b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "disable keyguard"); 725b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // if (DBG) Log.d(LOG_TAG, "disableKeyguard()...", new Throwable("stack dump")); 726b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardLock.disableKeyguard(); 727b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 728b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 729b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 730b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Re-enables the keyguard after a previous disableKeyguard() call. 731b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 732b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Any call to this method MUST correspond to (i.e. be balanced with) 733b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * a previous disableKeyguard() call. 734b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 735b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void reenableKeyguard() { 736b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "re-enable keyguard"); 737b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // if (DBG) Log.d(LOG_TAG, "reenableKeyguard()...", new Throwable("stack dump")); 738b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mKeyguardLock.reenableKeyguard(); 739b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 740b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 741b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 742b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Controls how quickly the screen times out. 743b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 744b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * The poke lock controls how long it takes before the screen powers 745b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * down, and therefore has no immediate effect when the current 746b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * WakeState (see {@link PhoneApp#requestWakeState}) is FULL. 747b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * If we're in a state where the screen *is* allowed to turn off, 748b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * though, the poke lock will determine the timeout interval (long or 749b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * short). 750b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 751b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param shortPokeLock tells the device the timeout duration to use 752b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * before going to sleep 753b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * {@link com.android.server.PowerManagerService#SHORT_KEYLIGHT_DELAY}. 754b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 755b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void setScreenTimeout(ScreenTimeoutDuration duration) { 756796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "setScreenTimeout(" + duration + ")..."); 757b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 758b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // make sure we don't set the poke lock repeatedly so that we 759b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // avoid triggering the userActivity calls in 760b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // PowerManagerService.setPokeLock(). 7614472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (duration == mScreenTimeoutDuration) { 762b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return; 763b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 764039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood // stick with default timeout if we are using the proximity sensor 765039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood if (proximitySensorModeEnabled()) { 766039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood return; 767039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood } 7684472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown mScreenTimeoutDuration = duration; 7694472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown updatePokeLock(); 7704472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 771b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 7724472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /** 7734472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Update the state of the poke lock held by the phone app, 7744472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * based on the current desired screen timeout and the 7754472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * current "ignore user activity on touch" flag. 7764472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown */ 7774472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown private void updatePokeLock() { 778b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // This is kind of convoluted, but the basic thing to remember is 779b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // that the poke lock just sends a message to the screen to tell 780b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // it to stay on for a while. 781b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The default is 0, for a long timeout and should be set that way 782b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // when we are heading back into a the keyguard / screen off 783b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // state, and also when we're trying to keep the screen alive 784b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // while ringing. We'll also want to ignore the cheek events 785b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // regardless of the timeout duration. 786b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The short timeout is really used whenever we want to give up 787b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the screen lock, such as when we're in call. 788b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project int pokeLockSetting = LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS; 7894472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown switch (mScreenTimeoutDuration) { 790b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case SHORT: 791b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Set the poke lock to timeout the display after a short 792b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // timeout (5s). This ensures that the screen goes to sleep 793b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // as soon as acceptably possible after we the wake lock 794b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // has been released. 795b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project pokeLockSetting |= LocalPowerManager.POKE_LOCK_SHORT_TIMEOUT; 796b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 797b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 798b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case MEDIUM: 799b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Set the poke lock to timeout the display after a medium 800b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // timeout (15s). This ensures that the screen goes to sleep 801b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // as soon as acceptably possible after we the wake lock 802b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // has been released. 803b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project pokeLockSetting |= LocalPowerManager.POKE_LOCK_MEDIUM_TIMEOUT; 804b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 805b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 806b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case DEFAULT: 807b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project default: 808b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // set the poke lock to timeout the display after a long 809b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // delay by default. 810b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // TODO: it may be nice to be able to disable cheek presses 811b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // for long poke locks (emergency dialer, for instance). 812b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 813b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 814b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 8154472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (mIgnoreTouchUserActivity) { 8164472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown pokeLockSetting |= LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS; 8174472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 8184472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown 819b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Send the request 820b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project try { 821b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService.setPokeLock(pokeLockSetting, mPokeLockToken, LOG_TAG); 822b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } catch (RemoteException e) { 8234472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown Log.w(LOG_TAG, "mPowerManagerService.setPokeLock() failed: " + e); 824b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 825b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 826b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 827b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 828b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Controls whether or not the screen is allowed to sleep. 829b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 830b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Once sleep is allowed (WakeState is SLEEP), it will rely on the 831b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * settings for the poke lock to determine when to timeout and let 832b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * the device sleep {@link PhoneApp#setScreenTimeout}. 833b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 834b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @param ws tells the device to how to wake. 835b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 836b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void requestWakeState(WakeState ws) { 837796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "requestWakeState(" + ws + ")..."); 838b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeState != ws) { 839b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project switch (ws) { 840b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case PARTIAL: 841b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // acquire the processor wake lock, and release the FULL 842b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // lock if it is being held. 843b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock.acquire(); 844b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeLock.isHeld()) { 845b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock.release(); 846b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 847b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 848b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case FULL: 849b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // acquire the full wake lock, and release the PARTIAL 850b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // lock if it is being held. 851b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock.acquire(); 852b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPartialWakeLock.isHeld()) { 853b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock.release(); 854b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 855b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 856b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project case SLEEP: 857b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project default: 858b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // release both the PARTIAL and FULL locks. 859b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeLock.isHeld()) { 860b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeLock.release(); 861b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 862b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mPartialWakeLock.isHeld()) { 863b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPartialWakeLock.release(); 864b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 865b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project break; 866b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 867b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mWakeState = ws; 868b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 869b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 870b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 871b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 872b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * If we are not currently keeping the screen on, then poke the power 873b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * manager to wake up the screen for the user activity timeout duration. 874b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 875b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void wakeUpScreen() { 876b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mWakeState == WakeState.SLEEP) { 877b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "pulse screen lock"); 878b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project try { 879b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService.userActivityWithForce(SystemClock.uptimeMillis(), false, true); 880b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } catch (RemoteException ex) { 881b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Ignore -- the system process is dead. 882b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 883b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 884b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 885b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 886b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 887b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Sets the wake state and screen timeout based on the current state 888b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * of the phone, and the current state of the in-call UI. 889b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 890b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This method is a "UI Policy" wrapper around 891b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * {@link PhoneApp#requestWakeState} and {@link PhoneApp#setScreenTimeout}. 892b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 893b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * It's safe to call this method regardless of the state of the Phone 894b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * (e.g. whether or not it's idle), and regardless of the state of the 895b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Phone UI (e.g. whether or not the InCallScreen is active.) 896b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 897b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void updateWakeState() { 898b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Phone.State state = phone.getState(); 899b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 900b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if the in-call UI is the foreground activity. 901b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (Note this will be false if the screen is currently off, 902b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // since in that case *no* activity is in the foreground.) 903b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isShowingCallScreen = isShowingCallScreen(); 904b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 905b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if the InCallScreen's DTMF dialer is currently opened. 906b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (Note this does NOT imply whether or not the InCallScreen 907b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // itself is visible.) 908b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isDialerOpened = (mInCallScreen != null) && mInCallScreen.isDialerOpened(); 909b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 910b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // True if the speakerphone is in use. (If so, we *always* use 911b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the default timeout. Since the user is obviously not holding 912b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the phone up to his/her face, we don't need to worry about 913b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // false touches, and thus don't need to turn the screen off so 914b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // aggressively.) 915b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Note that we need to make a fresh call to this method any 916b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // time the speaker state changes. (That happens in 917b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // PhoneUtils.turnOnSpeaker().) 918b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isSpeakerInUse = (state == Phone.State.OFFHOOK) && PhoneUtils.isSpeakerOn(this); 919b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 920b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // TODO (bug 1440854): The screen timeout *might* also need to 921b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // depend on the bluetooth state, but this isn't as clear-cut as 922b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the speaker state (since while using BT it's common for the 923b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // user to put the phone straight into a pocket, in which case the 924b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // timeout should probably still be short.) 925b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 926796c70c99bc39295bf685061056f06ab8949c742David Brown if (DBG) Log.d(LOG_TAG, "updateWakeState: callscreen " + isShowingCallScreen 927796c70c99bc39295bf685061056f06ab8949c742David Brown + ", dialer " + isDialerOpened 928796c70c99bc39295bf685061056f06ab8949c742David Brown + ", speaker " + isSpeakerInUse + "..."); 929b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 930b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 931b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (1) Set the screen timeout. 932b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 933b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Note that the "screen timeout" value we determine here is 934b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // meaningless if the screen is forced on (see (2) below.) 935b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 936b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (!isShowingCallScreen || isSpeakerInUse) { 937b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Use the system-wide default timeout. 938b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setScreenTimeout(ScreenTimeoutDuration.DEFAULT); 939b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else { 940b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // We're on the in-call screen, and *not* using the speakerphone. 941b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (isDialerOpened) { 942b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // The DTMF dialpad is up. This case is special because 943b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // the in-call UI has its own "touch lock" mechanism to 944b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // disable the dialpad after a very short amount of idle 945b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // time (to avoid false touches from the user's face while 946b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // in-call.) 947b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 948b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // In this case the *physical* screen just uses the 949b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // system-wide default timeout. 950b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setScreenTimeout(ScreenTimeoutDuration.DEFAULT); 951b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else { 952b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // We're on the in-call screen, and not using the DTMF dialpad. 953b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // There's actually no touchable UI onscreen at all in 954b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // this state. Also, the user is (most likely) not 955b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // looking at the screen at all, since they're probably 956b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // holding the phone up to their face. Here we use a 957b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // special screen timeout value specific to the in-call 958b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // screen, purely to save battery life. 959b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setScreenTimeout(ScreenTimeoutDuration.MEDIUM); 960b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 961b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 962b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 963b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 964b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // (2) Decide whether to force the screen on or not. 965b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 966ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown // Force the screen to be on if the phone is ringing or dialing, 967ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown // or if we're displaying the "Call ended" UI for a connection in 968ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown // the "disconnected" state. 969b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // 970b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isRinging = (state == Phone.State.RINGING); 971ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown boolean isDialing = (phone.getForegroundCall().getState() == Call.State.DIALING); 972b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean showingDisconnectedConnection = 973b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.hasDisconnectedConnections(phone) && isShowingCallScreen; 974ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown boolean keepScreenOn = isRinging || isDialing || showingDisconnectedConnection; 975b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (DBG) Log.d(LOG_TAG, "updateWakeState: keepScreenOn = " + keepScreenOn 976b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project + " (isRinging " + isRinging 977ee77dd0ec7fcbe315a34ef6625854a8affe31885David Brown + ", isDialing " + isDialing 978796c70c99bc39295bf685061056f06ab8949c742David Brown + ", showingDisc " + showingDisconnectedConnection + ")"); 979b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // keepScreenOn == true means we'll hold a full wake lock: 980b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP); 981b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 982b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 983b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 984b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Wrapper around the PowerManagerService.preventScreenOn() API. 985b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This allows the in-call UI to prevent the screen from turning on 986b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * even if a subsequent call to updateWakeState() causes us to acquire 987b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * a full wake lock. 988b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 989b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /* package */ void preventScreenOn(boolean prevent) { 990796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "- preventScreenOn(" + prevent + ")..."); 991b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project try { 992b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPowerManagerService.preventScreenOn(prevent); 993b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } catch (RemoteException e) { 994b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Log.w(LOG_TAG, "mPowerManagerService.preventScreenOn() failed: " + e); 995b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 996b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 997b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 9984472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /** 9994472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Sets or clears the flag that tells the PowerManager that touch 10004472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * (and cheek) events should NOT be considered "user activity". 10014472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * 10024472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Since the in-call UI is totally insensitive to touch in most 10034472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * states, we set this flag whenever the InCallScreen is in the 10044472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * foreground. (Otherwise, repeated unintentional touches could 10054472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * prevent the device from going to sleep.) 10064472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * 10074472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * There *are* some some touch events that really do count as user 10084472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * activity, though. For those, we need to manually poke the 10094472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * PowerManager's userActivity method; see pokeUserActivity(). 10104472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown */ 10114472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /* package */ void setIgnoreTouchUserActivity(boolean ignore) { 10124472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (VDBG) Log.d(LOG_TAG, "setIgnoreTouchUserActivity(" + ignore + ")..."); 10134472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown mIgnoreTouchUserActivity = ignore; 10144472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown updatePokeLock(); 10154472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 10164472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown 10174472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /** 10184472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * Manually pokes the PowerManager's userActivity method. Since we 10194472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * hold the POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS poke lock while 10204472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * the InCallScreen is active, we need to do this for touch events 10214472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * that really do count as user activity (like DTMF key presses, or 10224472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown * unlocking the "touch lock" overlay.) 10234472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown */ 10244472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown /* package */ void pokeUserActivity() { 10254472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown if (VDBG) Log.d(LOG_TAG, "pokeUserActivity()..."); 10264472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown try { 10274472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown mPowerManagerService.userActivity(SystemClock.uptimeMillis(), false); 10284472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } catch (RemoteException e) { 10294472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown Log.w(LOG_TAG, "mPowerManagerService.userActivity() failed: " + e); 10304472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 10314472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown } 10324472ce7a7e8568b4bb66098c4e4a2e71099167acDavid Brown 103358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown /** 1034445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Set when a new outgoing call is beginning, so we can update 1035445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * the proximity sensor state. 1036445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Cleared when the InCallScreen is no longer in the foreground, 1037445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * in case the call fails without changing the telephony state. 1038445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood */ 1039445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /* package */ void setBeginningCall(boolean beginning) { 1040445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // Note that we are beginning a new call, for proximity sensor support 1041445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood mBeginningCall = beginning; 1042445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // Update the Proximity sensor based on mBeginningCall state 1043445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood updateProximitySensorMode(phone.getState()); 1044445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood } 1045445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 1046445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /** 104758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * Updates the wake lock used to control proximity sensor behavior, 104858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * based on the current state of the phone. This method is called 104958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * from the CallNotifier on any phone state change. 105058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 105158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * On devices that have a proximity sensor, to avoid false touches 105258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * during a call, we hold a PROXIMITY_SCREEN_OFF_WAKE_LOCK wake lock 105358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * whenever the phone is off hook. (When held, that wake lock causes 105458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * the screen to turn off automatically when the sensor detects an 105558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * object close to the screen.) 105658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 105758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * This method is a no-op for devices that don't have a proximity 105858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * sensor. 105958de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 106058de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * Note this method doesn't care if the InCallScreen is the foreground 106158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * activity or not. That's because we want the proximity sensor to be 106258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * enabled any time the phone is in use, to avoid false cheek events 106358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * for whatever app you happen to be running. 106458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 1065d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * Proximity wake lock will *not* be held if any one of the 1066d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * conditions is true while on a call: 1067d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 1) If the audio is routed via Bluetooth 1068d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 2) If a wired headset is connected 1069d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 3) if the speaker is ON 1070d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai * 4) If the slider is open(i.e. the hardkeyboard is *not* hidden) 107158de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * 107258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown * @param state current state of the phone (see {@link Phone#State}) 107358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown */ 107458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown /* package */ void updateProximitySensorMode(Phone.State state) { 1075445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: state = " + state); 1076d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 1077039a8e51aa4a3ed27ad788dd5f1e043446517d92Mike Lockwood if (proximitySensorModeEnabled()) { 1078445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (((state == Phone.State.OFFHOOK) || mBeginningCall) 1079d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai && !(isHeadsetPlugged() 1080d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai || PhoneUtils.isSpeakerOn(this) 1081d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai || ((mBtHandsfree != null) && mBtHandsfree.isAudioOn()) 1082d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai || mIsHardKeyboardOpen)) { 108358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // Phone is in use! Arrange for the screen to turn off 108458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // automatically when the sensor detects a close object. 108558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (!mProximityWakeLock.isHeld()) { 108658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (DBG) Log.d(LOG_TAG, "updateProximitySensorMode: acquiring..."); 108758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown mProximityWakeLock.acquire(); 10885601d455864ffb08ff995ba3fc162580dc7b8998Mike Lockwood // disable keyguard while we are using the proximity sensor 10895601d455864ffb08ff995ba3fc162580dc7b8998Mike Lockwood disableKeyguard(); 1090f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown } else { 1091445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: lock already held."); 109258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 109358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } else { 109458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // Phone is either idle, or ringing. We don't want any 109558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown // special proximity sensor behavior in either case. 109658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (mProximityWakeLock.isHeld()) { 109758de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown if (DBG) Log.d(LOG_TAG, "updateProximitySensorMode: releasing..."); 109858de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown mProximityWakeLock.release(); 10995601d455864ffb08ff995ba3fc162580dc7b8998Mike Lockwood reenableKeyguard(); 1100f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown } else { 1101445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: lock already released."); 110258de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 110358de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 110458de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 110558de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown } 110658de0c5d10bbf48f6316a12495cd1c176a11a6feDavid Brown 1107f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown /** 1108445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Notifies the phone app when the phone state changes. 1109445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood * Currently used only for proximity sensor support. 1110445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood */ 1111445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /* package */ void updatePhoneState(Phone.State state) { 1112445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood if (state != mLastPhoneState) { 1113445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood mLastPhoneState = state; 1114445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood updateProximitySensorMode(state); 1115445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood // clear our beginning call flag 1116445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood mBeginningCall = false; 1117445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood } 1118445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood } 1119445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood 1120445c9030dc93750a8209ace086ea3820ee33f0b1Mike Lockwood /** 1121f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown * @return true if this device supports the "proximity sensor 1122f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown * auto-lock" feature while in-call (see updateProximitySensorMode()). 1123f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown */ 1124f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown /* package */ boolean proximitySensorModeEnabled() { 1125f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown return (mProximityWakeLock != null); 1126f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown } 1127f0f6d973992a988c0fc801ba80f826c8edf02c03David Brown 1128b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project KeyguardManager getKeyguardManager() { 1129b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mKeyguardManager; 1130b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1131b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1132b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private void onMMIComplete(AsyncResult r) { 1133796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "onMMIComplete()..."); 1134b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project MmiCode mmiCode = (MmiCode) r.result; 1135b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project PhoneUtils.displayMMIComplete(phone, getInstance(), mmiCode, null, null); 1136b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1137b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1138a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville private void initForNewRadioTechnology() { 113987258b2b589c3afea4b89b840251012378e0d3b4David Brown if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology..."); 1140a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 114160877272381161201c6969dea501e683705d6e32w if (phone.getPhoneName().equals("CDMA")) { 114260877272381161201c6969dea501e683705d6e32w // Create an instance of CdmaPhoneCallState and initialize it to IDLE 114360877272381161201c6969dea501e683705d6e32w cdmaPhoneCallState = new CdmaPhoneCallState(); 114460877272381161201c6969dea501e683705d6e32w cdmaPhoneCallState.CdmaPhoneCallStateInit(); 114560877272381161201c6969dea501e683705d6e32w 114660877272381161201c6969dea501e683705d6e32w //create instances of CDMA OTA data classes 114760877272381161201c6969dea501e683705d6e32w if (cdmaOtaProvisionData == null) { 114860877272381161201c6969dea501e683705d6e32w cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData(); 114960877272381161201c6969dea501e683705d6e32w } 115060877272381161201c6969dea501e683705d6e32w if (cdmaOtaConfigData == null) { 115160877272381161201c6969dea501e683705d6e32w cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData(); 115260877272381161201c6969dea501e683705d6e32w } 115360877272381161201c6969dea501e683705d6e32w if (cdmaOtaScreenState == null) { 115460877272381161201c6969dea501e683705d6e32w cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState(); 115560877272381161201c6969dea501e683705d6e32w } 115660877272381161201c6969dea501e683705d6e32w } 115760877272381161201c6969dea501e683705d6e32w 1158a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville ringer.updateRingerContextAfterRadioTechnologyChange(this.phone); 1159a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange(); 116087258b2b589c3afea4b89b840251012378e0d3b4David Brown if (mBtHandsfree != null) { 1161a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville mBtHandsfree.updateBtHandsfreeAfterRadioTechnologyChange(); 1162a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } 116387258b2b589c3afea4b89b840251012378e0d3b4David Brown if (mInCallScreen != null) { 116487258b2b589c3afea4b89b840251012378e0d3b4David Brown mInCallScreen.updateAfterRadioTechnologyChange(); 116587258b2b589c3afea4b89b840251012378e0d3b4David Brown } 1166a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 116787258b2b589c3afea4b89b840251012378e0d3b4David Brown // Update registration for ICC status after radio technology change 1168a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville IccCard sim = phone.getIccCard(); 1169a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville if (sim != null) { 117087258b2b589c3afea4b89b840251012378e0d3b4David Brown if (DBG) Log.d(LOG_TAG, "Update registration for ICC status..."); 1171a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 1172a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville //Register all events new to the new active phone 1173a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null); 1174a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null); 1175a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null); 1176a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } 1177a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } 1178a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville 1179404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1180404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville /** 1181b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @return true if a wired headset is currently plugged in. 1182b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 1183b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * @see Intent.ACTION_HEADSET_PLUG (which we listen for in mReceiver.onReceive()) 1184b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 1185b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean isHeadsetPlugged() { 1186b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return mIsHeadsetPlugged; 1187b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1188b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 11898bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /** 11908bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @return true if the onscreen UI should currently be showing the 11918bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * special "bluetooth is active" indication in a couple of places (in 11928bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * which UI elements turn blue and/or show the bluetooth logo.) 11938bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 11948bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * This depends on the BluetoothHeadset state *and* the current 11958bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * telephony state; see shouldShowBluetoothIndication(). 11968bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 11978bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @see CallCard 11988bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @see NotificationMgr.updateInCallNotification 11998bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project */ 12008bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /* package */ boolean showBluetoothIndication() { 12018bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project return mShowBluetoothIndication; 12028bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12038bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12048bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /** 12058bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * Recomputes the mShowBluetoothIndication flag based on the current 12068bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * bluetooth state and current telephony state. 12078bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 12088bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * This needs to be called any time the bluetooth headset state or the 12098bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * telephony state changes. 12104b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project * 12114b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project * @param forceUiUpdate if true, force the UI elements that care 12124b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project * about this flag to update themselves. 12138bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project */ 12144b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project /* package */ void updateBluetoothIndication(boolean forceUiUpdate) { 12158bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project mShowBluetoothIndication = shouldShowBluetoothIndication(mBluetoothHeadsetState, 12164b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project mBluetoothHeadsetAudioState, 12178bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project phone); 12184b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project if (forceUiUpdate) { 12194b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // Post Handler messages to the various components that might 12204b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // need to be refreshed based on the new state. 12214b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project if (isShowingCallScreen()) mInCallScreen.updateBluetoothIndication(); 12224b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project mHandler.sendEmptyMessage(EVENT_UPDATE_INCALL_NOTIFICATION); 12234b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project } 1224d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai 1225d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai // Update the Proximity sensor based on Bluetooth audio state 1226d3744ff481f7d96669740b015a39d7441208152bAbhishek Pillai updateProximitySensorMode(phone.getState()); 12278bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12288bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12298bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project /** 12308bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * UI policy helper function for the couple of places in the UI that 12318bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * have some way of indicating that "bluetooth is in use." 12328bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * 12338bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @return true if the onscreen UI should indicate that "bluetooth is in use", 12348bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * based on the specified bluetooth headset state, and the 12358bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * current state of the phone. 12368bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project * @see showBluetoothIndication() 12378bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project */ 12388bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project private static boolean shouldShowBluetoothIndication(int bluetoothState, 12394b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project int bluetoothAudioState, 12408bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project Phone phone) { 12418bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // We want the UI to indicate that "bluetooth is in use" in two 12428bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // slightly different cases: 12438bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // 12448bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // (a) The obvious case: if a bluetooth headset is currently in 12458bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // use for an ongoing call. 12468bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // 12478bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // (b) The not-so-obvious case: if an incoming call is ringing, 12488bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // and we expect that audio *will* be routed to a bluetooth 12498bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // headset once the call is answered. 12508bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12518bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project switch (phone.getState()) { 12528bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project case OFFHOOK: 12538bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // This covers normal active calls, and also the case if 12544b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // the foreground call is DIALING or ALERTING. In this 12554b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // case, bluetooth is considered "active" if a headset 12564b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project // is connected *and* audio is being routed to it. 12574b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project return ((bluetoothState == BluetoothHeadset.STATE_CONNECTED) 12584b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project && (bluetoothAudioState == BluetoothHeadset.AUDIO_STATE_CONNECTED)); 12598bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12608bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project case RINGING: 12618bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // If an incoming call is ringing, we're *not* yet routing 12628bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // audio to the headset (since there's no in-call audio 12638bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // yet!) In this case, if a bluetooth headset is 12648bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // connected at all, we assume that it'll become active 12658bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project // once the user answers the phone. 12668bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project return (bluetoothState == BluetoothHeadset.STATE_CONNECTED); 12678bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 12688bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project default: // Presumably IDLE 12698bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project return false; 12708bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12718bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project } 12728bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project 1273b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1274b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 1275b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Receiver for misc intent broadcasts the Phone app cares about. 1276b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 1277b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private class PhoneAppBroadcastReceiver extends BroadcastReceiver { 1278b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 1279b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onReceive(Context context, Intent intent) { 1280b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project String action = intent.getAction(); 1281b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) { 1282b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean enabled = System.getInt(getContentResolver(), 1283b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project System.AIRPLANE_MODE_ON, 0) == 0; 1284b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project phone.setRadioPower(enabled); 128518e0a07cc700234f5a02fe10eee9b3ea10db58b3Nick Pelly } else if (action.equals(BluetoothHeadset.ACTION_STATE_CHANGED)) { 128618e0a07cc700234f5a02fe10eee9b3ea10db58b3Nick Pelly mBluetoothHeadsetState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, 12878bb467d9a1106dedd79e42166c7b6e9fc9a897a7The Android Open Source Project BluetoothHeadset.STATE_ERROR); 1288796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: HEADSET_STATE_CHANGED_ACTION"); 1289796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "==> new state: " + mBluetoothHeadsetState); 12904b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project updateBluetoothIndication(true); // Also update any visible UI if necessary 129118e0a07cc700234f5a02fe10eee9b3ea10db58b3Nick Pelly } else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) { 12924b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project mBluetoothHeadsetAudioState = 129318e0a07cc700234f5a02fe10eee9b3ea10db58b3Nick Pelly intent.getIntExtra(BluetoothHeadset.EXTRA_AUDIO_STATE, 12944b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project BluetoothHeadset.STATE_ERROR); 1295796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: HEADSET_AUDIO_STATE_CHANGED_ACTION"); 1296796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "==> new state: " + mBluetoothHeadsetAudioState); 12974b8337277ec2e375c3536b97c40e6617a7b12990The Android Open Source Project updateBluetoothIndication(true); // Also update any visible UI if necessary 1298b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { 129987258b2b589c3afea4b89b840251012378e0d3b4David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED"); 130087258b2b589c3afea4b89b840251012378e0d3b4David Brown if (VDBG) Log.d(LOG_TAG, "- state: " + intent.getStringExtra(Phone.STATE_KEY)); 130187258b2b589c3afea4b89b840251012378e0d3b4David Brown if (VDBG) Log.d(LOG_TAG, "- reason: " 130287258b2b589c3afea4b89b840251012378e0d3b4David Brown + intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY)); 13034079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project 13044079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // The "data disconnected due to roaming" notification is 13054079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // visible if you've lost data connectivity because you're 13064079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // roaming and you have the "data roaming" feature turned off. 13074079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project boolean disconnectedDueToRoaming = false; 1308b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if ("DISCONNECTED".equals(intent.getStringExtra(Phone.STATE_KEY))) { 1309b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY); 1310b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (Phone.REASON_ROAMING_ON.equals(reason)) { 13114079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // We just lost our data connection, and the reason 13124079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // is that we started roaming. This implies that 13134079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // the user has data roaming turned off. 13144079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project disconnectedDueToRoaming = true; 1315b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1316b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 13174079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project mHandler.sendEmptyMessage(disconnectedDueToRoaming 13184079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project ? EVENT_DATA_ROAMING_DISCONNECTED 13194079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project : EVENT_DATA_ROAMING_OK); 1320b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(Intent.ACTION_HEADSET_PLUG)) { 1321796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_HEADSET_PLUG"); 1322796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, " state: " + intent.getIntExtra("state", 0)); 1323796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, " name: " + intent.getStringExtra("name")); 1324b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mIsHeadsetPlugged = (intent.getIntExtra("state", 0) == 1); 1325b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mHandler.sendMessage(mHandler.obtainMessage(EVENT_WIRED_HEADSET_PLUG, 0)); 1326b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if (action.equals(Intent.ACTION_BATTERY_LOW)) { 1327796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_BATTERY_LOW"); 1328b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project notifier.sendBatteryLow(); // Play a warning tone if in-call 1329b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } else if ((action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) && 1330b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project (mPUKEntryActivity != null)) { 1331b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // if an attempt to un-PUK-lock the device was made, while we're 1332b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // receiving this state change notification, notify the handler. 1333b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has 1334b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // been attempted. 1335b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED, 1336a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE))); 1337a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) { 1338a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville String newPhone = intent.getStringExtra(Phone.PHONE_NAME_KEY); 1339a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active."); 1340a69de9f9a2e99fe08f0009bb218b95ed7985c575Wink Saville initForNewRadioTechnology(); 1341404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) { 1342404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville handleServiceStateChanged(intent); 1343abeff00b5242e795baa8f5271525c5911f649993Wink Saville } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) { 13444e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski if(phone.getPhoneName().equals("CDMA")) { 13454e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp."); 13464e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski // Start Emergency Callback Mode service 13474e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski if (intent.getBooleanExtra("phoneinECMState", false)) { 13484e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski context.startService(new Intent(context, 13494e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski EmergencyCallbackModeService.class)); 13504e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski } 13514e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski } else { 13524e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski Log.e(LOG_TAG, "Error! Emergency Callback Mode not supported for " + 13534e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski phone.getPhoneName() + " phones"); 13544e879989bb6e23763802ceb128e8785f8f063ac0Robert Kowalski } 1355b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1356b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1357b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1358b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1359b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project /** 1360b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Broadcast receiver for the ACTION_MEDIA_BUTTON broadcast intent. 1361b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 1362b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * This functionality isn't lumped in with the other intents in 1363b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * PhoneAppBroadcastReceiver because we instantiate this as a totally 1364b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * separate BroadcastReceiver instance, since we need to manually 1365b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * adjust its IntentFilter's priority (to make sure we get these 1366b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * intents *before* the media player.) 1367b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 1368b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private class MediaButtonBroadcastReceiver extends BroadcastReceiver { 1369b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 1370b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onReceive(Context context, Intent intent) { 1371b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); 1372796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, 1373b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project "MediaButtonBroadcastReceiver.onReceive()... event = " + event); 1374b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if ((event != null) 1375b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project && (event.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK) 1376b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project && (event.getAction() == KeyEvent.ACTION_DOWN)) { 1377b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 1378b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (event.getRepeatCount() == 0) { 1379b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project // Mute ONLY on the initial keypress. 1380796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "MediaButtonBroadcastReceiver: HEADSETHOOK down!"); 1381b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project boolean consumed = PhoneUtils.handleHeadsetHook(phone); 1382796c70c99bc39295bf685061056f06ab8949c742David Brown if (VDBG) Log.d(LOG_TAG, "==> handleHeadsetHook(): consumed = " + consumed); 1383b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (consumed) { 1384b8df8173e1a0ea8ba89cea984176216201c4d5e7Paul Berman // If a headset is attached and the press is consumed, also update 1385b8df8173e1a0ea8ba89cea984176216201c4d5e7Paul Berman // any UI items (such as an InCallScreen mute button) that may need to 1386b8df8173e1a0ea8ba89cea984176216201c4d5e7Paul Berman // be updated if their state changed. 1387b8df8173e1a0ea8ba89cea984176216201c4d5e7Paul Berman if (isShowingCallScreen()) { 1388b8df8173e1a0ea8ba89cea984176216201c4d5e7Paul Berman mInCallScreen.requestUpdateTouchUi(); 1389b8df8173e1a0ea8ba89cea984176216201c4d5e7Paul Berman } 1390b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project abortBroadcast(); 1391b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 13924079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project } else if (phone.getState() != Phone.State.IDLE) { 13934079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // As for any DOWN events other than the initial press, we consume 13944079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // (and ignore) those too if the phone is in use. (Otherwise the 13954079f559beb3e414036056b4b33ad40de5e89c4aThe Android Open Source Project // music player will handle them, which would be confusing.) 1396b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project abortBroadcast(); 1397b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1398b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1399b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1400b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 1401404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1402404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville private void handleServiceStateChanged(Intent intent) { 14034e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville /** 14044e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * This used to handle updating EriTextWidgetProvider this routine 14054e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * and and listening for ACTION_SERVICE_STATE_CHANGED intents could 14064e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * be removed. But leaving just in case it might be needed in the near 14074e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville * future. 14084e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville */ 14094e41cdf8b65434a324f3e83be1095689ddabd153Wink Saville 1410404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville // If service just returned, start sending out the queued messages 1411404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville ServiceState ss = ServiceState.newFromBundle(intent.getExtras()); 1412404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1413404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville boolean hasService = true; 1414404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville boolean isCdma = false; 1415404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville String eriText = ""; 1416404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville 1417404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville if (ss != null) { 1418404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville int state = ss.getState(); 141999d10538d840f0103c36dafa44db9f649ca884c8johnwang NotificationMgr.getDefault().updateNetworkSelection(state); 1420404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville switch (state) { 1421404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville case ServiceState.STATE_OUT_OF_SERVICE: 1422404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville case ServiceState.STATE_POWER_OFF: 1423404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville hasService = false; 1424404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville break; 1425404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } 1426404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } else { 1427404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville hasService = false; 1428404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } 1429404edc94de563aef5fd5ba48be9114a970cb93bbWink Saville } 1430af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 1431af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public boolean isOtaCallInActiveState() { 1432af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville boolean otaCallActive = false; 1433af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (mInCallScreen != null) { 1434af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville otaCallActive = mInCallScreen.isOtaCallInActiveState(); 1435af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 1436af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (DBG) Log.d(LOG_TAG, "PhoneApp - isOtaCallInActiveState " + otaCallActive); 1437af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville return otaCallActive; 1438af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 1439af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville 1440af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville public boolean isOtaCallInEndState() { 1441af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville boolean otaCallEnded = false; 1442af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (mInCallScreen != null) { 1443af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville otaCallEnded = mInCallScreen.isOtaCallInEndState(); 1444af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 1445af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville if (DBG) Log.d(LOG_TAG, "PhoneApp - isOtaCallInEndState " + otaCallEnded); 1446af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville return otaCallEnded; 1447af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville } 144873caead845b30580010a7502e4b7551d21dfa265Matthew Sun 144973caead845b30580010a7502e4b7551d21dfa265Matthew Sun // it is safe to call clearOtaState() even if the InCallScreen isn't active 145073caead845b30580010a7502e4b7551d21dfa265Matthew Sun public void clearOtaState() { 145173caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - clearOtaState ..."); 145273caead845b30580010a7502e4b7551d21dfa265Matthew Sun if ((mInCallScreen != null) 145373caead845b30580010a7502e4b7551d21dfa265Matthew Sun && (mInCallScreen.otaUtils != null)) { 145473caead845b30580010a7502e4b7551d21dfa265Matthew Sun mInCallScreen.otaUtils.cleanOtaScreen(); 145573caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - clearOtaState clears OTA screen"); 145673caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 145773caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 145873caead845b30580010a7502e4b7551d21dfa265Matthew Sun 145973caead845b30580010a7502e4b7551d21dfa265Matthew Sun // it is safe to call dismissOtaDialogs() even if the InCallScreen isn't active 146073caead845b30580010a7502e4b7551d21dfa265Matthew Sun public void dismissOtaDialogs() { 146173caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - dismissOtaDialogs ..."); 146273caead845b30580010a7502e4b7551d21dfa265Matthew Sun if ((mInCallScreen != null) 146373caead845b30580010a7502e4b7551d21dfa265Matthew Sun && (mInCallScreen.otaUtils != null)) { 146473caead845b30580010a7502e4b7551d21dfa265Matthew Sun mInCallScreen.otaUtils.dismissAllOtaDialogs(); 146573caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - dismissOtaDialogs clears OTA dialogs"); 146673caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 146773caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 146873caead845b30580010a7502e4b7551d21dfa265Matthew Sun 146973caead845b30580010a7502e4b7551d21dfa265Matthew Sun // it is safe to call clearInCallScreenMode() even if the InCallScreen isn't active 147073caead845b30580010a7502e4b7551d21dfa265Matthew Sun public void clearInCallScreenMode() { 147173caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (DBG) Log.d(LOG_TAG, "PhoneApp - clearInCallScreenMode ..."); 147273caead845b30580010a7502e4b7551d21dfa265Matthew Sun if (mInCallScreen != null) { 147373caead845b30580010a7502e4b7551d21dfa265Matthew Sun mInCallScreen.resetInCallScreenMode(); 147473caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 147573caead845b30580010a7502e4b7551d21dfa265Matthew Sun } 1476b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project} 1477