blob: 6c658d3af7ada970c605d68af8fa06c1d88372d5 [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;
Santos Cordon76aaf482015-04-08 10:58:27 -070069import com.android.services.telephony.activation.SimActivationManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070070
Andrew Lee385019f2014-11-24 14:19:50 -080071import java.util.ArrayList;
72import java.util.List;
73
Santos Cordon7d4ddf62013-07-10 11:58:08 -070074/**
75 * Global state for the telephony subsystem when running in the primary
76 * phone process.
77 */
Sailesh Nepalbf900542014-07-15 16:18:32 -070078public class PhoneGlobals extends ContextWrapper {
Andrew Lee83383e42014-10-31 12:42:28 -070079 public static final String LOG_TAG = "PhoneApp";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070080
81 /**
82 * Phone app-wide debug level:
83 * 0 - no debug logging
84 * 1 - normal debug logging if ro.debuggable is set (which is true in
85 * "eng" and "userdebug" builds but not "user" builds)
86 * 2 - ultra-verbose debug logging
87 *
88 * Most individual classes in the phone app have a local DBG constant,
89 * typically set to
90 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
91 * or else
92 * (PhoneApp.DBG_LEVEL >= 2)
93 * depending on the desired verbosity.
94 *
95 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
96 */
Andrew Lee88b51e22014-10-29 15:48:51 -070097 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070098
99 private static final boolean DBG =
100 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
101 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
102
103 // Message codes; see mHandler below.
104 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700105 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700106 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
107 private static final int EVENT_DATA_ROAMING_OK = 11;
108 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
109 private static final int EVENT_DOCK_STATE_CHANGED = 13;
Sailesh Nepalbf900542014-07-15 16:18:32 -0700110 private static final int EVENT_START_SIP_SERVICE = 14;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700111
112 // The MMI codes are also used by the InCallScreen.
113 public static final int MMI_INITIATE = 51;
114 public static final int MMI_COMPLETE = 52;
115 public static final int MMI_CANCEL = 53;
116 // Don't use message codes larger than 99 here; those are reserved for
117 // the individual Activities of the Phone UI.
118
119 /**
120 * Allowable values for the wake lock code.
121 * SLEEP means the device can be put to sleep.
122 * PARTIAL means wake the processor, but we display can be kept off.
123 * FULL means wake both the processor and the display.
124 */
125 public enum WakeState {
126 SLEEP,
127 PARTIAL,
128 FULL
129 }
130
131 /**
132 * Intent Action used for hanging up the current call from Notification bar. This will
133 * choose first ringing call, first active call, or first background call (typically in
134 * HOLDING state).
135 */
136 public static final String ACTION_HANG_UP_ONGOING_CALL =
137 "com.android.phone.ACTION_HANG_UP_ONGOING_CALL";
138
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700139 private static PhoneGlobals sMe;
140
141 // A few important fields we expose to the rest of the package
142 // directly (rather than thru set/get methods) for efficiency.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700143 CallController callController;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700144 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700145 CallNotifier notifier;
146 CallerInfoCache callerInfoCache;
Santos Cordon63a84242013-07-23 13:32:52 -0700147 NotificationMgr notificationMgr;
Andrew Lee9431b832015-03-09 18:46:45 -0700148 public PhoneInterfaceManager phoneMgr;
Santos Cordon76aaf482015-04-08 10:58:27 -0700149 public SimActivationManager simActivationManager;
Santos Cordon63a84242013-07-23 13:32:52 -0700150
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700151 private BluetoothManager bluetoothManager;
Santos Cordon69a69192013-08-22 14:25:42 -0700152 private CallGatewayManager callGatewayManager;
Santos Cordon63a84242013-07-23 13:32:52 -0700153 private CallStateMonitor callStateMonitor;
Santos Cordon63a84242013-07-23 13:32:52 -0700154
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700155 static int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
156 static boolean sVoiceCapable = true;
157
158 // Internal PhoneApp Call state tracker
159 CdmaPhoneCallState cdmaPhoneCallState;
160
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700161 // The currently-active PUK entry activity and progress dialog.
162 // Normally, these are the Emergency Dialer and the subsequent
163 // progress dialog. null if there is are no such objects in
164 // the foreground.
165 private Activity mPUKEntryActivity;
166 private ProgressDialog mPUKEntryProgressDialog;
167
168 private boolean mIsSimPinEnabled;
169 private String mCachedSimPin;
170
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700171 // True if we are beginning a call, but the phone state has not changed yet
172 private boolean mBeginningCall;
Yorke Lee4d2db1c2014-11-06 11:37:09 -0800173 private boolean mDataDisconnectedDueToRoaming = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700174
175 // Last phone state seen by updatePhoneState()
176 private PhoneConstants.State mLastPhoneState = PhoneConstants.State.IDLE;
177
178 private WakeState mWakeState = WakeState.SLEEP;
179
180 private PowerManager mPowerManager;
181 private IPowerManager mPowerManagerService;
182 private PowerManager.WakeLock mWakeLock;
183 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700184 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700185
186 private UpdateLock mUpdateLock;
187
188 // Broadcast receiver for various intent broadcasts (see onCreate())
189 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
190
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700191 /** boolean indicating restoring mute state on InCallScreen.onResume() */
192 private boolean mShouldRestoreMuteOnInCallResume;
193
194 /**
195 * The singleton OtaUtils instance used for OTASP calls.
196 *
197 * The OtaUtils instance is created lazily the first time we need to
198 * make an OTASP call, regardless of whether it's an interactive or
199 * non-interactive OTASP call.
200 */
201 public OtaUtils otaUtils;
202
203 // Following are the CDMA OTA information Objects used during OTA Call.
204 // cdmaOtaProvisionData object store static OTA information that needs
205 // to be maintained even during Slider open/close scenarios.
206 // cdmaOtaConfigData object stores configuration info to control visiblity
207 // of each OTA Screens.
208 // cdmaOtaScreenState object store OTA Screen State information.
209 public OtaUtils.CdmaOtaProvisionData cdmaOtaProvisionData;
210 public OtaUtils.CdmaOtaConfigData cdmaOtaConfigData;
211 public OtaUtils.CdmaOtaScreenState cdmaOtaScreenState;
212 public OtaUtils.CdmaOtaInCallScreenUiState cdmaOtaInCallScreenUiState;
213
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700214 /**
215 * Set the restore mute state flag. Used when we are setting the mute state
216 * OUTSIDE of user interaction {@link PhoneUtils#startNewCall(Phone)}
217 */
218 /*package*/void setRestoreMuteOnInCallResume (boolean mode) {
219 mShouldRestoreMuteOnInCallResume = mode;
220 }
221
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700222 Handler mHandler = new Handler() {
223 @Override
224 public void handleMessage(Message msg) {
225 PhoneConstants.State phoneState;
226 switch (msg.what) {
227 // Starts the SIP service. It's a no-op if SIP API is not supported
228 // on the deivce.
229 // TODO: Having the phone process host the SIP service is only
230 // temporary. Will move it to a persistent communication process
231 // later.
232 case EVENT_START_SIP_SERVICE:
233 SipService.start(getApplicationContext());
234 break;
235
236 // TODO: This event should be handled by the lock screen, just
237 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
238 case EVENT_SIM_NETWORK_LOCKED:
239 if (getResources().getBoolean(R.bool.ignore_sim_network_locked_events)) {
240 // Some products don't have the concept of a "SIM network lock"
241 Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; "
242 + "not showing 'SIM network unlock' PIN entry screen");
243 } else {
244 // Normal case: show the "SIM network unlock" PIN entry screen.
245 // The user won't be able to do anything else until
246 // they enter a valid SIM network PIN.
247 Log.i(LOG_TAG, "show sim depersonal panel");
248 IccNetworkDepersonalizationPanel ndpPanel =
249 new IccNetworkDepersonalizationPanel(PhoneGlobals.getInstance());
250 ndpPanel.show();
251 }
252 break;
253
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700254 case EVENT_DATA_ROAMING_DISCONNECTED:
255 notificationMgr.showDataDisconnectedRoaming();
256 break;
257
258 case EVENT_DATA_ROAMING_OK:
259 notificationMgr.hideDataDisconnectedRoaming();
260 break;
261
262 case MMI_COMPLETE:
263 onMMIComplete((AsyncResult) msg.obj);
264 break;
265
266 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800267 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700268 break;
269
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700270 case EVENT_SIM_STATE_CHANGED:
271 // Marks the event where the SIM goes into ready state.
272 // Right now, this is only used for the PUK-unlocking
273 // process.
274 if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY)) {
275 // when the right event is triggered and there
276 // are UI objects in the foreground, we close
277 // them to display the lock panel.
278 if (mPUKEntryActivity != null) {
279 mPUKEntryActivity.finish();
280 mPUKEntryActivity = null;
281 }
282 if (mPUKEntryProgressDialog != null) {
283 mPUKEntryProgressDialog.dismiss();
284 mPUKEntryProgressDialog = null;
285 }
286 }
287 break;
288
289 case EVENT_UNSOL_CDMA_INFO_RECORD:
290 //TODO: handle message here;
291 break;
292
293 case EVENT_DOCK_STATE_CHANGED:
294 // If the phone is docked/undocked during a call, and no wired or BT headset
295 // is connected: turn on/off the speaker accordingly.
296 boolean inDockMode = false;
297 if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
298 inDockMode = true;
299 }
300 if (VDBG) Log.d(LOG_TAG, "received EVENT_DOCK_STATE_CHANGED. Phone inDock = "
301 + inDockMode);
302
303 phoneState = mCM.getState();
304 if (phoneState == PhoneConstants.State.OFFHOOK &&
Santos Cordon593ab382013-08-06 21:58:23 -0700305 !bluetoothManager.isBluetoothHeadsetAudioOn()) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700306 PhoneUtils.turnOnSpeaker(getApplicationContext(), inDockMode, true);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700307 }
308 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700309 }
310 }
311 };
312
313 public PhoneGlobals(Context context) {
314 super(context);
315 sMe = this;
316 }
317
318 public void onCreate() {
319 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
320
321 ContentResolver resolver = getContentResolver();
322
323 // Cache the "voice capable" flag.
324 // This flag currently comes from a resource (which is
325 // overrideable on a per-product basis):
326 sVoiceCapable =
327 getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
328 // ...but this might eventually become a PackageManager "system
329 // feature" instead, in which case we'd do something like:
330 // sVoiceCapable =
331 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
332
Stuart Scottdcf40a92014-12-09 10:45:01 -0800333 if (mCM == null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700334 // Initialize the telephony framework
335 PhoneFactory.makeDefaultPhones(this);
336
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700337 // Start TelephonyDebugService After the default phone is created.
338 Intent intent = new Intent(this, TelephonyDebugService.class);
339 startService(intent);
340
341 mCM = CallManager.getInstance();
Stuart Scottdcf40a92014-12-09 10:45:01 -0800342 boolean hasCdmaPhoneType = false;
343 for (Phone phone : PhoneFactory.getPhones()) {
344 mCM.registerPhone(phone);
345 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
346 hasCdmaPhoneType = true;
347 }
348 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700349
350 // Create the NotificationMgr singleton, which is used to display
351 // status bar icons and control other status bar behavior.
352 notificationMgr = NotificationMgr.init(this);
353
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700354 mHandler.sendEmptyMessage(EVENT_START_SIP_SERVICE);
355
Stuart Scottdcf40a92014-12-09 10:45:01 -0800356 if (hasCdmaPhoneType) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700357 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
358 cdmaPhoneCallState = new CdmaPhoneCallState();
359 cdmaPhoneCallState.CdmaPhoneCallStateInit();
360 }
361
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700362 // before registering for phone state changes
363 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
364 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
365 // lock used to keep the processor awake, when we don't care for the display.
366 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
367 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700368
369 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
370
371 // get a handle to the service so that we can use it later when we
372 // want to set the poke lock.
373 mPowerManagerService = IPowerManager.Stub.asInterface(
374 ServiceManager.getService("power"));
375
376 // Get UpdateLock to suppress system-update related events (e.g. dialog show-up)
377 // during phone calls.
378 mUpdateLock = new UpdateLock("phone");
379
380 if (DBG) Log.d(LOG_TAG, "onCreate: mUpdateLock: " + mUpdateLock);
381
382 CallLogger callLogger = new CallLogger(this, new CallLogAsync());
383
Jay Shrauner21a75342013-11-25 16:14:43 -0800384 callGatewayManager = CallGatewayManager.getInstance();
Santos Cordon69a69192013-08-22 14:25:42 -0700385
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700386 // Create the CallController singleton, which is the interface
387 // to the telephony layer for user-initiated telephony functionality
388 // (like making outgoing calls.)
Santos Cordon69a69192013-08-22 14:25:42 -0700389 callController = CallController.init(this, callLogger, callGatewayManager);
390
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700391 // Create the CallerInfoCache singleton, which remembers custom ring tone and
392 // send-to-voicemail settings.
393 //
394 // The asynchronous caching will start just after this call.
395 callerInfoCache = CallerInfoCache.init(this);
396
397 // Monitors call activity from the telephony layer
398 callStateMonitor = new CallStateMonitor(mCM);
399
Santos Cordon2c2d3cf2013-08-08 03:53:47 -0700400 // Bluetooth manager
Sailesh Nepal23d9ed72014-07-03 09:40:26 -0700401 bluetoothManager = new BluetoothManager();
Santos Cordon2c2d3cf2013-08-08 03:53:47 -0700402
Stuart Scottdcf40a92014-12-09 10:45:01 -0800403 phoneMgr = PhoneInterfaceManager.init(this, PhoneFactory.getDefaultPhone());
Santos Cordon406c0342013-08-28 00:07:47 -0700404
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700405 // Create the CallNotifer singleton, which handles
406 // asynchronous events from the telephony layer (like
407 // launching the incoming-call UI when an incoming call comes
408 // in.)
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800409 notifier = CallNotifier.init(this, callLogger, callStateMonitor, bluetoothManager);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700410
Stuart Scottdcf40a92014-12-09 10:45:01 -0800411 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700412
413 // register for MMI/USSD
414 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
415
416 // register connection tracking to PhoneUtils
417 PhoneUtils.initializeConnectionHandler(mCM);
418
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700419 // Register for misc other intent broadcasts.
420 IntentFilter intentFilter =
421 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700422 intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700423 intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
424 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
425 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
426 intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
427 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700428 registerReceiver(mReceiver, intentFilter);
429
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700430 //set the default values for the preferences in the phone.
431 PreferenceManager.setDefaultValues(this, R.xml.network_setting, false);
432
433 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
434
435 // Make sure the audio mode (along with some
436 // audio-mode-related state of our own) is initialized
437 // correctly, given the current state of the phone.
438 PhoneUtils.setAudioMode(mCM);
439 }
440
Santos Cordon52bc81b2014-10-07 19:55:12 -0700441 cdmaOtaProvisionData = new OtaUtils.CdmaOtaProvisionData();
442 cdmaOtaConfigData = new OtaUtils.CdmaOtaConfigData();
443 cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState();
444 cdmaOtaInCallScreenUiState = new OtaUtils.CdmaOtaInCallScreenUiState();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700445
Santos Cordon76aaf482015-04-08 10:58:27 -0700446 simActivationManager = new SimActivationManager();
447
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700448 // XXX pre-load the SimProvider so that it's ready
449 resolver.getType(Uri.parse("content://icc/adn"));
450
451 // start with the default value to set the mute state.
452 mShouldRestoreMuteOnInCallResume = false;
453
454 // TODO: Register for Cdma Information Records
455 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
456
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700457 // Read HAC settings and configure audio hardware
458 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800459 int hac = android.provider.Settings.System.getInt(
460 getContentResolver(),
461 android.provider.Settings.System.HEARING_AID,
462 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700463 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Andrew Leefb7f92e2015-02-26 16:23:32 -0800464 audioManager.setParameter(SettingsConstants.HAC_KEY,
465 hac == SettingsConstants.HAC_ENABLED
466 ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700467 }
Santos Cordonff506f52013-11-21 19:13:19 -0800468 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700469
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700470 /**
471 * Returns the singleton instance of the PhoneApp.
472 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800473 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700474 if (sMe == null) {
475 throw new IllegalStateException("No PhoneGlobals here!");
476 }
477 return sMe;
478 }
479
480 /**
481 * Returns the singleton instance of the PhoneApp if running as the
482 * primary user, otherwise null.
483 */
484 static PhoneGlobals getInstanceIfPrimary() {
485 return sMe;
486 }
487
488 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800489 * Returns the default phone.
490 *
Andrew Lee385019f2014-11-24 14:19:50 -0800491 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700492 */
Andrew Lee83383e42014-10-31 12:42:28 -0700493 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800494 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700495 }
496
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800497 public static Phone getPhone(int subId) {
498 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800499 }
500
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700501 /* package */ BluetoothManager getBluetoothManager() {
502 return bluetoothManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700503 }
504
Santos Cordonde10b752013-09-19 04:11:33 -0700505 /* package */ CallManager getCallManager() {
506 return mCM;
507 }
508
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700509 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700510 * Returns PendingIntent for hanging up ongoing phone call. This will typically be used from
511 * Notification context.
512 */
513 /* package */ static PendingIntent createHangUpOngoingCallPendingIntent(Context context) {
514 Intent intent = new Intent(PhoneGlobals.ACTION_HANG_UP_ONGOING_CALL, null,
515 context, NotificationBroadcastReceiver.class);
516 return PendingIntent.getBroadcast(context, 0, intent, 0);
517 }
518
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700519 boolean isSimPinEnabled() {
520 return mIsSimPinEnabled;
521 }
522
523 boolean authenticateAgainstCachedSimPin(String pin) {
524 return (mCachedSimPin != null && mCachedSimPin.equals(pin));
525 }
526
527 void setCachedSimPin(String pin) {
528 mCachedSimPin = pin;
529 }
530
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700531 /**
532 * Handles OTASP-related events from the telephony layer.
533 *
534 * While an OTASP call is active, the CallNotifier forwards
535 * OTASP-related telephony events to this method.
536 */
537 void handleOtaspEvent(Message msg) {
538 if (DBG) Log.d(LOG_TAG, "handleOtaspEvent(message " + msg + ")...");
539
540 if (otaUtils == null) {
541 // We shouldn't be getting OTASP events without ever
542 // having started the OTASP call in the first place!
543 Log.w(LOG_TAG, "handleOtaEvents: got an event but otaUtils is null! "
544 + "message = " + msg);
545 return;
546 }
547
548 otaUtils.onOtaProvisionStatusChanged((AsyncResult) msg.obj);
549 }
550
551 /**
552 * Similarly, handle the disconnect event of an OTASP call
553 * by forwarding it to the OtaUtils instance.
554 */
555 /* package */ void handleOtaspDisconnect() {
556 if (DBG) Log.d(LOG_TAG, "handleOtaspDisconnect()...");
557
558 if (otaUtils == null) {
559 // We shouldn't be getting OTASP events without ever
560 // having started the OTASP call in the first place!
561 Log.w(LOG_TAG, "handleOtaspDisconnect: otaUtils is null!");
562 return;
563 }
564
565 otaUtils.onOtaspDisconnect();
566 }
567
568 /**
569 * Sets the activity responsible for un-PUK-blocking the device
570 * so that we may close it when we receive a positive result.
571 * mPUKEntryActivity is also used to indicate to the device that
572 * we are trying to un-PUK-lock the phone. In other words, iff
573 * it is NOT null, then we are trying to unlock and waiting for
574 * the SIM to move to READY state.
575 *
576 * @param activity is the activity to close when PUK has
577 * finished unlocking. Can be set to null to indicate the unlock
578 * or SIM READYing process is over.
579 */
580 void setPukEntryActivity(Activity activity) {
581 mPUKEntryActivity = activity;
582 }
583
584 Activity getPUKEntryActivity() {
585 return mPUKEntryActivity;
586 }
587
588 /**
589 * Sets the dialog responsible for notifying the user of un-PUK-
590 * blocking - SIM READYing progress, so that we may dismiss it
591 * when we receive a positive result.
592 *
593 * @param dialog indicates the progress dialog informing the user
594 * of the state of the device. Dismissed upon completion of
595 * READYing process
596 */
597 void setPukEntryProgressDialog(ProgressDialog dialog) {
598 mPUKEntryProgressDialog = dialog;
599 }
600
601 ProgressDialog getPUKEntryProgressDialog() {
602 return mPUKEntryProgressDialog;
603 }
604
605 /**
606 * Controls whether or not the screen is allowed to sleep.
607 *
608 * Once sleep is allowed (WakeState is SLEEP), it will rely on the
609 * settings for the poke lock to determine when to timeout and let
610 * the device sleep {@link PhoneGlobals#setScreenTimeout}.
611 *
612 * @param ws tells the device to how to wake.
613 */
614 /* package */ void requestWakeState(WakeState ws) {
615 if (VDBG) Log.d(LOG_TAG, "requestWakeState(" + ws + ")...");
616 synchronized (this) {
617 if (mWakeState != ws) {
618 switch (ws) {
619 case PARTIAL:
620 // acquire the processor wake lock, and release the FULL
621 // lock if it is being held.
622 mPartialWakeLock.acquire();
623 if (mWakeLock.isHeld()) {
624 mWakeLock.release();
625 }
626 break;
627 case FULL:
628 // acquire the full wake lock, and release the PARTIAL
629 // lock if it is being held.
630 mWakeLock.acquire();
631 if (mPartialWakeLock.isHeld()) {
632 mPartialWakeLock.release();
633 }
634 break;
635 case SLEEP:
636 default:
637 // release both the PARTIAL and FULL locks.
638 if (mWakeLock.isHeld()) {
639 mWakeLock.release();
640 }
641 if (mPartialWakeLock.isHeld()) {
642 mPartialWakeLock.release();
643 }
644 break;
645 }
646 mWakeState = ws;
647 }
648 }
649 }
650
651 /**
652 * If we are not currently keeping the screen on, then poke the power
653 * manager to wake up the screen for the user activity timeout duration.
654 */
655 /* package */ void wakeUpScreen() {
656 synchronized (this) {
657 if (mWakeState == WakeState.SLEEP) {
658 if (DBG) Log.d(LOG_TAG, "pulse screen lock");
659 mPowerManager.wakeUp(SystemClock.uptimeMillis());
660 }
661 }
662 }
663
664 /**
665 * Sets the wake state and screen timeout based on the current state
666 * of the phone, and the current state of the in-call UI.
667 *
668 * This method is a "UI Policy" wrapper around
669 * {@link PhoneGlobals#requestWakeState} and {@link PhoneGlobals#setScreenTimeout}.
670 *
671 * It's safe to call this method regardless of the state of the Phone
672 * (e.g. whether or not it's idle), and regardless of the state of the
673 * Phone UI (e.g. whether or not the InCallScreen is active.)
674 */
675 /* package */ void updateWakeState() {
676 PhoneConstants.State state = mCM.getState();
677
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700678 // True if the speakerphone is in use. (If so, we *always* use
679 // the default timeout. Since the user is obviously not holding
680 // the phone up to his/her face, we don't need to worry about
681 // false touches, and thus don't need to turn the screen off so
682 // aggressively.)
683 // Note that we need to make a fresh call to this method any
684 // time the speaker state changes. (That happens in
685 // PhoneUtils.turnOnSpeaker().)
686 boolean isSpeakerInUse = (state == PhoneConstants.State.OFFHOOK) && PhoneUtils.isSpeakerOn(this);
687
688 // TODO (bug 1440854): The screen timeout *might* also need to
689 // depend on the bluetooth state, but this isn't as clear-cut as
690 // the speaker state (since while using BT it's common for the
691 // user to put the phone straight into a pocket, in which case the
692 // timeout should probably still be short.)
693
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700694 // Decide whether to force the screen on or not.
695 //
696 // Force the screen to be on if the phone is ringing or dialing,
697 // or if we're displaying the "Call ended" UI for a connection in
698 // the "disconnected" state.
699 // However, if the phone is disconnected while the user is in the
700 // middle of selecting a quick response message, we should not force
701 // the screen to be on.
702 //
703 boolean isRinging = (state == PhoneConstants.State.RINGING);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800704 boolean isDialing = (mCM.getFgPhone().getForegroundCall().getState() == Call.State.DIALING);
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700705 boolean keepScreenOn = isRinging || isDialing;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700706 // keepScreenOn == true means we'll hold a full wake lock:
707 requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP);
708 }
709
710 /**
711 * Manually pokes the PowerManager's userActivity method. Since we
712 * set the {@link WindowManager.LayoutParams#INPUT_FEATURE_DISABLE_USER_ACTIVITY}
713 * flag while the InCallScreen is active when there is no proximity sensor,
714 * we need to do this for touch events that really do count as user activity
715 * (like pressing any onscreen UI elements.)
716 */
717 /* package */ void pokeUserActivity() {
718 if (VDBG) Log.d(LOG_TAG, "pokeUserActivity()...");
719 mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
720 }
721
722 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700723 * Notifies the phone app when the phone state changes.
724 *
Santos Cordonfc309812013-08-20 18:33:16 -0700725 * This method will updates various states inside Phone app (e.g. update-lock state, etc.)
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700726 */
727 /* package */ void updatePhoneState(PhoneConstants.State state) {
728 if (state != mLastPhoneState) {
729 mLastPhoneState = state;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700730
731 // Try to acquire or release UpdateLock.
732 //
733 // Watch out: we don't release the lock here when the screen is still in foreground.
734 // At that time InCallScreen will release it on onPause().
735 if (state != PhoneConstants.State.IDLE) {
736 // UpdateLock is a recursive lock, while we may get "acquire" request twice and
737 // "release" request once for a single call (RINGING + OFFHOOK and IDLE).
738 // We need to manually ensure the lock is just acquired once for each (and this
739 // will prevent other possible buggy situations too).
740 if (!mUpdateLock.isHeld()) {
741 mUpdateLock.acquire();
742 }
743 } else {
Jay Shraunera5d13212013-09-19 13:37:43 -0700744 if (mUpdateLock.isHeld()) {
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700745 mUpdateLock.release();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700746 }
747 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700748 }
749 }
750
751 /* package */ PhoneConstants.State getPhoneState() {
752 return mLastPhoneState;
753 }
754
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700755 KeyguardManager getKeyguardManager() {
756 return mKeyguardManager;
757 }
758
759 private void onMMIComplete(AsyncResult r) {
760 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
761 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800762 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700763 }
764
Stuart Scottdcf40a92014-12-09 10:45:01 -0800765 private void initForNewRadioTechnology(int phoneId) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700766 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
767
Stuart Scottdcf40a92014-12-09 10:45:01 -0800768 final Phone phone = PhoneFactory.getPhone(phoneId);
769
770 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700771 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
772 cdmaPhoneCallState = new CdmaPhoneCallState();
773 cdmaPhoneCallState.CdmaPhoneCallStateInit();
774 }
Santos Cordon52bc81b2014-10-07 19:55:12 -0700775 if (!TelephonyCapabilities.supportsOtasp(phone)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700776 //Clean up OTA data in GSM/UMTS. It is valid only for CDMA
777 clearOtaState();
778 }
779
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700780 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
781 callStateMonitor.updateAfterRadioTechnologyChange();
782
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700783 // Update registration for ICC status after radio technology change
784 IccCard sim = phone.getIccCard();
785 if (sim != null) {
786 if (DBG) Log.d(LOG_TAG, "Update registration for ICC status...");
787
788 //Register all events new to the new active phone
789 sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
790 }
791 }
792
Santos Cordon593ab382013-08-06 21:58:23 -0700793 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700794 * Receiver for misc intent broadcasts the Phone app cares about.
795 */
796 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
797 @Override
798 public void onReceive(Context context, Intent intent) {
799 String action = intent.getAction();
800 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
801 boolean enabled = System.getInt(getContentResolver(),
802 System.AIRPLANE_MODE_ON, 0) == 0;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800803 PhoneUtils.setRadioPower(enabled);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700804 } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800805 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
806 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
807 int phoneId = SubscriptionManager.getPhoneId(subId);
808 String state = intent.getStringExtra(PhoneConstants.STATE_KEY);
809 if (VDBG) {
810 Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED");
811 Log.d(LOG_TAG, "- state: " + state);
812 Log.d(LOG_TAG, "- reason: "
813 + intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
814 Log.d(LOG_TAG, "- subId: " + subId);
815 Log.d(LOG_TAG, "- phoneId: " + phoneId);
816 }
817 Phone phone = SubscriptionManager.isValidPhoneId(phoneId) ?
818 PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700819 // The "data disconnected due to roaming" notification is shown
820 // if (a) you have the "data roaming" feature turned off, and
821 // (b) you just lost data connectivity because you're roaming.
822 boolean disconnectedDueToRoaming =
823 !phone.getDataRoamingEnabled()
Stuart Scottdcf40a92014-12-09 10:45:01 -0800824 && PhoneConstants.DataState.DISCONNECTED.equals(state)
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700825 && Phone.REASON_ROAMING_ON.equals(
826 intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
Yorke Lee4d2db1c2014-11-06 11:37:09 -0800827 if (mDataDisconnectedDueToRoaming != disconnectedDueToRoaming) {
828 mDataDisconnectedDueToRoaming = disconnectedDueToRoaming;
829 mHandler.sendEmptyMessage(disconnectedDueToRoaming
830 ? EVENT_DATA_ROAMING_DISCONNECTED : EVENT_DATA_ROAMING_OK);
831 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700832 } else if ((action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) &&
833 (mPUKEntryActivity != null)) {
834 // if an attempt to un-PUK-lock the device was made, while we're
835 // receiving this state change notification, notify the handler.
836 // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has
837 // been attempted.
838 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
839 intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)));
840 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
841 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800842 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
843 SubscriptionManager.INVALID_PHONE_INDEX);
844 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " (" + phoneId
845 + ") is active.");
846 initForNewRadioTechnology(phoneId);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700847 } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
848 handleServiceStateChanged(intent);
849 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800850 if (TelephonyCapabilities.supportsEcm(mCM.getFgPhone())) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700851 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
852 // Start Emergency Callback Mode service
853 if (intent.getBooleanExtra("phoneinECMState", false)) {
854 context.startService(new Intent(context,
855 EmergencyCallbackModeService.class));
856 }
857 } else {
858 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
859 // on a device that doesn't support ECM in the first place.
860 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, "
Stuart Scottdcf40a92014-12-09 10:45:01 -0800861 + "but ECM isn't supported for phone: "
862 + mCM.getFgPhone().getPhoneName());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700863 }
864 } else if (action.equals(Intent.ACTION_DOCK_EVENT)) {
865 mDockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
866 Intent.EXTRA_DOCK_STATE_UNDOCKED);
867 if (VDBG) Log.d(LOG_TAG, "ACTION_DOCK_EVENT -> mDockState = " + mDockState);
868 mHandler.sendMessage(mHandler.obtainMessage(EVENT_DOCK_STATE_CHANGED, 0));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700869 }
870 }
871 }
872
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700873 /**
874 * Accepts broadcast Intents which will be prepared by {@link NotificationMgr} and thus
875 * sent from framework's notification mechanism (which is outside Phone context).
876 * This should be visible from outside, but shouldn't be in "exported" state.
877 *
878 * TODO: If possible merge this into PhoneAppBroadcastReceiver.
879 */
880 public static class NotificationBroadcastReceiver extends BroadcastReceiver {
881 @Override
882 public void onReceive(Context context, Intent intent) {
883 String action = intent.getAction();
884 // TODO: use "if (VDBG)" here.
885 Log.d(LOG_TAG, "Broadcast from Notification: " + action);
886
887 if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
888 PhoneUtils.hangup(PhoneGlobals.getInstance().mCM);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700889 } else {
890 Log.w(LOG_TAG, "Received hang-up request from notification,"
891 + " but there's no call the system can hang up.");
892 }
893 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700894 }
895
896 private void handleServiceStateChanged(Intent intent) {
897 /**
898 * This used to handle updating EriTextWidgetProvider this routine
899 * and and listening for ACTION_SERVICE_STATE_CHANGED intents could
900 * be removed. But leaving just in case it might be needed in the near
901 * future.
902 */
903
904 // If service just returned, start sending out the queued messages
905 ServiceState ss = ServiceState.newFromBundle(intent.getExtras());
906
907 if (ss != null) {
908 int state = ss.getState();
909 notificationMgr.updateNetworkSelection(state);
910 }
911 }
912
913 public boolean isOtaCallInActiveState() {
914 boolean otaCallActive = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700915 if (VDBG) Log.d(LOG_TAG, "- isOtaCallInActiveState " + otaCallActive);
916 return otaCallActive;
917 }
918
919 public boolean isOtaCallInEndState() {
920 boolean otaCallEnded = false;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700921 if (VDBG) Log.d(LOG_TAG, "- isOtaCallInEndState " + otaCallEnded);
922 return otaCallEnded;
923 }
924
925 // it is safe to call clearOtaState() even if the InCallScreen isn't active
926 public void clearOtaState() {
927 if (DBG) Log.d(LOG_TAG, "- clearOtaState ...");
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700928 if (otaUtils != null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700929 otaUtils.cleanOtaScreen(true);
930 if (DBG) Log.d(LOG_TAG, " - clearOtaState clears OTA screen");
931 }
932 }
933
934 // it is safe to call dismissOtaDialogs() even if the InCallScreen isn't active
935 public void dismissOtaDialogs() {
936 if (DBG) Log.d(LOG_TAG, "- dismissOtaDialogs ...");
Jay Shrauner6fe8fd62013-09-16 19:39:30 -0700937 if (otaUtils != null) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700938 otaUtils.dismissAllOtaDialogs();
939 if (DBG) Log.d(LOG_TAG, " - dismissOtaDialogs clears OTA dialogs");
940 }
941 }
942
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700943 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -0800944 * Triggers a refresh of the message waiting (voicemail) indicator.
945 *
946 * @param subId the subscription id we should refresh the notification for.
947 */
948 public void refreshMwiIndicator(int subId) {
949 notificationMgr.refreshMwi(subId);
950 }
951
952 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700953 * "Call origin" may be used by Contacts app to specify where the phone call comes from.
954 * Currently, the only permitted value for this extra is {@link #ALLOWED_EXTRA_CALL_ORIGIN}.
955 * Any other value will be ignored, to make sure that malicious apps can't trick the in-call
956 * UI into launching some random other app after a call ends.
957 *
958 * TODO: make this more generic. Note that we should let the "origin" specify its package
959 * while we are now assuming it is "com.android.contacts"
960 */
961 public static final String EXTRA_CALL_ORIGIN = "com.android.phone.CALL_ORIGIN";
962 private static final String DEFAULT_CALL_ORIGIN_PACKAGE = "com.android.dialer";
963 private static final String ALLOWED_EXTRA_CALL_ORIGIN =
964 "com.android.dialer.DialtactsActivity";
965 /**
966 * Used to determine if the preserved call origin is fresh enough.
967 */
968 private static final long CALL_ORIGIN_EXPIRATION_MILLIS = 30 * 1000;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700969}