blob: d13ebfe3b854a3fd441afdfd9c314d73f505dc9d [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;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070067import com.android.server.sip.SipService;
68
Andrew Lee385019f2014-11-24 14:19:50 -080069import java.util.ArrayList;
70import java.util.List;
71
Santos Cordon7d4ddf62013-07-10 11:58:08 -070072/**
73 * Global state for the telephony subsystem when running in the primary
74 * phone process.
75 */
Sailesh Nepalbf900542014-07-15 16:18:32 -070076public class PhoneGlobals extends ContextWrapper {
Andrew Lee83383e42014-10-31 12:42:28 -070077 public static final String LOG_TAG = "PhoneApp";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070078
79 /**
80 * Phone app-wide debug level:
81 * 0 - no debug logging
82 * 1 - normal debug logging if ro.debuggable is set (which is true in
83 * "eng" and "userdebug" builds but not "user" builds)
84 * 2 - ultra-verbose debug logging
85 *
86 * Most individual classes in the phone app have a local DBG constant,
87 * typically set to
88 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
89 * or else
90 * (PhoneApp.DBG_LEVEL >= 2)
91 * depending on the desired verbosity.
92 *
93 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
94 */
Andrew Lee88b51e22014-10-29 15:48:51 -070095 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070096
97 private static final boolean DBG =
98 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
99 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
100
101 // Message codes; see mHandler below.
102 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700103 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700104 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
105 private static final int EVENT_DATA_ROAMING_OK = 11;
106 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
107 private static final int EVENT_DOCK_STATE_CHANGED = 13;
Sailesh Nepalbf900542014-07-15 16:18:32 -0700108 private static final int EVENT_START_SIP_SERVICE = 14;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700109
110 // The MMI codes are also used by the InCallScreen.
111 public static final int MMI_INITIATE = 51;
112 public static final int MMI_COMPLETE = 52;
113 public static final int MMI_CANCEL = 53;
114 // Don't use message codes larger than 99 here; those are reserved for
115 // the individual Activities of the Phone UI.
116
117 /**
118 * Allowable values for the wake lock code.
119 * SLEEP means the device can be put to sleep.
120 * PARTIAL means wake the processor, but we display can be kept off.
121 * FULL means wake both the processor and the display.
122 */
123 public enum WakeState {
124 SLEEP,
125 PARTIAL,
126 FULL
127 }
128
129 /**
130 * Intent Action used for hanging up the current call from Notification bar. This will
131 * choose first ringing call, first active call, or first background call (typically in
132 * HOLDING state).
133 */
134 public static final String ACTION_HANG_UP_ONGOING_CALL =
135 "com.android.phone.ACTION_HANG_UP_ONGOING_CALL";
136
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700137 private static PhoneGlobals sMe;
138
139 // A few important fields we expose to the rest of the package
140 // directly (rather than thru set/get methods) for efficiency.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700141 CallController callController;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700142 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700143 CallNotifier notifier;
144 CallerInfoCache callerInfoCache;
Santos Cordon63a84242013-07-23 13:32:52 -0700145 NotificationMgr notificationMgr;
Santos Cordon63a84242013-07-23 13:32:52 -0700146 PhoneInterfaceManager phoneMgr;
147
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700148 private BluetoothManager bluetoothManager;
Santos Cordon69a69192013-08-22 14:25:42 -0700149 private CallGatewayManager callGatewayManager;
Santos Cordon63a84242013-07-23 13:32:52 -0700150 private CallStateMonitor callStateMonitor;
Santos Cordon63a84242013-07-23 13:32:52 -0700151
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700152 static int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
153 static boolean sVoiceCapable = true;
154
155 // Internal PhoneApp Call state tracker
156 CdmaPhoneCallState cdmaPhoneCallState;
157
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700158 // The currently-active PUK entry activity and progress dialog.
159 // Normally, these are the Emergency Dialer and the subsequent
160 // progress dialog. null if there is are no such objects in
161 // the foreground.
162 private Activity mPUKEntryActivity;
163 private ProgressDialog mPUKEntryProgressDialog;
164
165 private boolean mIsSimPinEnabled;
166 private String mCachedSimPin;
167
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700168 // True if we are beginning a call, but the phone state has not changed yet
169 private boolean mBeginningCall;
Yorke Lee4d2db1c2014-11-06 11:37:09 -0800170 private boolean mDataDisconnectedDueToRoaming = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700171
172 // Last phone state seen by updatePhoneState()
173 private PhoneConstants.State mLastPhoneState = PhoneConstants.State.IDLE;
174
175 private WakeState mWakeState = WakeState.SLEEP;
176
177 private PowerManager mPowerManager;
178 private IPowerManager mPowerManagerService;
179 private PowerManager.WakeLock mWakeLock;
180 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700181 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700182
183 private UpdateLock mUpdateLock;
184
185 // Broadcast receiver for various intent broadcasts (see onCreate())
186 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
187
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700188 /** boolean indicating restoring mute state on InCallScreen.onResume() */
189 private boolean mShouldRestoreMuteOnInCallResume;
190
191 /**
192 * The singleton OtaUtils instance used for OTASP calls.
193 *
194 * The OtaUtils instance is created lazily the first time we need to
195 * make an OTASP call, regardless of whether it's an interactive or
196 * non-interactive OTASP call.
197 */
198 public OtaUtils otaUtils;
199
200 // Following are the CDMA OTA information Objects used during OTA Call.
201 // cdmaOtaProvisionData object store static OTA information that needs
202 // to be maintained even during Slider open/close scenarios.
203 // cdmaOtaConfigData object stores configuration info to control visiblity
204 // of each OTA Screens.
205 // cdmaOtaScreenState object store OTA Screen State information.
206 public OtaUtils.CdmaOtaProvisionData cdmaOtaProvisionData;
207 public OtaUtils.CdmaOtaConfigData cdmaOtaConfigData;
208 public OtaUtils.CdmaOtaScreenState cdmaOtaScreenState;
209 public OtaUtils.CdmaOtaInCallScreenUiState cdmaOtaInCallScreenUiState;
210
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700211 /**
212 * Set the restore mute state flag. Used when we are setting the mute state
213 * OUTSIDE of user interaction {@link PhoneUtils#startNewCall(Phone)}
214 */
215 /*package*/void setRestoreMuteOnInCallResume (boolean mode) {
216 mShouldRestoreMuteOnInCallResume = mode;
217 }
218
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700219 Handler mHandler = new Handler() {
220 @Override
221 public void handleMessage(Message msg) {
222 PhoneConstants.State phoneState;
223 switch (msg.what) {
224 // Starts the SIP service. It's a no-op if SIP API is not supported
225 // on the deivce.
226 // TODO: Having the phone process host the SIP service is only
227 // temporary. Will move it to a persistent communication process
228 // later.
229 case EVENT_START_SIP_SERVICE:
230 SipService.start(getApplicationContext());
231 break;
232
233 // TODO: This event should be handled by the lock screen, just
234 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
235 case EVENT_SIM_NETWORK_LOCKED:
236 if (getResources().getBoolean(R.bool.ignore_sim_network_locked_events)) {
237 // Some products don't have the concept of a "SIM network lock"
238 Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; "
239 + "not showing 'SIM network unlock' PIN entry screen");
240 } else {
241 // Normal case: show the "SIM network unlock" PIN entry screen.
242 // The user won't be able to do anything else until
243 // they enter a valid SIM network PIN.
244 Log.i(LOG_TAG, "show sim depersonal panel");
245 IccNetworkDepersonalizationPanel ndpPanel =
246 new IccNetworkDepersonalizationPanel(PhoneGlobals.getInstance());
247 ndpPanel.show();
248 }
249 break;
250
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700251 case EVENT_DATA_ROAMING_DISCONNECTED:
252 notificationMgr.showDataDisconnectedRoaming();
253 break;
254
255 case EVENT_DATA_ROAMING_OK:
256 notificationMgr.hideDataDisconnectedRoaming();
257 break;
258
259 case MMI_COMPLETE:
260 onMMIComplete((AsyncResult) msg.obj);
261 break;
262
263 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800264 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700265 break;
266
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700267 case EVENT_SIM_STATE_CHANGED:
268 // Marks the event where the SIM goes into ready state.
269 // Right now, this is only used for the PUK-unlocking
270 // process.
271 if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY)) {
272 // when the right event is triggered and there
273 // are UI objects in the foreground, we close
274 // them to display the lock panel.
275 if (mPUKEntryActivity != null) {
276 mPUKEntryActivity.finish();
277 mPUKEntryActivity = null;
278 }
279 if (mPUKEntryProgressDialog != null) {
280 mPUKEntryProgressDialog.dismiss();
281 mPUKEntryProgressDialog = null;
282 }
283 }
284 break;
285
286 case EVENT_UNSOL_CDMA_INFO_RECORD:
287 //TODO: handle message here;
288 break;
289
290 case EVENT_DOCK_STATE_CHANGED:
291 // If the phone is docked/undocked during a call, and no wired or BT headset
292 // is connected: turn on/off the speaker accordingly.
293 boolean inDockMode = false;
294 if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
295 inDockMode = true;
296 }
297 if (VDBG) Log.d(LOG_TAG, "received EVENT_DOCK_STATE_CHANGED. Phone inDock = "
298 + inDockMode);
299
300 phoneState = mCM.getState();
301 if (phoneState == PhoneConstants.State.OFFHOOK &&
Santos Cordon593ab382013-08-06 21:58:23 -0700302 !bluetoothManager.isBluetoothHeadsetAudioOn()) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700303 PhoneUtils.turnOnSpeaker(getApplicationContext(), inDockMode, true);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700304 }
305 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700306 }
307 }
308 };
309
310 public PhoneGlobals(Context context) {
311 super(context);
312 sMe = this;
313 }
314
315 public void onCreate() {
316 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
317
318 ContentResolver resolver = getContentResolver();
319
320 // Cache the "voice capable" flag.
321 // This flag currently comes from a resource (which is
322 // overrideable on a per-product basis):
323 sVoiceCapable =
324 getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
325 // ...but this might eventually become a PackageManager "system
326 // feature" instead, in which case we'd do something like:
327 // sVoiceCapable =
328 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
329
Stuart Scottdcf40a92014-12-09 10:45:01 -0800330 if (mCM == null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700331 // Initialize the telephony framework
332 PhoneFactory.makeDefaultPhones(this);
333
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700334 // Start TelephonyDebugService After the default phone is created.
335 Intent intent = new Intent(this, TelephonyDebugService.class);
336 startService(intent);
337
338 mCM = CallManager.getInstance();
Stuart Scottdcf40a92014-12-09 10:45:01 -0800339 boolean hasCdmaPhoneType = false;
340 for (Phone phone : PhoneFactory.getPhones()) {
341 mCM.registerPhone(phone);
342 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
343 hasCdmaPhoneType = true;
344 }
345 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700346
347 // Create the NotificationMgr singleton, which is used to display
348 // status bar icons and control other status bar behavior.
349 notificationMgr = NotificationMgr.init(this);
350
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700351 mHandler.sendEmptyMessage(EVENT_START_SIP_SERVICE);
352
Stuart Scottdcf40a92014-12-09 10:45:01 -0800353 if (hasCdmaPhoneType) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700354 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
355 cdmaPhoneCallState = new CdmaPhoneCallState();
356 cdmaPhoneCallState.CdmaPhoneCallStateInit();
357 }
358
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700359 // before registering for phone state changes
360 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
361 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
362 // lock used to keep the processor awake, when we don't care for the display.
363 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
364 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700365
366 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
367
368 // get a handle to the service so that we can use it later when we
369 // want to set the poke lock.
370 mPowerManagerService = IPowerManager.Stub.asInterface(
371 ServiceManager.getService("power"));
372
373 // Get UpdateLock to suppress system-update related events (e.g. dialog show-up)
374 // during phone calls.
375 mUpdateLock = new UpdateLock("phone");
376
377 if (DBG) Log.d(LOG_TAG, "onCreate: mUpdateLock: " + mUpdateLock);
378
379 CallLogger callLogger = new CallLogger(this, new CallLogAsync());
380
Jay Shrauner21a75342013-11-25 16:14:43 -0800381 callGatewayManager = CallGatewayManager.getInstance();
Santos Cordon69a69192013-08-22 14:25:42 -0700382
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700383 // Create the CallController singleton, which is the interface
384 // to the telephony layer for user-initiated telephony functionality
385 // (like making outgoing calls.)
Santos Cordon69a69192013-08-22 14:25:42 -0700386 callController = CallController.init(this, callLogger, callGatewayManager);
387
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700388 // Create the CallerInfoCache singleton, which remembers custom ring tone and
389 // send-to-voicemail settings.
390 //
391 // The asynchronous caching will start just after this call.
392 callerInfoCache = CallerInfoCache.init(this);
393
394 // Monitors call activity from the telephony layer
395 callStateMonitor = new CallStateMonitor(mCM);
396
Santos Cordon2c2d3cf2013-08-08 03:53:47 -0700397 // Bluetooth manager
Sailesh Nepal23d9ed72014-07-03 09:40:26 -0700398 bluetoothManager = new BluetoothManager();
Santos Cordon2c2d3cf2013-08-08 03:53:47 -0700399
Stuart Scottdcf40a92014-12-09 10:45:01 -0800400 phoneMgr = PhoneInterfaceManager.init(this, PhoneFactory.getDefaultPhone());
Santos Cordon406c0342013-08-28 00:07:47 -0700401
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700402 // Create the CallNotifer singleton, which handles
403 // asynchronous events from the telephony layer (like
404 // launching the incoming-call UI when an incoming call comes
405 // in.)
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800406 notifier = CallNotifier.init(this, callLogger, callStateMonitor, bluetoothManager);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700407
Stuart Scottdcf40a92014-12-09 10:45:01 -0800408 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700409
410 // register for MMI/USSD
411 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
412
413 // register connection tracking to PhoneUtils
414 PhoneUtils.initializeConnectionHandler(mCM);
415
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700416 // Register for misc other intent broadcasts.
417 IntentFilter intentFilter =
418 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700419 intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700420 intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
421 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
422 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
423 intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
424 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700425 registerReceiver(mReceiver, intentFilter);
426
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700427 //set the default values for the preferences in the phone.
428 PreferenceManager.setDefaultValues(this, R.xml.network_setting, false);
429
430 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
431
432 // Make sure the audio mode (along with some
433 // audio-mode-related state of our own) is initialized
434 // correctly, given the current state of the phone.
435 PhoneUtils.setAudioMode(mCM);
436 }
437
Santos Cordon52bc81b2014-10-07 19:55:12 -0700438 cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData();
439 cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData();
440 cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState();
441 cdmaOtaInCallScreenUiState = new OtaUtils.CdmaOtaInCallScreenUiState();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700442
443 // XXX pre-load the SimProvider so that it's ready
444 resolver.getType(Uri.parse("content://icc/adn"));
445
446 // start with the default value to set the mute state.
447 mShouldRestoreMuteOnInCallResume = false;
448
449 // TODO: Register for Cdma Information Records
450 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
451
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700452 // Read HAC settings and configure audio hardware
453 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800454 int hac = android.provider.Settings.System.getInt(
455 getContentResolver(),
456 android.provider.Settings.System.HEARING_AID,
457 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700458 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
459 audioManager.setParameter(CallFeaturesSetting.HAC_KEY, hac != 0 ?
460 CallFeaturesSetting.HAC_VAL_ON :
461 CallFeaturesSetting.HAC_VAL_OFF);
462 }
Santos Cordonff506f52013-11-21 19:13:19 -0800463 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700464
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700465 /**
466 * Returns the singleton instance of the PhoneApp.
467 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800468 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700469 if (sMe == null) {
470 throw new IllegalStateException("No PhoneGlobals here!");
471 }
472 return sMe;
473 }
474
475 /**
476 * Returns the singleton instance of the PhoneApp if running as the
477 * primary user, otherwise null.
478 */
479 static PhoneGlobals getInstanceIfPrimary() {
480 return sMe;
481 }
482
483 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800484 * Returns the default phone.
485 *
Andrew Lee385019f2014-11-24 14:19:50 -0800486 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700487 */
Andrew Lee83383e42014-10-31 12:42:28 -0700488 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800489 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700490 }
491
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800492 public static Phone getPhone(int subId) {
493 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800494 }
495
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700496 /* package */ BluetoothManager getBluetoothManager() {
497 return bluetoothManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700498 }
499
Santos Cordonde10b752013-09-19 04:11:33 -0700500 /* package */ CallManager getCallManager() {
501 return mCM;
502 }
503
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700504 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700505 * Returns PendingIntent for hanging up ongoing phone call. This will typically be used from
506 * Notification context.
507 */
508 /* package */ static PendingIntent createHangUpOngoingCallPendingIntent(Context context) {
509 Intent intent = new Intent(PhoneGlobals.ACTION_HANG_UP_ONGOING_CALL, null,
510 context, NotificationBroadcastReceiver.class);
511 return PendingIntent.getBroadcast(context, 0, intent, 0);
512 }
513
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700514 boolean isSimPinEnabled() {
515 return mIsSimPinEnabled;
516 }
517
518 boolean authenticateAgainstCachedSimPin(String pin) {
519 return (mCachedSimPin != null && mCachedSimPin.equals(pin));
520 }
521
522 void setCachedSimPin(String pin) {
523 mCachedSimPin = pin;
524 }
525
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700526 /**
527 * Handles OTASP-related events from the telephony layer.
528 *
529 * While an OTASP call is active, the CallNotifier forwards
530 * OTASP-related telephony events to this method.
531 */
532 void handleOtaspEvent(Message msg) {
533 if (DBG) Log.d(LOG_TAG, "handleOtaspEvent(message " + msg + ")...");
534
535 if (otaUtils == null) {
536 // We shouldn't be getting OTASP events without ever
537 // having started the OTASP call in the first place!
538 Log.w(LOG_TAG, "handleOtaEvents: got an event but otaUtils is null! "
539 + "message = " + msg);
540 return;
541 }
542
543 otaUtils.onOtaProvisionStatusChanged((AsyncResult) msg.obj);
544 }
545
546 /**
547 * Similarly, handle the disconnect event of an OTASP call
548 * by forwarding it to the OtaUtils instance.
549 */
550 /* package */ void handleOtaspDisconnect() {
551 if (DBG) Log.d(LOG_TAG, "handleOtaspDisconnect()...");
552
553 if (otaUtils == null) {
554 // We shouldn't be getting OTASP events without ever
555 // having started the OTASP call in the first place!
556 Log.w(LOG_TAG, "handleOtaspDisconnect: otaUtils is null!");
557 return;
558 }
559
560 otaUtils.onOtaspDisconnect();
561 }
562
563 /**
564 * Sets the activity responsible for un-PUK-blocking the device
565 * so that we may close it when we receive a positive result.
566 * mPUKEntryActivity is also used to indicate to the device that
567 * we are trying to un-PUK-lock the phone. In other words, iff
568 * it is NOT null, then we are trying to unlock and waiting for
569 * the SIM to move to READY state.
570 *
571 * @param activity is the activity to close when PUK has
572 * finished unlocking. Can be set to null to indicate the unlock
573 * or SIM READYing process is over.
574 */
575 void setPukEntryActivity(Activity activity) {
576 mPUKEntryActivity = activity;
577 }
578
579 Activity getPUKEntryActivity() {
580 return mPUKEntryActivity;
581 }
582
583 /**
584 * Sets the dialog responsible for notifying the user of un-PUK-
585 * blocking - SIM READYing progress, so that we may dismiss it
586 * when we receive a positive result.
587 *
588 * @param dialog indicates the progress dialog informing the user
589 * of the state of the device. Dismissed upon completion of
590 * READYing process
591 */
592 void setPukEntryProgressDialog(ProgressDialog dialog) {
593 mPUKEntryProgressDialog = dialog;
594 }
595
596 ProgressDialog getPUKEntryProgressDialog() {
597 return mPUKEntryProgressDialog;
598 }
599
600 /**
601 * Controls whether or not the screen is allowed to sleep.
602 *
603 * Once sleep is allowed (WakeState is SLEEP), it will rely on the
604 * settings for the poke lock to determine when to timeout and let
605 * the device sleep {@link PhoneGlobals#setScreenTimeout}.
606 *
607 * @param ws tells the device to how to wake.
608 */
609 /* package */ void requestWakeState(WakeState ws) {
610 if (VDBG) Log.d(LOG_TAG, "requestWakeState(" + ws + ")...");
611 synchronized (this) {
612 if (mWakeState != ws) {
613 switch (ws) {
614 case PARTIAL:
615 // acquire the processor wake lock, and release the FULL
616 // lock if it is being held.
617 mPartialWakeLock.acquire();
618 if (mWakeLock.isHeld()) {
619 mWakeLock.release();
620 }
621 break;
622 case FULL:
623 // acquire the full wake lock, and release the PARTIAL
624 // lock if it is being held.
625 mWakeLock.acquire();
626 if (mPartialWakeLock.isHeld()) {
627 mPartialWakeLock.release();
628 }
629 break;
630 case SLEEP:
631 default:
632 // release both the PARTIAL and FULL locks.
633 if (mWakeLock.isHeld()) {
634 mWakeLock.release();
635 }
636 if (mPartialWakeLock.isHeld()) {
637 mPartialWakeLock.release();
638 }
639 break;
640 }
641 mWakeState = ws;
642 }
643 }
644 }
645
646 /**
647 * If we are not currently keeping the screen on, then poke the power
648 * manager to wake up the screen for the user activity timeout duration.
649 */
650 /* package */ void wakeUpScreen() {
651 synchronized (this) {
652 if (mWakeState == WakeState.SLEEP) {
653 if (DBG) Log.d(LOG_TAG, "pulse screen lock");
654 mPowerManager.wakeUp(SystemClock.uptimeMillis());
655 }
656 }
657 }
658
659 /**
660 * Sets the wake state and screen timeout based on the current state
661 * of the phone, and the current state of the in-call UI.
662 *
663 * This method is a "UI Policy" wrapper around
664 * {@link PhoneGlobals#requestWakeState} and {@link PhoneGlobals#setScreenTimeout}.
665 *
666 * It's safe to call this method regardless of the state of the Phone
667 * (e.g. whether or not it's idle), and regardless of the state of the
668 * Phone UI (e.g. whether or not the InCallScreen is active.)
669 */
670 /* package */ void updateWakeState() {
671 PhoneConstants.State state = mCM.getState();
672
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700673 // True if the speakerphone is in use. (If so, we *always* use
674 // the default timeout. Since the user is obviously not holding
675 // the phone up to his/her face, we don't need to worry about
676 // false touches, and thus don't need to turn the screen off so
677 // aggressively.)
678 // Note that we need to make a fresh call to this method any
679 // time the speaker state changes. (That happens in
680 // PhoneUtils.turnOnSpeaker().)
681 boolean isSpeakerInUse = (state == PhoneConstants.State.OFFHOOK) && PhoneUtils.isSpeakerOn(this);
682
683 // TODO (bug 1440854): The screen timeout *might* also need to
684 // depend on the bluetooth state, but this isn't as clear-cut as
685 // the speaker state (since while using BT it's common for the
686 // user to put the phone straight into a pocket, in which case the
687 // timeout should probably still be short.)
688
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700689 // Decide whether to force the screen on or not.
690 //
691 // Force the screen to be on if the phone is ringing or dialing,
692 // or if we're displaying the "Call ended" UI for a connection in
693 // the "disconnected" state.
694 // However, if the phone is disconnected while the user is in the
695 // middle of selecting a quick response message, we should not force
696 // the screen to be on.
697 //
698 boolean isRinging = (state == PhoneConstants.State.RINGING);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800699 boolean isDialing = (mCM.getFgPhone().getForegroundCall().getState() == Call.State.DIALING);
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700700 boolean keepScreenOn = isRinging || isDialing;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700701 // keepScreenOn == true means we'll hold a full wake lock:
702 requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP);
703 }
704
705 /**
706 * Manually pokes the PowerManager's userActivity method. Since we
707 * set the {@link WindowManager.LayoutParams#INPUT_FEATURE_DISABLE_USER_ACTIVITY}
708 * flag while the InCallScreen is active when there is no proximity sensor,
709 * we need to do this for touch events that really do count as user activity
710 * (like pressing any onscreen UI elements.)
711 */
712 /* package */ void pokeUserActivity() {
713 if (VDBG) Log.d(LOG_TAG, "pokeUserActivity()...");
714 mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
715 }
716
717 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700718 * Notifies the phone app when the phone state changes.
719 *
Santos Cordonfc309812013-08-20 18:33:16 -0700720 * This method will updates various states inside Phone app (e.g. update-lock state, etc.)
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700721 */
722 /* package */ void updatePhoneState(PhoneConstants.State state) {
723 if (state != mLastPhoneState) {
724 mLastPhoneState = state;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700725
726 // Try to acquire or release UpdateLock.
727 //
728 // Watch out: we don't release the lock here when the screen is still in foreground.
729 // At that time InCallScreen will release it on onPause().
730 if (state != PhoneConstants.State.IDLE) {
731 // UpdateLock is a recursive lock, while we may get "acquire" request twice and
732 // "release" request once for a single call (RINGING + OFFHOOK and IDLE).
733 // We need to manually ensure the lock is just acquired once for each (and this
734 // will prevent other possible buggy situations too).
735 if (!mUpdateLock.isHeld()) {
736 mUpdateLock.acquire();
737 }
738 } else {
Jay Shraunera5d13212013-09-19 13:37:43 -0700739 if (mUpdateLock.isHeld()) {
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700740 mUpdateLock.release();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700741 }
742 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700743 }
744 }
745
746 /* package */ PhoneConstants.State getPhoneState() {
747 return mLastPhoneState;
748 }
749
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700750 KeyguardManager getKeyguardManager() {
751 return mKeyguardManager;
752 }
753
754 private void onMMIComplete(AsyncResult r) {
755 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
756 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800757 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700758 }
759
Stuart Scottdcf40a92014-12-09 10:45:01 -0800760 private void initForNewRadioTechnology(int phoneId) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700761 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
762
Stuart Scottdcf40a92014-12-09 10:45:01 -0800763 final Phone phone = PhoneFactory.getPhone(phoneId);
764
765 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700766 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
767 cdmaPhoneCallState = new CdmaPhoneCallState();
768 cdmaPhoneCallState.CdmaPhoneCallStateInit();
769 }
Santos Cordon52bc81b2014-10-07 19:55:12 -0700770 if (!TelephonyCapabilities.supportsOtasp(phone)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700771 //Clean up OTA data in GSM/UMTS. It is valid only for CDMA
772 clearOtaState();
773 }
774
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700775 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
776 callStateMonitor.updateAfterRadioTechnologyChange();
777
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700778 // Update registration for ICC status after radio technology change
779 IccCard sim = phone.getIccCard();
780 if (sim != null) {
781 if (DBG) Log.d(LOG_TAG, "Update registration for ICC status...");
782
783 //Register all events new to the new active phone
784 sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
785 }
786 }
787
Santos Cordon593ab382013-08-06 21:58:23 -0700788 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700789 * Receiver for misc intent broadcasts the Phone app cares about.
790 */
791 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
792 @Override
793 public void onReceive(Context context, Intent intent) {
794 String action = intent.getAction();
795 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
796 boolean enabled = System.getInt(getContentResolver(),
797 System.AIRPLANE_MODE_ON, 0) == 0;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800798 PhoneUtils.setRadioPower(enabled);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700799 } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800800 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
801 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
802 int phoneId = SubscriptionManager.getPhoneId(subId);
803 String state = intent.getStringExtra(PhoneConstants.STATE_KEY);
804 if (VDBG) {
805 Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED");
806 Log.d(LOG_TAG, "- state: " + state);
807 Log.d(LOG_TAG, "- reason: "
808 + intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
809 Log.d(LOG_TAG, "- subId: " + subId);
810 Log.d(LOG_TAG, "- phoneId: " + phoneId);
811 }
812 Phone phone = SubscriptionManager.isValidPhoneId(phoneId) ?
813 PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700814 // The "data disconnected due to roaming" notification is shown
815 // if (a) you have the "data roaming" feature turned off, and
816 // (b) you just lost data connectivity because you're roaming.
817 boolean disconnectedDueToRoaming =
818 !phone.getDataRoamingEnabled()
Stuart Scottdcf40a92014-12-09 10:45:01 -0800819 && PhoneConstants.DataState.DISCONNECTED.equals(state)
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700820 && Phone.REASON_ROAMING_ON.equals(
821 intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
Yorke Lee4d2db1c2014-11-06 11:37:09 -0800822 if (mDataDisconnectedDueToRoaming != disconnectedDueToRoaming) {
823 mDataDisconnectedDueToRoaming = disconnectedDueToRoaming;
824 mHandler.sendEmptyMessage(disconnectedDueToRoaming
825 ? EVENT_DATA_ROAMING_DISCONNECTED : EVENT_DATA_ROAMING_OK);
826 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700827 } else if ((action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) &&
828 (mPUKEntryActivity != null)) {
829 // if an attempt to un-PUK-lock the device was made, while we're
830 // receiving this state change notification, notify the handler.
831 // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has
832 // been attempted.
833 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
834 intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)));
835 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
836 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800837 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
838 SubscriptionManager.INVALID_PHONE_INDEX);
839 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " (" + phoneId
840 + ") is active.");
841 initForNewRadioTechnology(phoneId);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700842 } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
843 handleServiceStateChanged(intent);
844 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800845 if (TelephonyCapabilities.supportsEcm(mCM.getFgPhone())) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700846 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
847 // Start Emergency Callback Mode service
848 if (intent.getBooleanExtra("phoneinECMState", false)) {
849 context.startService(new Intent(context,
850 EmergencyCallbackModeService.class));
851 }
852 } else {
853 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
854 // on a device that doesn't support ECM in the first place.
855 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, "
Stuart Scottdcf40a92014-12-09 10:45:01 -0800856 + "but ECM isn't supported for phone: "
857 + mCM.getFgPhone().getPhoneName());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700858 }
859 } else if (action.equals(Intent.ACTION_DOCK_EVENT)) {
860 mDockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
861 Intent.EXTRA_DOCK_STATE_UNDOCKED);
862 if (VDBG) Log.d(LOG_TAG, "ACTION_DOCK_EVENT -> mDockState = " + mDockState);
863 mHandler.sendMessage(mHandler.obtainMessage(EVENT_DOCK_STATE_CHANGED, 0));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700864 }
865 }
866 }
867
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700868 /**
869 * Accepts broadcast Intents which will be prepared by {@link NotificationMgr} and thus
870 * sent from framework's notification mechanism (which is outside Phone context).
871 * This should be visible from outside, but shouldn't be in "exported" state.
872 *
873 * TODO: If possible merge this into PhoneAppBroadcastReceiver.
874 */
875 public static class NotificationBroadcastReceiver extends BroadcastReceiver {
876 @Override
877 public void onReceive(Context context, Intent intent) {
878 String action = intent.getAction();
879 // TODO: use "if (VDBG)" here.
880 Log.d(LOG_TAG, "Broadcast from Notification: " + action);
881
882 if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
883 PhoneUtils.hangup(PhoneGlobals.getInstance().mCM);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700884 } else {
885 Log.w(LOG_TAG, "Received hang-up request from notification,"
886 + " but there's no call the system can hang up.");
887 }
888 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700889 }
890
891 private void handleServiceStateChanged(Intent intent) {
892 /**
893 * This used to handle updating EriTextWidgetProvider this routine
894 * and and listening for ACTION_SERVICE_STATE_CHANGED intents could
895 * be removed. But leaving just in case it might be needed in the near
896 * future.
897 */
898
899 // If service just returned, start sending out the queued messages
900 ServiceState ss = ServiceState.newFromBundle(intent.getExtras());
901
902 if (ss != null) {
903 int state = ss.getState();
904 notificationMgr.updateNetworkSelection(state);
905 }
906 }
907
908 public boolean isOtaCallInActiveState() {
909 boolean otaCallActive = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700910 if (VDBG) Log.d(LOG_TAG, "- isOtaCallInActiveState " + otaCallActive);
911 return otaCallActive;
912 }
913
914 public boolean isOtaCallInEndState() {
915 boolean otaCallEnded = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700916 if (VDBG) Log.d(LOG_TAG, "- isOtaCallInEndState " + otaCallEnded);
917 return otaCallEnded;
918 }
919
920 // it is safe to call clearOtaState() even if the InCallScreen isn't active
921 public void clearOtaState() {
922 if (DBG) Log.d(LOG_TAG, "- clearOtaState ...");
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700923 if (otaUtils != null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700924 otaUtils.cleanOtaScreen(true);
925 if (DBG) Log.d(LOG_TAG, " - clearOtaState clears OTA screen");
926 }
927 }
928
929 // it is safe to call dismissOtaDialogs() even if the InCallScreen isn't active
930 public void dismissOtaDialogs() {
931 if (DBG) Log.d(LOG_TAG, "- dismissOtaDialogs ...");
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700932 if (otaUtils != null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700933 otaUtils.dismissAllOtaDialogs();
934 if (DBG) Log.d(LOG_TAG, " - dismissOtaDialogs clears OTA dialogs");
935 }
936 }
937
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700938 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -0800939 * Triggers a refresh of the message waiting (voicemail) indicator.
940 *
941 * @param subId the subscription id we should refresh the notification for.
942 */
943 public void refreshMwiIndicator(int subId) {
944 notificationMgr.refreshMwi(subId);
945 }
946
947 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700948 * "Call origin" may be used by Contacts app to specify where the phone call comes from.
949 * Currently, the only permitted value for this extra is {@link #ALLOWED_EXTRA_CALL_ORIGIN}.
950 * Any other value will be ignored, to make sure that malicious apps can't trick the in-call
951 * UI into launching some random other app after a call ends.
952 *
953 * TODO: make this more generic. Note that we should let the "origin" specify its package
954 * while we are now assuming it is "com.android.contacts"
955 */
956 public static final String EXTRA_CALL_ORIGIN = "com.android.phone.CALL_ORIGIN";
957 private static final String DEFAULT_CALL_ORIGIN_PACKAGE = "com.android.dialer";
958 private static final String ALLOWED_EXTRA_CALL_ORIGIN =
959 "com.android.dialer.DialtactsActivity";
960 /**
961 * Used to determine if the preserved call origin is fresh enough.
962 */
963 private static final long CALL_ORIGIN_EXPIRATION_MILLIS = 30 * 1000;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700964}