Refactoring into Telecomm Codebase and cleanup
Cleans up obsolete parts of services/Telephony.
Bug: 26204262
Change-Id: Id11bb2a20fe948d51bdc1f3ba00ae9ecb6dba14d
diff --git a/src/com/android/phone/CallController.java b/src/com/android/phone/CallController.java
index 3af4d7d..5b08662 100644
--- a/src/com/android/phone/CallController.java
+++ b/src/com/android/phone/CallController.java
@@ -234,16 +234,6 @@
checkForOtaspCall(intent);
}
- // Clear out the "restore mute state" flag since we're
- // initiating a brand-new call.
- //
- // (This call to setRestoreMuteOnInCallResume(false) informs the
- // phone app that we're dealing with a new connection
- // (i.e. placing an outgoing call, and NOT handling an aborted
- // "Add Call" request), so we should let the mute state be handled
- // by the PhoneUtils phone state change handler.)
- mApp.setRestoreMuteOnInCallResume(false);
-
CallStatusCode status = placeCallInternal(intent);
switch (status) {
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 14913f9..cfffb94 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -68,30 +68,15 @@
// Time to display the message from the underlying phone layers.
private static final int SHOW_MESSAGE_NOTIFICATION_TIME = 3000; // msec
- private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
- .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
- .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
- .build();
-
/** The singleton instance. */
private static CallNotifier sInstance;
- // values used to track the query state
- private static final int CALLERINFO_QUERY_READY = 0;
- private static final int CALLERINFO_QUERYING = -1;
-
- // the state of the CallerInfo Query.
- private int mCallerInfoQueryState;
-
- // object used to synchronize access to mCallerInfoQueryState
- private Object mCallerInfoQueryStateGuard = new Object();
private Map<Integer, CallNotifierPhoneStateListener> mPhoneStateListeners =
new ArrayMap<Integer, CallNotifierPhoneStateListener>();
private PhoneGlobals mApplication;
private CallManager mCM;
private BluetoothHeadset mBluetoothHeadset;
- private CallLogger mCallLogger;
// ToneGenerator instance for playing SignalInfo tones
private ToneGenerator mSignalInfoToneGenerator;
@@ -99,26 +84,37 @@
// The tone volume relative to other sounds in the stream SignalInfo
private static final int TONE_RELATIVE_VOLUME_SIGNALINFO = 80;
- private Call.State mPreviousCdmaCallState;
private boolean mVoicePrivacyState = false;
- private boolean mIsCdmaRedialCall = false;
// Cached AudioManager
private AudioManager mAudioManager;
private SubscriptionManager mSubscriptionManager;
private TelephonyManager mTelephonyManager;
+ // Events from the Phone object:
+ public static final int PHONE_DISCONNECT = 3;
+ public static final int PHONE_STATE_DISPLAYINFO = 6;
+ public static final int PHONE_STATE_SIGNALINFO = 7;
+ public static final int PHONE_ENHANCED_VP_ON = 9;
+ public static final int PHONE_ENHANCED_VP_OFF = 10;
+ public static final int PHONE_SUPP_SERVICE_FAILED = 14;
+ public static final int PHONE_TTY_MODE_RECEIVED = 15;
+ // Events generated internally.
+ // We should store all the possible event type values in one place to make sure that
+ // they don't step on each others' toes.
+ public static final int INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE = 22;
+ // Other events from call manager
+ public static final int EVENT_OTA_PROVISION_CHANGE = 20;
+
/**
* Initialize the singleton CallNotifier instance.
* This is only done once, at startup, from PhoneApp.onCreate().
*/
/* package */ static CallNotifier init(
- PhoneGlobals app,
- CallLogger callLogger,
- CallStateMonitor callStateMonitor) {
+ PhoneGlobals app) {
synchronized (CallNotifier.class) {
if (sInstance == null) {
- sInstance = new CallNotifier(app, callLogger, callStateMonitor);
+ sInstance = new CallNotifier(app);
} else {
Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance);
}
@@ -128,12 +124,9 @@
/** Private constructor; @see init() */
private CallNotifier(
- PhoneGlobals app,
- CallLogger callLogger,
- CallStateMonitor callStateMonitor) {
+ PhoneGlobals app) {
mApplication = app;
mCM = app.mCM;
- mCallLogger = callLogger;
mAudioManager = (AudioManager) mApplication.getSystemService(Context.AUDIO_SERVICE);
mTelephonyManager =
@@ -141,7 +134,7 @@
mSubscriptionManager = (SubscriptionManager) mApplication.getSystemService(
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
- callStateMonitor.addListener(this);
+ registerForNotifications();
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
@@ -179,50 +172,54 @@
}
}
+ /**
+ * Register for call state notifications with the CallManager.
+ */
+ private void registerForNotifications() {
+ mCM.registerForDisconnect(this, PHONE_DISCONNECT, null);
+ mCM.registerForCdmaOtaStatusChange(this, EVENT_OTA_PROVISION_CHANGE, null);
+ mCM.registerForDisplayInfo(this, PHONE_STATE_DISPLAYINFO, null);
+ mCM.registerForSignalInfo(this, PHONE_STATE_SIGNALINFO, null);
+ mCM.registerForInCallVoicePrivacyOn(this, PHONE_ENHANCED_VP_ON, null);
+ mCM.registerForInCallVoicePrivacyOff(this, PHONE_ENHANCED_VP_OFF, null);
+ mCM.registerForSuppServiceFailed(this, PHONE_SUPP_SERVICE_FAILED, null);
+ mCM.registerForTtyModeReceived(this, PHONE_TTY_MODE_RECEIVED, null);
+ }
+
@Override
public void handleMessage(Message msg) {
+ if (DBG) {
+ Log.d(LOG_TAG, "handleMessage(" + msg.what + ")");
+ }
switch (msg.what) {
- case CallStateMonitor.PHONE_NEW_RINGING_CONNECTION:
- log("RINGING... (new)");
- onNewRingingConnection((AsyncResult) msg.obj);
- break;
-
- case CallStateMonitor.PHONE_STATE_CHANGED:
- onPhoneStateChanged((AsyncResult) msg.obj);
- break;
-
- case CallStateMonitor.PHONE_DISCONNECT:
+ case PHONE_DISCONNECT:
if (DBG) log("DISCONNECT");
// Stop any signalInfo tone being played when a call gets ended, the rest of the
// disconnect functionality in onDisconnect() is handled in ConnectionService.
stopSignalInfoTone();
break;
- case CallStateMonitor.PHONE_UNKNOWN_CONNECTION_APPEARED:
- onUnknownConnectionAppeared((AsyncResult) msg.obj);
- break;
-
- case CallStateMonitor.PHONE_STATE_DISPLAYINFO:
+ case PHONE_STATE_DISPLAYINFO:
if (DBG) log("Received PHONE_STATE_DISPLAYINFO event");
onDisplayInfo((AsyncResult) msg.obj);
break;
- case CallStateMonitor.PHONE_STATE_SIGNALINFO:
+ case PHONE_STATE_SIGNALINFO:
if (DBG) log("Received PHONE_STATE_SIGNALINFO event");
onSignalInfo((AsyncResult) msg.obj);
break;
- case CallStateMonitor.INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE:
+ case INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE:
if (DBG) log("Received Display Info notification done event ...");
PhoneDisplayMessage.dismissMessage();
break;
- case CallStateMonitor.EVENT_OTA_PROVISION_CHANGE:
+ case EVENT_OTA_PROVISION_CHANGE:
if (DBG) log("EVENT_OTA_PROVISION_CHANGE...");
mApplication.handleOtaspEvent(msg);
break;
- case CallStateMonitor.PHONE_ENHANCED_VP_ON:
+ case PHONE_ENHANCED_VP_ON:
if (DBG) log("PHONE_ENHANCED_VP_ON...");
if (!mVoicePrivacyState) {
int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY;
@@ -231,7 +228,7 @@
}
break;
- case CallStateMonitor.PHONE_ENHANCED_VP_OFF:
+ case PHONE_ENHANCED_VP_OFF:
if (DBG) log("PHONE_ENHANCED_VP_OFF...");
if (mVoicePrivacyState) {
int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY;
@@ -240,12 +237,12 @@
}
break;
- case CallStateMonitor.PHONE_SUPP_SERVICE_FAILED:
+ case PHONE_SUPP_SERVICE_FAILED:
if (DBG) log("PHONE_SUPP_SERVICE_FAILED...");
onSuppServiceFailed((AsyncResult) msg.obj);
break;
- case CallStateMonitor.PHONE_TTY_MODE_RECEIVED:
+ case PHONE_TTY_MODE_RECEIVED:
if (DBG) log("Received PHONE_TTY_MODE_RECEIVED event");
onTtyModeReceived((AsyncResult) msg.obj);
break;
@@ -255,207 +252,6 @@
}
}
- /**
- * Handles a "new ringing connection" event from the telephony layer.
- */
- private void onNewRingingConnection(AsyncResult r) {
- Connection c = (Connection) r.result;
- log("onNewRingingConnection(): state = " + mCM.getState() + ", conn = { " + c + " }");
- Call ringing = c.getCall();
- Phone phone = ringing.getPhone();
-
- // Check for a few cases where we totally ignore incoming calls.
- if (ignoreAllIncomingCalls(phone)) {
- // Immediately reject the call, without even indicating to the user
- // that an incoming call occurred. (This will generally send the
- // caller straight to voicemail, just as if we *had* shown the
- // incoming-call UI and the user had declined the call.)
- PhoneUtils.hangupRingingCall(ringing);
- return;
- }
-
- if (!c.isRinging()) {
- Log.i(LOG_TAG, "CallNotifier.onNewRingingConnection(): connection not ringing!");
- // This is a very strange case: an incoming call that stopped
- // ringing almost instantly after the onNewRingingConnection()
- // event. There's nothing we can do here, so just bail out
- // without doing anything. (But presumably we'll log it in
- // the call log when the disconnect event comes in...)
- return;
- }
-
- // Stop any signalInfo tone being played on receiving a Call
- stopSignalInfoTone();
-
- Call.State state = c.getState();
- // State will be either INCOMING or WAITING.
- if (VDBG) log("- connection is ringing! state = " + state);
- // if (DBG) PhoneUtils.dumpCallState(mPhone);
-
- // No need to do any service state checks here (like for
- // "emergency mode"), since in those states the SIM won't let
- // us get incoming connections in the first place.
-
- // TODO: Consider sending out a serialized broadcast Intent here
- // (maybe "ACTION_NEW_INCOMING_CALL"), *before* starting the
- // ringer and going to the in-call UI. The intent should contain
- // the caller-id info for the current connection, and say whether
- // it would be a "call waiting" call or a regular ringing call.
- // If anybody consumed the broadcast, we'd bail out without
- // ringing or bringing up the in-call UI.
- //
- // This would give 3rd party apps a chance to listen for (and
- // intercept) new ringing connections. An app could reject the
- // incoming call by consuming the broadcast and doing nothing, or
- // it could "pick up" the call (without any action by the user!)
- // via some future TelephonyManager API.
- //
- // See bug 1312336 for more details.
- // We'd need to protect this with a new "intercept incoming calls"
- // system permission.
-
- // Obtain a partial wake lock to make sure the CPU doesn't go to
- // sleep before we finish bringing up the InCallScreen.
- // (This will be upgraded soon to a full wake lock; see
- // showIncomingCall().)
- if (VDBG) log("Holding wake lock on new incoming connection.");
- mApplication.requestWakeState(PhoneGlobals.WakeState.PARTIAL);
-
- // Note we *don't* post a status bar notification here, since
- // we're not necessarily ready to actually show the incoming call
- // to the user. (For calls in the INCOMING state, at least, we
- // still need to run a caller-id query, and we may not even ring
- // at all if the "send directly to voicemail" flag is set.)
- //
- // Instead, we update the notification (and potentially launch the
- // InCallScreen) from the showIncomingCall() method, which runs
- // when the caller-id query completes or times out.
-
- if (VDBG) log("- onNewRingingConnection() done.");
- }
-
- /**
- * Determines whether or not we're allowed to present incoming calls to the
- * user, based on the capabilities and/or current state of the device.
- *
- * If this method returns true, that means we should immediately reject the
- * current incoming call, without even indicating to the user that an
- * incoming call occurred.
- *
- * (We only reject incoming calls in a few cases, like during an OTASP call
- * when we can't interrupt the user, or if the device hasn't completed the
- * SetupWizard yet. We also don't allow incoming calls on non-voice-capable
- * devices. But note that we *always* allow incoming calls while in ECM.)
- *
- * @return true if we're *not* allowed to present an incoming call to
- * the user.
- */
- private boolean ignoreAllIncomingCalls(Phone phone) {
- // Incoming calls are totally ignored on non-voice-capable devices.
- if (!PhoneGlobals.sVoiceCapable) {
- // ...but still log a warning, since we shouldn't have gotten this
- // event in the first place! (Incoming calls *should* be blocked at
- // the telephony layer on non-voice-capable capable devices.)
- Log.w(LOG_TAG, "Got onNewRingingConnection() on non-voice-capable device! Ignoring...");
- return true;
- }
-
- // In ECM (emergency callback mode), we ALWAYS allow incoming calls
- // to get through to the user. (Note that ECM is applicable only to
- // voice-capable CDMA devices).
- if (PhoneUtils.isPhoneInEcm(phone)) {
- if (DBG) log("Incoming call while in ECM: always allow...");
- return false;
- }
-
- // Incoming calls are totally ignored if the device isn't provisioned yet.
- boolean provisioned = Settings.Global.getInt(mApplication.getContentResolver(),
- Settings.Global.DEVICE_PROVISIONED, 0) != 0;
- if (!provisioned) {
- Log.i(LOG_TAG, "Ignoring incoming call: not provisioned");
- return true;
- }
-
- // Incoming calls are totally ignored if an OTASP call is active.
- if (TelephonyCapabilities.supportsOtasp(phone)) {
- boolean activateState = (mApplication.cdmaOtaScreenState.otaScreenState
- == OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION);
- boolean dialogState = (mApplication.cdmaOtaScreenState.otaScreenState
- == OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG);
- boolean spcState = mApplication.cdmaOtaProvisionData.inOtaSpcState;
-
- if (spcState) {
- Log.i(LOG_TAG, "Ignoring incoming call: OTA call is active");
- return true;
- } else if (activateState || dialogState) {
- // We *are* allowed to receive incoming calls at this point.
- // But clear out any residual OTASP UI first.
- // TODO: It's an MVC violation to twiddle the OTA UI state here;
- // we should instead provide a higher-level API via OtaUtils.
- if (dialogState) mApplication.dismissOtaDialogs();
- mApplication.clearOtaState();
- return false;
- }
- }
-
- // Normal case: allow this call to be presented to the user.
- return false;
- }
-
- private void onUnknownConnectionAppeared(AsyncResult r) {
- PhoneConstants.State state = mCM.getState();
-
- if (state == PhoneConstants.State.OFFHOOK) {
- if (DBG) log("unknown connection appeared...");
-
- onPhoneStateChanged(r);
- }
- }
-
- /**
- * Updates the phone UI in response to phone state changes.
- *
- * Watch out: certain state changes are actually handled by their own
- * specific methods:
- * - see onNewRingingConnection() for new incoming calls
- * - see onDisconnect() for calls being hung up or disconnected
- */
- private void onPhoneStateChanged(AsyncResult r) {
- PhoneConstants.State state = mCM.getState();
- if (VDBG) log("onPhoneStateChanged: state = " + state);
-
- // Turn status bar notifications on or off depending upon the state
- // of the phone. Notification Alerts (audible or vibrating) should
- // be on if and only if the phone is IDLE.
- mApplication.notificationMgr.statusBarHelper
- .enableNotificationAlerts(state == PhoneConstants.State.IDLE);
-
- Phone fgPhone = mCM.getFgPhone();
- if (fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
- if ((fgPhone.getForegroundCall().getState() == Call.State.ACTIVE)
- && ((mPreviousCdmaCallState == Call.State.DIALING)
- || (mPreviousCdmaCallState == Call.State.ALERTING))) {
- if (mIsCdmaRedialCall) {
- int toneToPlay = InCallTonePlayer.TONE_REDIAL;
- new InCallTonePlayer(toneToPlay).start();
- }
- // Stop any signal info tone when call moves to ACTIVE state
- stopSignalInfoTone();
- }
- mPreviousCdmaCallState = fgPhone.getForegroundCall().getState();
- }
-
- // Update the phone state and other sensor/lock.
- mApplication.updatePhoneState(state);
-
- if (state == PhoneConstants.State.OFFHOOK) {
-
- if (VDBG) log("onPhoneStateChanged: OFF HOOK");
- // make sure audio is in in-call mode now
- PhoneUtils.setAudioMode(mCM);
- }
- }
-
void updateCallNotifierRegistrationsAfterRadioTechnologyChange() {
if (DBG) Log.d(LOG_TAG, "updateCallNotifierRegistrationsAfterRadioTechnologyChange...");
@@ -463,129 +259,6 @@
createSignalInfoToneGenerator();
}
- private void onDisconnect(AsyncResult r) {
- if (VDBG) log("onDisconnect()... CallManager state: " + mCM.getState());
-
- mVoicePrivacyState = false;
- Connection c = (Connection) r.result;
- if (c != null) {
- log("onDisconnect: cause = " + DisconnectCause.toString(c.getDisconnectCause())
- + ", incoming = " + c.isIncoming()
- + ", date = " + c.getCreateTime());
- } else {
- Log.w(LOG_TAG, "onDisconnect: null connection");
- }
-
- int autoretrySetting = 0;
- if ((c != null) &&
- (c.getCall().getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)) {
- autoretrySetting = android.provider.Settings.Global.getInt(mApplication.
- getContentResolver(),android.provider.Settings.Global.CALL_AUTO_RETRY, 0);
- }
-
- // Stop any signalInfo tone being played when a call gets ended
- stopSignalInfoTone();
-
- if ((c != null) &&
- (c.getCall().getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)) {
- // Resetting the CdmaPhoneCallState members
- mApplication.cdmaPhoneCallState.resetCdmaPhoneCallState();
- }
-
- // If this is the end of an OTASP call, pass it on to the PhoneApp.
- if (c != null && TelephonyCapabilities.supportsOtasp(c.getCall().getPhone())) {
- final String number = c.getAddress();
- if (c.getCall().getPhone().isOtaSpNumber(number)) {
- if (DBG) log("onDisconnect: this was an OTASP call!");
- mApplication.handleOtaspDisconnect();
- }
- }
-
- // Check for the various tones we might need to play (thru the
- // earpiece) after a call disconnects.
- int toneToPlay = InCallTonePlayer.TONE_NONE;
-
- // If we don't need to play BUSY or CONGESTION, then play the
- // "call ended" tone if this was a "regular disconnect" (i.e. a
- // normal call where one end or the other hung up) *and* this
- // disconnect event caused the phone to become idle. (In other
- // words, we *don't* play the sound if one call hangs up but
- // there's still an active call on the other line.)
- // TODO: We may eventually want to disable this via a preference.
- if ((toneToPlay == InCallTonePlayer.TONE_NONE)
- && (mCM.getState() == PhoneConstants.State.IDLE)
- && (c != null)) {
- int cause = c.getDisconnectCause();
- if ((cause == DisconnectCause.NORMAL) // remote hangup
- || (cause == DisconnectCause.LOCAL)) { // local hangup
- if (VDBG) log("- need to play CALL_ENDED tone!");
- toneToPlay = InCallTonePlayer.TONE_CALL_ENDED;
- mIsCdmaRedialCall = false;
- }
- }
-
- // All phone calls are disconnected.
- if (mCM.getState() == PhoneConstants.State.IDLE) {
- // Don't reset the audio mode or bluetooth/speakerphone state
- // if we still need to let the user hear a tone through the earpiece.
- if (toneToPlay == InCallTonePlayer.TONE_NONE) {
- resetAudioStateAfterDisconnect();
- }
- }
-
- if (c != null) {
- mCallLogger.logCall(c);
-
- final String number = c.getAddress();
- final Phone phone = c.getCall().getPhone();
- final boolean isEmergencyNumber =
- PhoneNumberUtils.isLocalEmergencyNumber(mApplication, number);
-
- // Possibly play a "post-disconnect tone" thru the earpiece.
- // We do this here, rather than from the InCallScreen
- // activity, since we need to do this even if you're not in
- // the Phone UI at the moment the connection ends.
- if (toneToPlay != InCallTonePlayer.TONE_NONE) {
- if (VDBG) log("- starting post-disconnect tone (" + toneToPlay + ")...");
- new InCallTonePlayer(toneToPlay).start();
-
- // TODO: alternatively, we could start an InCallTonePlayer
- // here with an "unlimited" tone length,
- // and manually stop it later when this connection truly goes
- // away. (The real connection over the network was closed as soon
- // as we got the BUSY message. But our telephony layer keeps the
- // connection open for a few extra seconds so we can show the
- // "busy" indication to the user. We could stop the busy tone
- // when *that* connection's "disconnect" event comes in.)
- }
-
- final int cause = c.getDisconnectCause();
- if (((mPreviousCdmaCallState == Call.State.DIALING)
- || (mPreviousCdmaCallState == Call.State.ALERTING))
- && (!isEmergencyNumber)
- && (cause != DisconnectCause.INCOMING_MISSED )
- && (cause != DisconnectCause.NORMAL)
- && (cause != DisconnectCause.LOCAL)
- && (cause != DisconnectCause.INCOMING_REJECTED)) {
- if (!mIsCdmaRedialCall) {
- if (autoretrySetting == InCallScreen.AUTO_RETRY_ON) {
- // TODO: (Moto): The contact reference data may need to be stored and use
- // here when redialing a call. For now, pass in NULL as the URI parameter.
- final int status =
- PhoneUtils.placeCall(mApplication, phone, number, null, false);
- if (status != PhoneUtils.CALL_STATUS_FAILED) {
- mIsCdmaRedialCall = true;
- }
- } else {
- mIsCdmaRedialCall = false;
- }
- } else {
- mIsCdmaRedialCall = false;
- }
- }
- }
- }
-
/**
* Resets the audio mode and speaker state when a call ends.
*/
@@ -857,15 +530,6 @@
resetAudioStateAfterDisconnect();
}
}
-
- public void stopTone() {
- synchronized (this) {
- if (mState == TONE_ON) {
- notify();
- }
- mState = TONE_STOPPED;
- }
- }
}
/**
@@ -881,7 +545,7 @@
PhoneDisplayMessage.displayNetworkMessage(mApplication, displayInfo);
// start a timer that kills the dialog
- sendEmptyMessageDelayed(CallStateMonitor.INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
+ sendEmptyMessageDelayed(INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
SHOW_MESSAGE_NOTIFICATION_TIME);
}
}
@@ -910,7 +574,7 @@
PhoneDisplayMessage.displayErrorMessage(mApplication, mergeFailedString);
// start a timer that kills the dialog
- sendEmptyMessageDelayed(CallStateMonitor.INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
+ sendEmptyMessageDelayed(INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
SHOW_MESSAGE_NOTIFICATION_TIME);
}
@@ -996,8 +660,7 @@
mApplication.getResources().getString(resId));
// start a timer that kills the dialog
- sendEmptyMessageDelayed(
- CallStateMonitor.INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
+ sendEmptyMessageDelayed(INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE,
SHOW_MESSAGE_NOTIFICATION_TIME);
}
}
@@ -1081,27 +744,6 @@
new SignalInfoTonePlayer(ToneGenerator.TONE_CDMA_SIGNAL_OFF).start();
}
- /**
- * Return the private variable mPreviousCdmaCallState.
- */
- /* package */ Call.State getPreviousCdmaCallState() {
- return mPreviousCdmaCallState;
- }
-
- /**
- * Return the private variable mVoicePrivacyState.
- */
- /* package */ boolean getVoicePrivacyState() {
- return mVoicePrivacyState;
- }
-
- /**
- * Return the private variable mIsCdmaRedialCall.
- */
- /* package */ boolean getIsCdmaRedialCall() {
- return mIsCdmaRedialCall;
- }
-
private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener =
new BluetoothProfile.ServiceListener() {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
diff --git a/src/com/android/phone/CallStateMonitor.java b/src/com/android/phone/CallStateMonitor.java
deleted file mode 100644
index 027eba7..0000000
--- a/src/com/android/phone/CallStateMonitor.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone;
-
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Message;
-import android.os.SystemProperties;
-import android.util.Log;
-
-import com.android.internal.telephony.CallManager;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-
-/**
- * Dedicated Call state monitoring class. This class communicates directly with
- * the call manager to listen for call state events and notifies registered
- * handlers.
- * It works as an inverse multiplexor for all classes wanted Call State updates
- * so that there exists only one channel to the telephony layer.
- *
- * TODO: Add manual phone state checks (getState(), etc.).
- */
-class CallStateMonitor extends Handler {
- private static final String LOG_TAG = CallStateMonitor.class.getSimpleName();
- private static final boolean DBG =
- (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
-
- // Events from the Phone object:
- public static final int PHONE_STATE_CHANGED = 1;
- public static final int PHONE_NEW_RINGING_CONNECTION = 2;
- public static final int PHONE_DISCONNECT = 3;
- public static final int PHONE_UNKNOWN_CONNECTION_APPEARED = 4;
- public static final int PHONE_STATE_DISPLAYINFO = 6;
- public static final int PHONE_STATE_SIGNALINFO = 7;
- public static final int PHONE_CDMA_CALL_WAITING = 8;
- public static final int PHONE_ENHANCED_VP_ON = 9;
- public static final int PHONE_ENHANCED_VP_OFF = 10;
- public static final int PHONE_RINGBACK_TONE = 11;
- public static final int PHONE_RESEND_MUTE = 12;
- public static final int PHONE_ON_DIAL_CHARS = 13;
- public static final int PHONE_SUPP_SERVICE_FAILED = 14;
- public static final int PHONE_TTY_MODE_RECEIVED = 15;
- // Events generated internally.
- // We should store all the possible event type values in one place to make sure that
- // they don't step on each others' toes.
- public static final int INTERNAL_SHOW_MESSAGE_NOTIFICATION_DONE = 22;
- public static final int INTERNAL_UPDATE_IN_CALL_NOTIFICATION = 23;
-
- // Other events from call manager
- public static final int EVENT_OTA_PROVISION_CHANGE = 20;
-
- private CallManager callManager;
- private ArrayList<Handler> registeredHandlers;
-
- // Events generated internally:
- public CallStateMonitor(CallManager callManager) {
- this.callManager = callManager;
- registeredHandlers = new ArrayList<Handler>();
-
- registerForNotifications();
- }
-
- /**
- * Register for call state notifications with the CallManager.
- */
- private void registerForNotifications() {
- //
- // TODO: The lines commented out here can be removed as their associated functionality in
- // other files is removed.
- //
- //callManager.registerForNewRingingConnection(this, PHONE_NEW_RINGING_CONNECTION, null);
- //callManager.registerForPreciseCallStateChanged(this, PHONE_STATE_CHANGED, null);
- callManager.registerForDisconnect(this, PHONE_DISCONNECT, null);
- //callManager.registerForUnknownConnection(this, PHONE_UNKNOWN_CONNECTION_APPEARED, null);
- callManager.registerForCdmaOtaStatusChange(this, EVENT_OTA_PROVISION_CHANGE, null);
- //callManager.registerForCallWaiting(this, PHONE_CDMA_CALL_WAITING, null);
- callManager.registerForDisplayInfo(this, PHONE_STATE_DISPLAYINFO, null);
- callManager.registerForSignalInfo(this, PHONE_STATE_SIGNALINFO, null);
- callManager.registerForInCallVoicePrivacyOn(this, PHONE_ENHANCED_VP_ON, null);
- callManager.registerForInCallVoicePrivacyOff(this, PHONE_ENHANCED_VP_OFF, null);
- callManager.registerForSuppServiceFailed(this, PHONE_SUPP_SERVICE_FAILED, null);
- //callManager.registerForRingbackTone(this, PHONE_RINGBACK_TONE, null);
- //callManager.registerForResendIncallMute(this, PHONE_RESEND_MUTE, null);
- //callManager.registerForPostDialCharacter(this, PHONE_ON_DIAL_CHARS, null);
- callManager.registerForTtyModeReceived(this, PHONE_TTY_MODE_RECEIVED, null);
- }
-
- public void addListener(Handler handler) {
- if (handler != null && !registeredHandlers.contains(handler)) {
- if (DBG) {
- Log.d(LOG_TAG, "Adding Handler: " + handler);
- }
-
- registeredHandlers.add(handler);
- }
- }
-
- @Override
- public void handleMessage(Message msg) {
- if (DBG) {
- Log.d(LOG_TAG, "handleMessage(" + msg.what + ")");
- }
-
- for (Handler handler : registeredHandlers) {
- handler.handleMessage(msg);
- }
- }
-}
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index d223d83..f32d8d5 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -97,8 +97,6 @@
private TelecomManager mTelecomManager;
private TelephonyManager mTelephonyManager;
- public StatusBarHelper statusBarHelper;
-
// used to track the notification of selected network unavailable
private boolean mSelectedUnavailableNotify = false;
@@ -118,7 +116,6 @@
(StatusBarManager) app.getSystemService(Context.STATUS_BAR_SERVICE);
mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE);
mPhone = app.mCM.getDefaultPhone();
- statusBarHelper = new StatusBarHelper();
mSubscriptionManager = SubscriptionManager.from(mContext);
mTelecomManager = TelecomManager.from(mContext);
mTelephonyManager = (TelephonyManager) app.getSystemService(Context.TELEPHONY_SERVICE);
@@ -149,101 +146,6 @@
}
}
- /**
- * Helper class that's a wrapper around the framework's
- * StatusBarManager.disable() API.
- *
- * This class is used to control features like:
- *
- * - Disabling the status bar "notification windowshade"
- * while the in-call UI is up
- *
- * - Disabling notification alerts (audible or vibrating)
- * while a phone call is active
- *
- * - Disabling navigation via the system bar (the "soft buttons" at
- * the bottom of the screen on devices with no hard buttons)
- *
- * We control these features through a single point of control to make
- * sure that the various StatusBarManager.disable() calls don't
- * interfere with each other.
- */
- public class StatusBarHelper {
- // Current desired state of status bar / system bar behavior
- private boolean mIsNotificationEnabled = true;
- private boolean mIsExpandedViewEnabled = true;
- private boolean mIsSystemBarNavigationEnabled = true;
-
- private StatusBarHelper() {
- }
-
- /**
- * Enables or disables auditory / vibrational alerts.
- *
- * (We disable these any time a voice call is active, regardless
- * of whether or not the in-call UI is visible.)
- */
- public void enableNotificationAlerts(boolean enable) {
- if (mIsNotificationEnabled != enable) {
- mIsNotificationEnabled = enable;
- updateStatusBar();
- }
- }
-
- /**
- * Enables or disables the expanded view of the status bar
- * (i.e. the ability to pull down the "notification windowshade").
- *
- * (This feature is disabled by the InCallScreen while the in-call
- * UI is active.)
- */
- public void enableExpandedView(boolean enable) {
- if (mIsExpandedViewEnabled != enable) {
- mIsExpandedViewEnabled = enable;
- updateStatusBar();
- }
- }
-
- /**
- * Enables or disables the navigation via the system bar (the
- * "soft buttons" at the bottom of the screen)
- *
- * (This feature is disabled while an incoming call is ringing,
- * because it's easy to accidentally touch the system bar while
- * pulling the phone out of your pocket.)
- */
- public void enableSystemBarNavigation(boolean enable) {
- if (mIsSystemBarNavigationEnabled != enable) {
- mIsSystemBarNavigationEnabled = enable;
- updateStatusBar();
- }
- }
-
- /**
- * Updates the status bar to reflect the current desired state.
- */
- private void updateStatusBar() {
- int state = StatusBarManager.DISABLE_NONE;
-
- if (!mIsExpandedViewEnabled) {
- state |= StatusBarManager.DISABLE_EXPAND;
- }
- if (!mIsNotificationEnabled) {
- state |= StatusBarManager.DISABLE_NOTIFICATION_ALERTS;
- }
- if (!mIsSystemBarNavigationEnabled) {
- // Disable *all* possible navigation via the system bar.
- state |= StatusBarManager.DISABLE_HOME;
- state |= StatusBarManager.DISABLE_RECENT;
- state |= StatusBarManager.DISABLE_BACK;
- state |= StatusBarManager.DISABLE_SEARCH;
- }
-
- if (DBG) log("updateStatusBar: state = 0x" + Integer.toHexString(state));
- mStatusBarManager.disable(state);
- }
- }
-
/** The projection to use when querying the phones table */
static final String[] PHONES_PROJECTION = new String[] {
PhoneLookup.NUMBER,
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index be3bcfa..fd42f6f 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -130,14 +130,6 @@
FULL
}
- /**
- * Intent Action used for hanging up the current call from Notification bar. This will
- * choose first ringing call, first active call, or first background call (typically in
- * HOLDING state).
- */
- public static final String ACTION_HANG_UP_ONGOING_CALL =
- "com.android.phone.ACTION_HANG_UP_ONGOING_CALL";
-
private static PhoneGlobals sMe;
// A few important fields we expose to the rest of the package
@@ -152,7 +144,6 @@
CarrierConfigLoader configLoader;
private CallGatewayManager callGatewayManager;
- private CallStateMonitor callStateMonitor;
static boolean sVoiceCapable = true;
@@ -166,20 +157,11 @@
private Activity mPUKEntryActivity;
private ProgressDialog mPUKEntryProgressDialog;
- private boolean mIsSimPinEnabled;
- private String mCachedSimPin;
-
- // True if we are beginning a call, but the phone state has not changed yet
- private boolean mBeginningCall;
private boolean mDataDisconnectedDueToRoaming = false;
- // Last phone state seen by updatePhoneState()
- private PhoneConstants.State mLastPhoneState = PhoneConstants.State.IDLE;
-
private WakeState mWakeState = WakeState.SLEEP;
private PowerManager mPowerManager;
- private IPowerManager mPowerManagerService;
private PowerManager.WakeLock mWakeLock;
private PowerManager.WakeLock mPartialWakeLock;
private KeyguardManager mKeyguardManager;
@@ -189,9 +171,6 @@
// Broadcast receiver for various intent broadcasts (see onCreate())
private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
- /** boolean indicating restoring mute state on InCallScreen.onResume() */
- private boolean mShouldRestoreMuteOnInCallResume;
-
/**
* The singleton OtaUtils instance used for OTASP calls.
*
@@ -212,14 +191,6 @@
public OtaUtils.CdmaOtaScreenState cdmaOtaScreenState;
public OtaUtils.CdmaOtaInCallScreenUiState cdmaOtaInCallScreenUiState;
- /**
- * Set the restore mute state flag. Used when we are setting the mute state
- * OUTSIDE of user interaction {@link PhoneUtils#startNewCall(Phone)}
- */
- /*package*/void setRestoreMuteOnInCallResume (boolean mode) {
- mShouldRestoreMuteOnInCallResume = mode;
- }
-
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -345,11 +316,6 @@
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
- // get a handle to the service so that we can use it later when we
- // want to set the poke lock.
- mPowerManagerService = IPowerManager.Stub.asInterface(
- ServiceManager.getService("power"));
-
// Get UpdateLock to suppress system-update related events (e.g. dialog show-up)
// during phone calls.
mUpdateLock = new UpdateLock("phone");
@@ -371,9 +337,6 @@
// The asynchronous caching will start just after this call.
callerInfoCache = CallerInfoCache.init(this);
- // Monitors call activity from the telephony layer
- callStateMonitor = new CallStateMonitor(mCM);
-
phoneMgr = PhoneInterfaceManager.init(this, PhoneFactory.getDefaultPhone());
configLoader = CarrierConfigLoader.init(this);
@@ -382,7 +345,7 @@
// asynchronous events from the telephony layer (like
// launching the incoming-call UI when an incoming call comes
// in.)
- notifier = CallNotifier.init(this, callLogger, callStateMonitor);
+ notifier = CallNotifier.init(this);
PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
@@ -423,9 +386,6 @@
// XXX pre-load the SimProvider so that it's ready
resolver.getType(Uri.parse("content://icc/adn"));
- // start with the default value to set the mute state.
- mShouldRestoreMuteOnInCallResume = false;
-
// TODO: Register for Cdma Information Records
// phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
@@ -486,28 +446,6 @@
}
/**
- * Returns PendingIntent for hanging up ongoing phone call. This will typically be used from
- * Notification context.
- */
- /* package */ static PendingIntent createHangUpOngoingCallPendingIntent(Context context) {
- Intent intent = new Intent(PhoneGlobals.ACTION_HANG_UP_ONGOING_CALL, null,
- context, NotificationBroadcastReceiver.class);
- return PendingIntent.getBroadcast(context, 0, intent, 0);
- }
-
- boolean isSimPinEnabled() {
- return mIsSimPinEnabled;
- }
-
- boolean authenticateAgainstCachedSimPin(String pin) {
- return (mCachedSimPin != null && mCachedSimPin.equals(pin));
- }
-
- void setCachedSimPin(String pin) {
- mCachedSimPin = pin;
- }
-
- /**
* Handles OTASP-related events from the telephony layer.
*
* While an OTASP call is active, the CallNotifier forwards
@@ -577,10 +515,6 @@
mPUKEntryProgressDialog = dialog;
}
- ProgressDialog getPUKEntryProgressDialog() {
- return mPUKEntryProgressDialog;
- }
-
/**
* Controls whether or not the screen is allowed to sleep.
*
@@ -686,51 +620,6 @@
requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP);
}
- /**
- * Manually pokes the PowerManager's userActivity method. Since we
- * set the {@link WindowManager.LayoutParams#INPUT_FEATURE_DISABLE_USER_ACTIVITY}
- * flag while the InCallScreen is active when there is no proximity sensor,
- * we need to do this for touch events that really do count as user activity
- * (like pressing any onscreen UI elements.)
- */
- /* package */ void pokeUserActivity() {
- if (VDBG) Log.d(LOG_TAG, "pokeUserActivity()...");
- mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
- }
-
- /**
- * Notifies the phone app when the phone state changes.
- *
- * This method will updates various states inside Phone app (e.g. update-lock state, etc.)
- */
- /* package */ void updatePhoneState(PhoneConstants.State state) {
- if (state != mLastPhoneState) {
- mLastPhoneState = state;
-
- // Try to acquire or release UpdateLock.
- //
- // Watch out: we don't release the lock here when the screen is still in foreground.
- // At that time InCallScreen will release it on onPause().
- if (state != PhoneConstants.State.IDLE) {
- // UpdateLock is a recursive lock, while we may get "acquire" request twice and
- // "release" request once for a single call (RINGING + OFFHOOK and IDLE).
- // We need to manually ensure the lock is just acquired once for each (and this
- // will prevent other possible buggy situations too).
- if (!mUpdateLock.isHeld()) {
- mUpdateLock.acquire();
- }
- } else {
- if (mUpdateLock.isHeld()) {
- mUpdateLock.release();
- }
- }
- }
- }
-
- /* package */ PhoneConstants.State getPhoneState() {
- return mLastPhoneState;
- }
-
KeyguardManager getKeyguardManager() {
return mKeyguardManager;
}
@@ -829,29 +718,6 @@
}
}
- /**
- * Accepts broadcast Intents which will be prepared by {@link NotificationMgr} and thus
- * sent from framework's notification mechanism (which is outside Phone context).
- * This should be visible from outside, but shouldn't be in "exported" state.
- *
- * TODO: If possible merge this into PhoneAppBroadcastReceiver.
- */
- public static class NotificationBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- // TODO: use "if (VDBG)" here.
- Log.d(LOG_TAG, "Broadcast from Notification: " + action);
-
- if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
- PhoneUtils.hangup(PhoneGlobals.getInstance().mCM);
- } else {
- Log.w(LOG_TAG, "Received hang-up request from notification,"
- + " but there's no call the system can hang up.");
- }
- }
- }
-
private void handleServiceStateChanged(Intent intent) {
/**
* This used to handle updating EriTextWidgetProvider this routine
@@ -871,18 +737,6 @@
}
}
- public boolean isOtaCallInActiveState() {
- boolean otaCallActive = false;
- if (VDBG) Log.d(LOG_TAG, "- isOtaCallInActiveState " + otaCallActive);
- return otaCallActive;
- }
-
- public boolean isOtaCallInEndState() {
- boolean otaCallEnded = false;
- if (VDBG) Log.d(LOG_TAG, "- isOtaCallInEndState " + otaCallEnded);
- return otaCallEnded;
- }
-
// it is safe to call clearOtaState() even if the InCallScreen isn't active
public void clearOtaState() {
if (DBG) Log.d(LOG_TAG, "- clearOtaState ...");
@@ -918,22 +772,4 @@
public void clearMwiIndicator(int subId) {
notificationMgr.updateMwi(subId, false);
}
-
- /**
- * "Call origin" may be used by Contacts app to specify where the phone call comes from.
- * Currently, the only permitted value for this extra is {@link #ALLOWED_EXTRA_CALL_ORIGIN}.
- * Any other value will be ignored, to make sure that malicious apps can't trick the in-call
- * UI into launching some random other app after a call ends.
- *
- * TODO: make this more generic. Note that we should let the "origin" specify its package
- * while we are now assuming it is "com.android.contacts"
- */
- public static final String EXTRA_CALL_ORIGIN = "com.android.phone.CALL_ORIGIN";
- private static final String DEFAULT_CALL_ORIGIN_PACKAGE = "com.android.dialer";
- private static final String ALLOWED_EXTRA_CALL_ORIGIN =
- "com.android.dialer.DialtactsActivity";
- /**
- * Used to determine if the preserved call origin is fresh enough.
- */
- private static final long CALL_ORIGIN_EXPIRATION_MILLIS = 30 * 1000;
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index d59c726..4b22e57 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -1072,14 +1072,6 @@
}
}
- public boolean isSimPinEnabled(String callingPackage) {
- if (!canReadPhoneState(callingPackage, "isSimPinEnabled")) {
- return false;
- }
-
- return (PhoneGlobals.getInstance().isSimPinEnabled());
- }
-
public boolean supplyPin(String pin) {
return supplyPinForSubscriber(getDefaultSubscription(), pin);
}