Merge "Import translations. DO NOT MERGE" into lmp-mr1-dev
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index f026442..0b09792 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -115,7 +115,7 @@
mStatusBarManager =
(StatusBarManager) app.getSystemService(Context.STATUS_BAR_SERVICE);
mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE);
- mPhone = app.phone; // TODO: better style to use mCM.getDefaultPhone() everywhere instead
+ mPhone = app.mCM.getDefaultPhone();
statusBarHelper = new StatusBarHelper();
mSubscriptionManager = SubscriptionManager.from(mContext);
mTelecomManager = TelecomManager.from(mContext);
diff --git a/src/com/android/phone/OtaUtils.java b/src/com/android/phone/OtaUtils.java
index 5f8b2c7..c4b0d19 100644
--- a/src/com/android/phone/OtaUtils.java
+++ b/src/com/android/phone/OtaUtils.java
@@ -228,7 +228,7 @@
*/
public static boolean maybeDoOtaCall(Context context, Handler handler, int request) {
PhoneGlobals app = PhoneGlobals.getInstance();
- Phone phone = app.phone;
+ Phone phone = PhoneGlobals.getPhone();
if (ActivityManager.isRunningInTestHarness()) {
Log.i(LOG_TAG, "Don't run provisioning when in test harness");
diff --git a/src/com/android/phone/OutgoingCallBroadcaster.java b/src/com/android/phone/OutgoingCallBroadcaster.java
index be95103..96e9e7b 100644
--- a/src/com/android/phone/OutgoingCallBroadcaster.java
+++ b/src/com/android/phone/OutgoingCallBroadcaster.java
@@ -41,6 +41,7 @@
import android.view.View;
import android.widget.ProgressBar;
+import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyCapabilities;
@@ -189,13 +190,14 @@
if (VDBG) Log.v(TAG, "- got number from resultData: '" + number + "'");
final PhoneGlobals app = PhoneGlobals.getInstance();
+ final Phone phone = PhoneGlobals.getPhone();
// OTASP-specific checks.
// TODO: This should probably all happen in
// OutgoingCallBroadcaster.onCreate(), since there's no reason to
// even bother with the NEW_OUTGOING_CALL broadcast if we're going
// to disallow the outgoing call anyway...
- if (TelephonyCapabilities.supportsOtasp(app.phone)) {
+ if (TelephonyCapabilities.supportsOtasp(phone)) {
boolean activateState = (app.cdmaOtaScreenState.otaScreenState
== OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION);
boolean dialogState = (app.cdmaOtaScreenState.otaScreenState
@@ -234,9 +236,9 @@
if (number == null) {
if (DBG) Log.v(TAG, "CALL cancelled (null number), returning...");
return false;
- } else if (TelephonyCapabilities.supportsOtasp(app.phone)
- && (app.phone.getState() != PhoneConstants.State.IDLE)
- && (app.phone.isOtaSpNumber(number))) {
+ } else if (TelephonyCapabilities.supportsOtasp(phone)
+ && (phone.getState() != PhoneConstants.State.IDLE)
+ && (phone.isOtaSpNumber(number))) {
if (DBG) Log.v(TAG, "Call is active, a 2nd OTA call cancelled -- returning.");
return false;
} else if (PhoneNumberUtils.isPotentialLocalEmergencyNumber(context, number)) {
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 2fcce90..d13ebfe 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -143,7 +143,6 @@
CallNotifier notifier;
CallerInfoCache callerInfoCache;
NotificationMgr notificationMgr;
- Phone phone;
PhoneInterfaceManager phoneMgr;
private BluetoothManager bluetoothManager;
@@ -262,7 +261,7 @@
break;
case MMI_CANCEL:
- PhoneUtils.cancelMmiCode(phone);
+ PhoneUtils.cancelMmiCode(mCM.getFgPhone());
break;
case EVENT_SIM_STATE_CHANGED:
@@ -328,19 +327,22 @@
// sVoiceCapable =
// getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
- if (phone == null) {
+ if (mCM == null) {
// Initialize the telephony framework
PhoneFactory.makeDefaultPhones(this);
- // Get the default phone
- phone = PhoneFactory.getDefaultPhone();
-
// Start TelephonyDebugService After the default phone is created.
Intent intent = new Intent(this, TelephonyDebugService.class);
startService(intent);
mCM = CallManager.getInstance();
- mCM.registerPhone(phone);
+ boolean hasCdmaPhoneType = false;
+ for (Phone phone : PhoneFactory.getPhones()) {
+ mCM.registerPhone(phone);
+ if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
+ hasCdmaPhoneType = true;
+ }
+ }
// Create the NotificationMgr singleton, which is used to display
// status bar icons and control other status bar behavior.
@@ -348,9 +350,7 @@
mHandler.sendEmptyMessage(EVENT_START_SIP_SERVICE);
- int phoneType = phone.getPhoneType();
-
- if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
+ if (hasCdmaPhoneType) {
// Create an instance of CdmaPhoneCallState and initialize it to IDLE
cdmaPhoneCallState = new CdmaPhoneCallState();
cdmaPhoneCallState.CdmaPhoneCallStateInit();
@@ -397,7 +397,7 @@
// Bluetooth manager
bluetoothManager = new BluetoothManager();
- phoneMgr = PhoneInterfaceManager.init(this, phone);
+ phoneMgr = PhoneInterfaceManager.init(this, PhoneFactory.getDefaultPhone());
// Create the CallNotifer singleton, which handles
// asynchronous events from the telephony layer (like
@@ -405,12 +405,7 @@
// in.)
notifier = CallNotifier.init(this, callLogger, callStateMonitor, bluetoothManager);
- // register for ICC status
- IccCard sim = phone.getIccCard();
- if (sim != null) {
- if (VDBG) Log.v(LOG_TAG, "register for ICC status");
- sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
- }
+ PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
// register for MMI/USSD
mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
@@ -456,9 +451,10 @@
// Read HAC settings and configure audio hardware
if (getResources().getBoolean(R.bool.hac_enabled)) {
- int hac = android.provider.Settings.System.getInt(phone.getContext().getContentResolver(),
- android.provider.Settings.System.HEARING_AID,
- 0);
+ int hac = android.provider.Settings.System.getInt(
+ getContentResolver(),
+ android.provider.Settings.System.HEARING_AID,
+ 0);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setParameter(CallFeaturesSetting.HAC_KEY, hac != 0 ?
CallFeaturesSetting.HAC_VAL_ON :
@@ -485,11 +481,12 @@
}
/**
- * Returns the Phone associated with this instance.
+ * Returns the default phone.
+ *
* WARNING: This method should be used carefully, now that there may be multiple phones.
*/
public static Phone getPhone() {
- return getInstance().phone;
+ return PhoneFactory.getDefaultPhone();
}
public static Phone getPhone(int subId) {
@@ -699,7 +696,7 @@
// the screen to be on.
//
boolean isRinging = (state == PhoneConstants.State.RINGING);
- boolean isDialing = (phone.getForegroundCall().getState() == Call.State.DIALING);
+ boolean isDialing = (mCM.getFgPhone().getForegroundCall().getState() == Call.State.DIALING);
boolean keepScreenOn = isRinging || isDialing;
// keepScreenOn == true means we'll hold a full wake lock:
requestWakeState(keepScreenOn ? WakeState.FULL : WakeState.SLEEP);
@@ -757,13 +754,15 @@
private void onMMIComplete(AsyncResult r) {
if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
MmiCode mmiCode = (MmiCode) r.result;
- PhoneUtils.displayMMIComplete(phone, getInstance(), mmiCode, null, null);
+ PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
}
- private void initForNewRadioTechnology() {
+ private void initForNewRadioTechnology(int phoneId) {
if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
- if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
+ final Phone phone = PhoneFactory.getPhone(phoneId);
+
+ if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
// Create an instance of CdmaPhoneCallState and initialize it to IDLE
cdmaPhoneCallState = new CdmaPhoneCallState();
cdmaPhoneCallState.CdmaPhoneCallStateInit();
@@ -796,19 +795,28 @@
if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
boolean enabled = System.getInt(getContentResolver(),
System.AIRPLANE_MODE_ON, 0) == 0;
- phone.setRadioPower(enabled);
+ PhoneUtils.setRadioPower(enabled);
} else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
- if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED");
- if (VDBG) Log.d(LOG_TAG, "- state: " + intent.getStringExtra(PhoneConstants.STATE_KEY));
- if (VDBG) Log.d(LOG_TAG, "- reason: "
- + intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
-
+ int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ int phoneId = SubscriptionManager.getPhoneId(subId);
+ String state = intent.getStringExtra(PhoneConstants.STATE_KEY);
+ if (VDBG) {
+ Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED");
+ Log.d(LOG_TAG, "- state: " + state);
+ Log.d(LOG_TAG, "- reason: "
+ + intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
+ Log.d(LOG_TAG, "- subId: " + subId);
+ Log.d(LOG_TAG, "- phoneId: " + phoneId);
+ }
+ Phone phone = SubscriptionManager.isValidPhoneId(phoneId) ?
+ PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
// The "data disconnected due to roaming" notification is shown
// if (a) you have the "data roaming" feature turned off, and
// (b) you just lost data connectivity because you're roaming.
boolean disconnectedDueToRoaming =
!phone.getDataRoamingEnabled()
- && "DISCONNECTED".equals(intent.getStringExtra(PhoneConstants.STATE_KEY))
+ && PhoneConstants.DataState.DISCONNECTED.equals(state)
&& Phone.REASON_ROAMING_ON.equals(
intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY));
if (mDataDisconnectedDueToRoaming != disconnectedDueToRoaming) {
@@ -826,12 +834,15 @@
intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)));
} else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
- Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
- initForNewRadioTechnology();
+ int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
+ SubscriptionManager.INVALID_PHONE_INDEX);
+ Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " (" + phoneId
+ + ") is active.");
+ initForNewRadioTechnology(phoneId);
} else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
handleServiceStateChanged(intent);
} else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
- if (TelephonyCapabilities.supportsEcm(phone)) {
+ if (TelephonyCapabilities.supportsEcm(mCM.getFgPhone())) {
Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
// Start Emergency Callback Mode service
if (intent.getBooleanExtra("phoneinECMState", false)) {
@@ -842,7 +853,8 @@
// It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
// on a device that doesn't support ECM in the first place.
Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, "
- + "but ECM isn't supported for phone: " + phone.getPhoneName());
+ + "but ECM isn't supported for phone: "
+ + mCM.getFgPhone().getPhoneName());
}
} else if (action.equals(Intent.ACTION_DOCK_EVENT)) {
mDockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 0c8b62c..502a379 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -51,9 +51,11 @@
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.CallerInfoAsyncQuery;
import com.android.internal.telephony.Connection;
+import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.MmiCode;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.TelephonyCapabilities;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.sip.SipPhone;
@@ -2450,4 +2452,28 @@
String id = isEmergency ? "E" : prefix + String.valueOf(phone.getSubId());
return new PhoneAccountHandle(pstnConnectionServiceName, id);
}
+
+ /**
+ * Register ICC status for all phones.
+ */
+ static final void registerIccStatus(Handler handler, int event) {
+ for (Phone phone : PhoneFactory.getPhones()) {
+ IccCard sim = phone.getIccCard();
+ if (sim != null) {
+ if (VDBG) Log.v(LOG_TAG, "register for ICC status, phone " + phone.getPhoneId());
+ sim.registerForNetworkLocked(handler, event, phone);
+ }
+ }
+ }
+
+ /**
+ * Set the radio power on/off state for all phones.
+ *
+ * @param enabled true means on, false means off.
+ */
+ static final void setRadioPower(boolean enabled) {
+ for (Phone phone : PhoneFactory.getPhones()) {
+ phone.setRadioPower(enabled);
+ }
+ }
}
diff --git a/src/com/android/phone/SpecialCharSequenceMgr.java b/src/com/android/phone/SpecialCharSequenceMgr.java
index c29769f..4e2120e 100644
--- a/src/com/android/phone/SpecialCharSequenceMgr.java
+++ b/src/com/android/phone/SpecialCharSequenceMgr.java
@@ -201,7 +201,8 @@
if ((input.startsWith("**04") || input.startsWith("**05"))
&& input.endsWith("#")) {
PhoneGlobals app = PhoneGlobals.getInstance();
- boolean isMMIHandled = app.phone.handlePinMmi(input);
+ Phone phone = PhoneGlobals.getPhone();
+ boolean isMMIHandled = phone.handlePinMmi(input);
// if the PUK code is recognized then indicate to the
// phone app that an attempt to unPUK the device was