blob: 94a4661069df2272212949cba2b2a00ac6d13961 [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.phone;
18
19import android.app.Activity;
20import android.app.KeyguardManager;
21import android.app.PendingIntent;
22import android.app.ProgressDialog;
Yorke Leeca6ec3b2013-08-29 14:21:43 -070023import android.app.TaskStackBuilder;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070024import android.bluetooth.BluetoothAdapter;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070025import android.bluetooth.IBluetoothHeadsetPhone;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070026import android.content.BroadcastReceiver;
27import android.content.ComponentName;
28import android.content.ContentResolver;
29import android.content.Context;
30import android.content.ContextWrapper;
31import android.content.Intent;
32import android.content.IntentFilter;
33import android.content.ServiceConnection;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070034import android.media.AudioManager;
35import android.net.Uri;
36import android.os.AsyncResult;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070037import android.os.Handler;
38import android.os.IBinder;
39import android.os.IPowerManager;
40import android.os.Message;
41import android.os.PowerManager;
42import android.os.RemoteException;
43import android.os.ServiceManager;
44import android.os.SystemClock;
45import android.os.SystemProperties;
46import android.os.UpdateLock;
47import android.os.UserHandle;
48import android.preference.PreferenceManager;
49import android.provider.Settings.System;
50import android.telephony.ServiceState;
Andrew Lee2fcb6c32014-12-04 14:52:35 -080051import android.telephony.SubscriptionInfo;
Andrew Lee385019f2014-11-24 14:19:50 -080052import android.telephony.SubscriptionManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070053import android.util.Log;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070054
55import com.android.internal.telephony.Call;
56import com.android.internal.telephony.CallManager;
57import com.android.internal.telephony.IccCard;
58import com.android.internal.telephony.IccCardConstants;
59import com.android.internal.telephony.MmiCode;
60import com.android.internal.telephony.Phone;
61import com.android.internal.telephony.PhoneConstants;
62import com.android.internal.telephony.PhoneFactory;
Andrew Lee385019f2014-11-24 14:19:50 -080063import com.android.internal.telephony.SubscriptionController;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070064import com.android.internal.telephony.TelephonyCapabilities;
65import com.android.internal.telephony.TelephonyIntents;
Santos Cordon352ff652014-05-30 01:41:45 -070066import com.android.phone.common.CallLogAsync;
Andrew Leefb7f92e2015-02-26 16:23:32 -080067import com.android.phone.settings.SettingsConstants;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070068import com.android.server.sip.SipService;
69
Andrew Lee385019f2014-11-24 14:19:50 -080070import java.util.ArrayList;
71import java.util.List;
72
Santos Cordon7d4ddf62013-07-10 11:58:08 -070073/**
74 * Global state for the telephony subsystem when running in the primary
75 * phone process.
76 */
Sailesh Nepalbf900542014-07-15 16:18:32 -070077public class PhoneGlobals extends ContextWrapper {
Andrew Lee83383e42014-10-31 12:42:28 -070078 public static final String LOG_TAG = "PhoneApp";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070079
80 /**
81 * Phone app-wide debug level:
82 * 0 - no debug logging
83 * 1 - normal debug logging if ro.debuggable is set (which is true in
84 * "eng" and "userdebug" builds but not "user" builds)
85 * 2 - ultra-verbose debug logging
86 *
87 * Most individual classes in the phone app have a local DBG constant,
88 * typically set to
89 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
90 * or else
91 * (PhoneApp.DBG_LEVEL >= 2)
92 * depending on the desired verbosity.
93 *
94 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
95 */
Andrew Lee88b51e22014-10-29 15:48:51 -070096 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070097
98 private static final boolean DBG =
99 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
100 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
101
102 // Message codes; see mHandler below.
103 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700104 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700105 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
106 private static final int EVENT_DATA_ROAMING_OK = 11;
107 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
108 private static final int EVENT_DOCK_STATE_CHANGED = 13;
Sailesh Nepalbf900542014-07-15 16:18:32 -0700109 private static final int EVENT_START_SIP_SERVICE = 14;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700110
111 // The MMI codes are also used by the InCallScreen.
112 public static final int MMI_INITIATE = 51;
113 public static final int MMI_COMPLETE = 52;
114 public static final int MMI_CANCEL = 53;
115 // Don't use message codes larger than 99 here; those are reserved for
116 // the individual Activities of the Phone UI.
117
118 /**
119 * Allowable values for the wake lock code.
120 * SLEEP means the device can be put to sleep.
121 * PARTIAL means wake the processor, but we display can be kept off.
122 * FULL means wake both the processor and the display.
123 */
124 public enum WakeState {
125 SLEEP,
126 PARTIAL,
127 FULL
128 }
129
130 /**
131 * Intent Action used for hanging up the current call from Notification bar. This will
132 * choose first ringing call, first active call, or first background call (typically in
133 * HOLDING state).
134 */
135 public static final String ACTION_HANG_UP_ONGOING_CALL =
136 "com.android.phone.ACTION_HANG_UP_ONGOING_CALL";
137
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700138 private static PhoneGlobals sMe;
139
140 // A few important fields we expose to the rest of the package
141 // directly (rather than thru set/get methods) for efficiency.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700142 CallController callController;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700143 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700144 CallNotifier notifier;
145 CallerInfoCache callerInfoCache;
Santos Cordon63a84242013-07-23 13:32:52 -0700146 NotificationMgr notificationMgr;
Santos Cordon63a84242013-07-23 13:32:52 -0700147 PhoneInterfaceManager phoneMgr;
148
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700149 private BluetoothManager bluetoothManager;
Santos Cordon69a69192013-08-22 14:25:42 -0700150 private CallGatewayManager callGatewayManager;
Santos Cordon63a84242013-07-23 13:32:52 -0700151 private CallStateMonitor callStateMonitor;
Santos Cordon63a84242013-07-23 13:32:52 -0700152
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700153 static int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
154 static boolean sVoiceCapable = true;
155
156 // Internal PhoneApp Call state tracker
157 CdmaPhoneCallState cdmaPhoneCallState;
158
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700159 // The currently-active PUK entry activity and progress dialog.
160 // Normally, these are the Emergency Dialer and the subsequent
161 // progress dialog. null if there is are no such objects in
162 // the foreground.
163 private Activity mPUKEntryActivity;
164 private ProgressDialog mPUKEntryProgressDialog;
165
166 private boolean mIsSimPinEnabled;
167 private String mCachedSimPin;
168
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700169 // True if we are beginning a call, but the phone state has not changed yet
170 private boolean mBeginningCall;
Yorke Lee4d2db1c2014-11-06 11:37:09 -0800171 private boolean mDataDisconnectedDueToRoaming = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700172
173 // Last phone state seen by updatePhoneState()
174 private PhoneConstants.State mLastPhoneState = PhoneConstants.State.IDLE;
175
176 private WakeState mWakeState = WakeState.SLEEP;
177
178 private PowerManager mPowerManager;
179 private IPowerManager mPowerManagerService;
180 private PowerManager.WakeLock mWakeLock;
181 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700182 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700183
184 private UpdateLock mUpdateLock;
185
186 // Broadcast receiver for various intent broadcasts (see onCreate())
187 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
188
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700189 /** boolean indicating restoring mute state on InCallScreen.onResume() */
190 private boolean mShouldRestoreMuteOnInCallResume;
191
192 /**
193 * The singleton OtaUtils instance used for OTASP calls.
194 *
195 * The OtaUtils instance is created lazily the first time we need to
196 * make an OTASP call, regardless of whether it's an interactive or
197 * non-interactive OTASP call.
198 */
199 public OtaUtils otaUtils;
200
201 // Following are the CDMA OTA information Objects used during OTA Call.
202 // cdmaOtaProvisionData object store static OTA information that needs
203 // to be maintained even during Slider open/close scenarios.
204 // cdmaOtaConfigData object stores configuration info to control visiblity
205 // of each OTA Screens.
206 // cdmaOtaScreenState object store OTA Screen State information.
207 public OtaUtils.CdmaOtaProvisionData cdmaOtaProvisionData;
208 public OtaUtils.CdmaOtaConfigData cdmaOtaConfigData;
209 public OtaUtils.CdmaOtaScreenState cdmaOtaScreenState;
210 public OtaUtils.CdmaOtaInCallScreenUiState cdmaOtaInCallScreenUiState;
211
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700212 /**
213 * Set the restore mute state flag. Used when we are setting the mute state
214 * OUTSIDE of user interaction {@link PhoneUtils#startNewCall(Phone)}
215 */
216 /*package*/void setRestoreMuteOnInCallResume (boolean mode) {
217 mShouldRestoreMuteOnInCallResume = mode;
218 }
219
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700220 Handler mHandler = new Handler() {
221 @Override
222 public void handleMessage(Message msg) {
223 PhoneConstants.State phoneState;
224 switch (msg.what) {
225 // Starts the SIP service. It's a no-op if SIP API is not supported
226 // on the deivce.
227 // TODO: Having the phone process host the SIP service is only
228 // temporary. Will move it to a persistent communication process
229 // later.
230 case EVENT_START_SIP_SERVICE:
231 SipService.start(getApplicationContext());
232 break;
233
234 // TODO: This event should be handled by the lock screen, just
235 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
236 case EVENT_SIM_NETWORK_LOCKED:
237 if (getResources().getBoolean(R.bool.ignore_sim_network_locked_events)) {
238 // Some products don't have the concept of a "SIM network lock"
239 Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; "
240 + "not showing 'SIM network unlock' PIN entry screen");
241 } else {
242 // Normal case: show the "SIM network unlock" PIN entry screen.
243 // The user won't be able to do anything else until
244 // they enter a valid SIM network PIN.
245 Log.i(LOG_TAG, "show sim depersonal panel");
246 IccNetworkDepersonalizationPanel ndpPanel =
247 new IccNetworkDepersonalizationPanel(PhoneGlobals.getInstance());
248 ndpPanel.show();
249 }
250 break;
251
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700252 case EVENT_DATA_ROAMING_DISCONNECTED:
253 notificationMgr.showDataDisconnectedRoaming();
254 break;
255
256 case EVENT_DATA_ROAMING_OK:
257 notificationMgr.hideDataDisconnectedRoaming();
258 break;
259
260 case MMI_COMPLETE:
261 onMMIComplete((AsyncResult) msg.obj);
262 break;
263
264 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800265 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700266 break;
267
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700268 case EVENT_SIM_STATE_CHANGED:
269 // Marks the event where the SIM goes into ready state.
270 // Right now, this is only used for the PUK-unlocking
271 // process.
272 if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY)) {
273 // when the right event is triggered and there
274 // are UI objects in the foreground, we close
275 // them to display the lock panel.
276 if (mPUKEntryActivity != null) {
277 mPUKEntryActivity.finish();
278 mPUKEntryActivity = null;
279 }
280 if (mPUKEntryProgressDialog != null) {
281 mPUKEntryProgressDialog.dismiss();
282 mPUKEntryProgressDialog = null;
283 }
284 }
285 break;
286
287 case EVENT_UNSOL_CDMA_INFO_RECORD:
288 //TODO: handle message here;
289 break;
290
291 case EVENT_DOCK_STATE_CHANGED:
292 // If the phone is docked/undocked during a call, and no wired or BT headset
293 // is connected: turn on/off the speaker accordingly.
294 boolean inDockMode = false;
295 if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
296 inDockMode = true;
297 }
298 if (VDBG) Log.d(LOG_TAG, "received EVENT_DOCK_STATE_CHANGED. Phone inDock = "
299 + inDockMode);
300
301 phoneState = mCM.getState();
302 if (phoneState == PhoneConstants.State.OFFHOOK &&
Santos Cordon593ab382013-08-06 21:58:23 -0700303 !bluetoothManager.isBluetoothHeadsetAudioOn()) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700304 PhoneUtils.turnOnSpeaker(getApplicationContext(), inDockMode, true);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700305 }
306 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700307 }
308 }
309 };
310
311 public PhoneGlobals(Context context) {
312 super(context);
313 sMe = this;
314 }
315
316 public void onCreate() {
317 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
318
319 ContentResolver resolver = getContentResolver();
320
321 // Cache the "voice capable" flag.
322 // This flag currently comes from a resource (which is
323 // overrideable on a per-product basis):
324 sVoiceCapable =
325 getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
326 // ...but this might eventually become a PackageManager "system
327 // feature" instead, in which case we'd do something like:
328 // sVoiceCapable =
329 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
330
Stuart Scottdcf40a92014-12-09 10:45:01 -0800331 if (mCM == null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700332 // Initialize the telephony framework
333 PhoneFactory.makeDefaultPhones(this);
334
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700335 // Start TelephonyDebugService After the default phone is created.
336 Intent intent = new Intent(this, TelephonyDebugService.class);
337 startService(intent);
338
339 mCM = CallManager.getInstance();
Stuart Scottdcf40a92014-12-09 10:45:01 -0800340 boolean hasCdmaPhoneType = false;
341 for (Phone phone : PhoneFactory.getPhones()) {
342 mCM.registerPhone(phone);
343 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
344 hasCdmaPhoneType = true;
345 }
346 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700347
348 // Create the NotificationMgr singleton, which is used to display
349 // status bar icons and control other status bar behavior.
350 notificationMgr = NotificationMgr.init(this);
351
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700352 mHandler.sendEmptyMessage(EVENT_START_SIP_SERVICE);
353
Stuart Scottdcf40a92014-12-09 10:45:01 -0800354 if (hasCdmaPhoneType) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700355 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
356 cdmaPhoneCallState = new CdmaPhoneCallState();
357 cdmaPhoneCallState.CdmaPhoneCallStateInit();
358 }
359
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700360 // before registering for phone state changes
361 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
362 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
363 // lock used to keep the processor awake, when we don't care for the display.
364 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
365 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700366
367 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
368
369 // get a handle to the service so that we can use it later when we
370 // want to set the poke lock.
371 mPowerManagerService = IPowerManager.Stub.asInterface(
372 ServiceManager.getService("power"));
373
374 // Get UpdateLock to suppress system-update related events (e.g. dialog show-up)
375 // during phone calls.
376 mUpdateLock = new UpdateLock("phone");
377
378 if (DBG) Log.d(LOG_TAG, "onCreate: mUpdateLock: " + mUpdateLock);
379
380 CallLogger callLogger = new CallLogger(this, new CallLogAsync());
381
Jay Shrauner21a75342013-11-25 16:14:43 -0800382 callGatewayManager = CallGatewayManager.getInstance();
Santos Cordon69a69192013-08-22 14:25:42 -0700383
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700384 // Create the CallController singleton, which is the interface
385 // to the telephony layer for user-initiated telephony functionality
386 // (like making outgoing calls.)
Santos Cordon69a69192013-08-22 14:25:42 -0700387 callController = CallController.init(this, callLogger, callGatewayManager);
388
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700389 // Create the CallerInfoCache singleton, which remembers custom ring tone and
390 // send-to-voicemail settings.
391 //
392 // The asynchronous caching will start just after this call.
393 callerInfoCache = CallerInfoCache.init(this);
394
395 // Monitors call activity from the telephony layer
396 callStateMonitor = new CallStateMonitor(mCM);
397
Santos Cordon2c2d3cf2013-08-08 03:53:47 -0700398 // Bluetooth manager
Sailesh Nepal23d9ed72014-07-03 09:40:26 -0700399 bluetoothManager = new BluetoothManager();
Santos Cordon2c2d3cf2013-08-08 03:53:47 -0700400
Stuart Scottdcf40a92014-12-09 10:45:01 -0800401 phoneMgr = PhoneInterfaceManager.init(this, PhoneFactory.getDefaultPhone());
Santos Cordon406c0342013-08-28 00:07:47 -0700402
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700403 // Create the CallNotifer singleton, which handles
404 // asynchronous events from the telephony layer (like
405 // launching the incoming-call UI when an incoming call comes
406 // in.)
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800407 notifier = CallNotifier.init(this, callLogger, callStateMonitor, bluetoothManager);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700408
Stuart Scottdcf40a92014-12-09 10:45:01 -0800409 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700410
411 // register for MMI/USSD
412 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
413
414 // register connection tracking to PhoneUtils
415 PhoneUtils.initializeConnectionHandler(mCM);
416
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700417 // Register for misc other intent broadcasts.
418 IntentFilter intentFilter =
419 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700420 intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700421 intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
422 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
423 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
424 intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
425 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700426 registerReceiver(mReceiver, intentFilter);
427
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700428 //set the default values for the preferences in the phone.
429 PreferenceManager.setDefaultValues(this, R.xml.network_setting, false);
430
431 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
432
433 // Make sure the audio mode (along with some
434 // audio-mode-related state of our own) is initialized
435 // correctly, given the current state of the phone.
436 PhoneUtils.setAudioMode(mCM);
437 }
438
Santos Cordon52bc81b2014-10-07 19:55:12 -0700439 cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData();
440 cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData();
441 cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState();
442 cdmaOtaInCallScreenUiState = new OtaUtils.CdmaOtaInCallScreenUiState();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700443
444 // XXX pre-load the SimProvider so that it's ready
445 resolver.getType(Uri.parse("content://icc/adn"));
446
447 // start with the default value to set the mute state.
448 mShouldRestoreMuteOnInCallResume = false;
449
450 // TODO: Register for Cdma Information Records
451 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
452
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700453 // Read HAC settings and configure audio hardware
454 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800455 int hac = android.provider.Settings.System.getInt(
456 getContentResolver(),
457 android.provider.Settings.System.HEARING_AID,
458 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700459 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Andrew Leefb7f92e2015-02-26 16:23:32 -0800460 audioManager.setParameter(SettingsConstants.HAC_KEY,
461 hac == SettingsConstants.HAC_ENABLED
462 ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700463 }
Santos Cordonff506f52013-11-21 19:13:19 -0800464 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700465
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700466 /**
467 * Returns the singleton instance of the PhoneApp.
468 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800469 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700470 if (sMe == null) {
471 throw new IllegalStateException("No PhoneGlobals here!");
472 }
473 return sMe;
474 }
475
476 /**
477 * Returns the singleton instance of the PhoneApp if running as the
478 * primary user, otherwise null.
479 */
480 static PhoneGlobals getInstanceIfPrimary() {
481 return sMe;
482 }
483
484 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800485 * Returns the default phone.
486 *
Andrew Lee385019f2014-11-24 14:19:50 -0800487 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700488 */
Andrew Lee83383e42014-10-31 12:42:28 -0700489 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800490 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700491 }
492
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800493 public static Phone getPhone(int subId) {
494 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800495 }
496
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700497 /* package */ BluetoothManager getBluetoothManager() {
498 return bluetoothManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700499 }
500
Santos Cordonde10b752013-09-19 04:11:33 -0700501 /* package */ CallManager getCallManager() {
502 return mCM;
503 }
504
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700505 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700506 * Returns PendingIntent for hanging up ongoing phone call. This will typically be used from
507 * Notification context.
508 */
509 /* package */ static PendingIntent createHangUpOngoingCallPendingIntent(Context context) {
510 Intent intent = new Intent(PhoneGlobals.ACTION_HANG_UP_ONGOING_CALL, null,
511 context, NotificationBroadcastReceiver.class);
512 return PendingIntent.getBroadcast(context, 0, intent, 0);
513 }
514
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700515 boolean isSimPinEnabled() {
516 return mIsSimPinEnabled;
517 }
518
519 boolean authenticateAgainstCachedSimPin(String pin) {
520 return (mCachedSimPin != null && mCachedSimPin.equals(pin));
521 }
522
523 void setCachedSimPin(String pin) {
524 mCachedSimPin = pin;
525 }
526
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700527 /**
528 * Handles OTASP-related events from the telephony layer.
529 *
530 * While an OTASP call is active, the CallNotifier forwards
531 * OTASP-related telephony events to this method.
532 */
533 void handleOtaspEvent(Message msg) {
534 if (DBG) Log.d(LOG_TAG, "handleOtaspEvent(message " + msg + ")...");
535
536 if (otaUtils == null) {
537 // We shouldn't be getting OTASP events without ever
538 // having started the OTASP call in the first place!
539 Log.w(LOG_TAG, "handleOtaEvents: got an event but otaUtils is null! "
540 + "message = " + msg);
541 return;
542 }
543
544 otaUtils.onOtaProvisionStatusChanged((AsyncResult) msg.obj);
545 }
546
547 /**
548 * Similarly, handle the disconnect event of an OTASP call
549 * by forwarding it to the OtaUtils instance.
550 */
551 /* package */ void handleOtaspDisconnect() {
552 if (DBG) Log.d(LOG_TAG, "handleOtaspDisconnect()...");
553
554 if (otaUtils == null) {
555 // We shouldn't be getting OTASP events without ever
556 // having started the OTASP call in the first place!
557 Log.w(LOG_TAG, "handleOtaspDisconnect: otaUtils is null!");
558 return;
559 }
560
561 otaUtils.onOtaspDisconnect();
562 }
563
564 /**
565 * Sets the activity responsible for un-PUK-blocking the device
566 * so that we may close it when we receive a positive result.
567 * mPUKEntryActivity is also used to indicate to the device that
568 * we are trying to un-PUK-lock the phone. In other words, iff
569 * it is NOT null, then we are trying to unlock and waiting for
570 * the SIM to move to READY state.
571 *
572 * @param activity is the activity to close when PUK has
573 * finished unlocking. Can be set to null to indicate the unlock
574 * or SIM READYing process is over.
575 */
576 void setPukEntryActivity(Activity activity) {
577 mPUKEntryActivity = activity;
578 }
579
580 Activity getPUKEntryActivity() {
581 return mPUKEntryActivity;
582 }
583
584 /**
585 * Sets the dialog responsible for notifying the user of un-PUK-
586 * blocking - SIM READYing progress, so that we may dismiss it
587 * when we receive a positive result.
588 *
589 * @param dialog indicates the progress dialog informing the user
590 * of the state of the device. Dismissed upon completion of
591 * READYing process
592 */
593 void setPukEntryProgressDialog(ProgressDialog dialog) {
594 mPUKEntryProgressDialog = dialog;
595 }
596
597 ProgressDialog getPUKEntryProgressDialog() {
598 return mPUKEntryProgressDialog;
599 }
600
601 /**
602 * Controls whether or not the screen is allowed to sleep.
603 *
604 * Once sleep is allowed (WakeState is SLEEP), it will rely on the
605 * settings for the poke lock to determine when to timeout and let
606 * the device sleep {@link PhoneGlobals#setScreenTimeout}.
607 *
608 * @param ws tells the device to how to wake.
609 */
610 /* package */ void requestWakeState(WakeState ws) {
611 if (VDBG) Log.d(LOG_TAG, "requestWakeState(" + ws + ")...");
612 synchronized (this) {
613 if (mWakeState != ws) {
614 switch (ws) {
615 case PARTIAL:
616 // acquire the processor wake lock, and release the FULL
617 // lock if it is being held.
618 mPartialWakeLock.acquire();
619 if (mWakeLock.isHeld()) {
620 mWakeLock.release();
621 }
622 break;
623 case FULL:
624 // acquire the full wake lock, and release the PARTIAL
625 // lock if it is being held.
626 mWakeLock.acquire();
627 if (mPartialWakeLock.isHeld()) {
628 mPartialWakeLock.release();
629 }
630 break;
631 case SLEEP:
632 default:
633 // release both the PARTIAL and FULL locks.
634 if (mWakeLock.isHeld()) {
635 mWakeLock.release();
636 }
637 if (mPartialWakeLock.isHeld()) {
638 mPartialWakeLock.release();
639 }
640 break;
641 }
642 mWakeState = ws;
643 }
644 }
645 }
646
647 /**
648 * If we are not currently keeping the screen on, then poke the power
649 * manager to wake up the screen for the user activity timeout duration.
650 */
651 /* package */ void wakeUpScreen() {
652 synchronized (this) {
653 if (mWakeState == WakeState.SLEEP) {
654 if (DBG) Log.d(LOG_TAG, "pulse screen lock");
655 mPowerManager.wakeUp(SystemClock.uptimeMillis());
656 }
657 }
658 }
659
660 /**
661 * Sets the wake state and screen timeout based on the current state
662 * of the phone, and the current state of the in-call UI.
663 *
664 * This method is a "UI Policy" wrapper around
665 * {@link PhoneGlobals#requestWakeState} and {@link PhoneGlobals#setScreenTimeout}.
666 *
667 * It's safe to call this method regardless of the state of the Phone
668 * (e.g. whether or not it's idle), and regardless of the state of the
669 * Phone UI (e.g. whether or not the InCallScreen is active.)
670 */
671 /* package */ void updateWakeState() {
672 PhoneConstants.State state = mCM.getState();
673
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700674 // True if the speakerphone is in use. (If so, we *always* use
675 // the default timeout. Since the user is obviously not holding
676 // the phone up to his/her face, we don't need to worry about
677 // false touches, and thus don't need to turn the screen off so
678 // aggressively.)
679 // Note that we need to make a fresh call to this method any
680 // time the speaker state changes. (That happens in
681 // PhoneUtils.turnOnSpeaker().)
682 boolean isSpeakerInUse = (state == PhoneConstants.State.OFFHOOK) && PhoneUtils.isSpeakerOn(this);
683
684 // TODO (bug 1440854): The screen timeout *might* also need to
685 // depend on the bluetooth state, but this isn't as clear-cut as
686 // the speaker state (since while using BT it's common for the
687 // user to put the phone straight into a pocket, in which case the
688 // timeout should probably still be short.)
689
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700690 // Decide whether to force the screen on or not.
691 //
692 // Force the screen to be on if the phone is ringing or dialing,
693 // or if we're displaying the "Call ended" UI for a connection in
694 // the "disconnected" state.
695 // However, if the phone is disconnected while the user is in the
696 // middle of selecting a quick response message, we should not force
697 // the screen to be on.
698 //
699 boolean isRinging = (state == PhoneConstants.State.RINGING);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800700 boolean isDialing = (mCM.getFgPhone().getForegroundCall().getState() == Call.State.DIALING);
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700701 boolean keepScreenOn = isRinging || isDialing;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700702 // keepScreenOn == true means we'll hold a full wake lock:
703 requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP);
704 }
705
706 /**
707 * Manually pokes the PowerManager's userActivity method. Since we
708 * set the {@link WindowManager.LayoutParams#INPUT_FEATURE_DISABLE_USER_ACTIVITY}
709 * flag while the InCallScreen is active when there is no proximity sensor,
710 * we need to do this for touch events that really do count as user activity
711 * (like pressing any onscreen UI elements.)
712 */
713 /* package */ void pokeUserActivity() {
714 if (VDBG) Log.d(LOG_TAG, "pokeUserActivity()...");
715 mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
716 }
717
718 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700719 * Notifies the phone app when the phone state changes.
720 *
Santos Cordonfc309812013-08-20 18:33:16 -0700721 * This method will updates various states inside Phone app (e.g. update-lock state, etc.)
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700722 */
723 /* package */ void updatePhoneState(PhoneConstants.State state) {
724 if (state != mLastPhoneState) {
725 mLastPhoneState = state;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700726
727 // Try to acquire or release UpdateLock.
728 //
729 // Watch out: we don't release the lock here when the screen is still in foreground.
730 // At that time InCallScreen will release it on onPause().
731 if (state != PhoneConstants.State.IDLE) {
732 // UpdateLock is a recursive lock, while we may get "acquire" request twice and
733 // "release" request once for a single call (RINGING + OFFHOOK and IDLE).
734 // We need to manually ensure the lock is just acquired once for each (and this
735 // will prevent other possible buggy situations too).
736 if (!mUpdateLock.isHeld()) {
737 mUpdateLock.acquire();
738 }
739 } else {
Jay Shraunera5d13212013-09-19 13:37:43 -0700740 if (mUpdateLock.isHeld()) {
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700741 mUpdateLock.release();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700742 }
743 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700744 }
745 }
746
747 /* package */ PhoneConstants.State getPhoneState() {
748 return mLastPhoneState;
749 }
750
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700751 KeyguardManager getKeyguardManager() {
752 return mKeyguardManager;
753 }
754
755 private void onMMIComplete(AsyncResult r) {
756 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
757 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800758 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700759 }
760
Stuart Scottdcf40a92014-12-09 10:45:01 -0800761 private void initForNewRadioTechnology(int phoneId) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700762 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
763
Stuart Scottdcf40a92014-12-09 10:45:01 -0800764 final Phone phone = PhoneFactory.getPhone(phoneId);
765
766 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700767 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
768 cdmaPhoneCallState = new CdmaPhoneCallState();
769 cdmaPhoneCallState.CdmaPhoneCallStateInit();
770 }
Santos Cordon52bc81b2014-10-07 19:55:12 -0700771 if (!TelephonyCapabilities.supportsOtasp(phone)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700772 //Clean up OTA data in GSM/UMTS. It is valid only for CDMA
773 clearOtaState();
774 }
775
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700776 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
777 callStateMonitor.updateAfterRadioTechnologyChange();
778
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700779 // Update registration for ICC status after radio technology change
780 IccCard sim = phone.getIccCard();
781 if (sim != null) {
782 if (DBG) Log.d(LOG_TAG, "Update registration for ICC status...");
783
784 //Register all events new to the new active phone
785 sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
786 }
787 }
788
Santos Cordon593ab382013-08-06 21:58:23 -0700789 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700790 * Receiver for misc intent broadcasts the Phone app cares about.
791 */
792 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
793 @Override
794 public void onReceive(Context context, Intent intent) {
795 String action = intent.getAction();
796 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
797 boolean enabled = System.getInt(getContentResolver(),
798 System.AIRPLANE_MODE_ON, 0) == 0;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800799 PhoneUtils.setRadioPower(enabled);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700800 } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800801 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
802 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
803 int phoneId = SubscriptionManager.getPhoneId(subId);
804 String state = intent.getStringExtra(PhoneConstants.STATE_KEY);
805 if (VDBG) {
806 Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED");
807 Log.d(LOG_TAG, "- state: " + state);
808 Log.d(LOG_TAG, "- reason: "
809 + intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
810 Log.d(LOG_TAG, "- subId: " + subId);
811 Log.d(LOG_TAG, "- phoneId: " + phoneId);
812 }
813 Phone phone = SubscriptionManager.isValidPhoneId(phoneId) ?
814 PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700815 // The "data disconnected due to roaming" notification is shown
816 // if (a) you have the "data roaming" feature turned off, and
817 // (b) you just lost data connectivity because you're roaming.
818 boolean disconnectedDueToRoaming =
819 !phone.getDataRoamingEnabled()
Stuart Scottdcf40a92014-12-09 10:45:01 -0800820 && PhoneConstants.DataState.DISCONNECTED.equals(state)
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700821 && Phone.REASON_ROAMING_ON.equals(
822 intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
Yorke Lee4d2db1c2014-11-06 11:37:09 -0800823 if (mDataDisconnectedDueToRoaming != disconnectedDueToRoaming) {
824 mDataDisconnectedDueToRoaming = disconnectedDueToRoaming;
825 mHandler.sendEmptyMessage(disconnectedDueToRoaming
826 ? EVENT_DATA_ROAMING_DISCONNECTED : EVENT_DATA_ROAMING_OK);
827 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700828 } else if ((action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) &&
829 (mPUKEntryActivity != null)) {
830 // if an attempt to un-PUK-lock the device was made, while we're
831 // receiving this state change notification, notify the handler.
832 // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has
833 // been attempted.
834 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
835 intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)));
836 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
837 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800838 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
839 SubscriptionManager.INVALID_PHONE_INDEX);
840 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " (" + phoneId
841 + ") is active.");
842 initForNewRadioTechnology(phoneId);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700843 } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
844 handleServiceStateChanged(intent);
845 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800846 if (TelephonyCapabilities.supportsEcm(mCM.getFgPhone())) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700847 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
848 // Start Emergency Callback Mode service
849 if (intent.getBooleanExtra("phoneinECMState", false)) {
850 context.startService(new Intent(context,
851 EmergencyCallbackModeService.class));
852 }
853 } else {
854 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
855 // on a device that doesn't support ECM in the first place.
856 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, "
Stuart Scottdcf40a92014-12-09 10:45:01 -0800857 + "but ECM isn't supported for phone: "
858 + mCM.getFgPhone().getPhoneName());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700859 }
860 } else if (action.equals(Intent.ACTION_DOCK_EVENT)) {
861 mDockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
862 Intent.EXTRA_DOCK_STATE_UNDOCKED);
863 if (VDBG) Log.d(LOG_TAG, "ACTION_DOCK_EVENT -> mDockState = " + mDockState);
864 mHandler.sendMessage(mHandler.obtainMessage(EVENT_DOCK_STATE_CHANGED, 0));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700865 }
866 }
867 }
868
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700869 /**
870 * Accepts broadcast Intents which will be prepared by {@link NotificationMgr} and thus
871 * sent from framework's notification mechanism (which is outside Phone context).
872 * This should be visible from outside, but shouldn't be in "exported" state.
873 *
874 * TODO: If possible merge this into PhoneAppBroadcastReceiver.
875 */
876 public static class NotificationBroadcastReceiver extends BroadcastReceiver {
877 @Override
878 public void onReceive(Context context, Intent intent) {
879 String action = intent.getAction();
880 // TODO: use "if (VDBG)" here.
881 Log.d(LOG_TAG, "Broadcast from Notification: " + action);
882
883 if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
884 PhoneUtils.hangup(PhoneGlobals.getInstance().mCM);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700885 } else {
886 Log.w(LOG_TAG, "Received hang-up request from notification,"
887 + " but there's no call the system can hang up.");
888 }
889 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700890 }
891
892 private void handleServiceStateChanged(Intent intent) {
893 /**
894 * This used to handle updating EriTextWidgetProvider this routine
895 * and and listening for ACTION_SERVICE_STATE_CHANGED intents could
896 * be removed. But leaving just in case it might be needed in the near
897 * future.
898 */
899
900 // If service just returned, start sending out the queued messages
901 ServiceState ss = ServiceState.newFromBundle(intent.getExtras());
902
903 if (ss != null) {
904 int state = ss.getState();
905 notificationMgr.updateNetworkSelection(state);
906 }
907 }
908
909 public boolean isOtaCallInActiveState() {
910 boolean otaCallActive = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700911 if (VDBG) Log.d(LOG_TAG, "- isOtaCallInActiveState " + otaCallActive);
912 return otaCallActive;
913 }
914
915 public boolean isOtaCallInEndState() {
916 boolean otaCallEnded = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700917 if (VDBG) Log.d(LOG_TAG, "- isOtaCallInEndState " + otaCallEnded);
918 return otaCallEnded;
919 }
920
921 // it is safe to call clearOtaState() even if the InCallScreen isn't active
922 public void clearOtaState() {
923 if (DBG) Log.d(LOG_TAG, "- clearOtaState ...");
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700924 if (otaUtils != null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700925 otaUtils.cleanOtaScreen(true);
926 if (DBG) Log.d(LOG_TAG, " - clearOtaState clears OTA screen");
927 }
928 }
929
930 // it is safe to call dismissOtaDialogs() even if the InCallScreen isn't active
931 public void dismissOtaDialogs() {
932 if (DBG) Log.d(LOG_TAG, "- dismissOtaDialogs ...");
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700933 if (otaUtils != null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700934 otaUtils.dismissAllOtaDialogs();
935 if (DBG) Log.d(LOG_TAG, " - dismissOtaDialogs clears OTA dialogs");
936 }
937 }
938
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700939 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -0800940 * Triggers a refresh of the message waiting (voicemail) indicator.
941 *
942 * @param subId the subscription id we should refresh the notification for.
943 */
944 public void refreshMwiIndicator(int subId) {
945 notificationMgr.refreshMwi(subId);
946 }
947
948 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700949 * "Call origin" may be used by Contacts app to specify where the phone call comes from.
950 * Currently, the only permitted value for this extra is {@link #ALLOWED_EXTRA_CALL_ORIGIN}.
951 * Any other value will be ignored, to make sure that malicious apps can't trick the in-call
952 * UI into launching some random other app after a call ends.
953 *
954 * TODO: make this more generic. Note that we should let the "origin" specify its package
955 * while we are now assuming it is "com.android.contacts"
956 */
957 public static final String EXTRA_CALL_ORIGIN = "com.android.phone.CALL_ORIGIN";
958 private static final String DEFAULT_CALL_ORIGIN_PACKAGE = "com.android.dialer";
959 private static final String ALLOWED_EXTRA_CALL_ORIGIN =
960 "com.android.dialer.DialtactsActivity";
961 /**
962 * Used to determine if the preserved call origin is fresh enough.
963 */
964 private static final long CALL_ORIGIN_EXPIRATION_MILLIS = 30 * 1000;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700965}