Merge "Disable VT when TTY is enabled during a VOLTE call."
diff --git a/res/drawable/signal_strength_4g.xml b/res/drawable/signal_strength_4g.xml
new file mode 100644
index 0000000..9062096
--- /dev/null
+++ b/res/drawable/signal_strength_4g.xml
@@ -0,0 +1,28 @@
+<!--
+Copyright (C) 2014 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="9.208dp"
+ android:height="17dp"
+ android:viewportWidth="13.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M4.600000,7.800000l0.700000,0.000000l0.000000,1.300000L4.600000,9.100000L4.600000,11.000000L3.000000,11.000000L3.000000,9.200000L0.100000,9.200000L0.000000,8.100000L3.000000,2.500000l1.700000,0.000000L4.700000,7.800000zM1.600000,7.800000L3.000000,7.800000l0.000000,-3.000000L2.900000,5.000000L1.600000,7.800000z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M11.900000,9.900000c-0.200000,0.400000 -0.600000,0.700000 -1.000000,0.900000s-1.000000,0.400000 -1.800000,0.400000c-0.900000,0.000000 -1.700000,-0.300000 -2.200000,-0.800000S6.100000,9.000000 6.100000,7.900000L6.100000,5.600000c0.000000,-1.100000 0.300000,-1.900000 0.800000,-2.400000S8.100000,2.400000 9.000000,2.400000c1.000000,0.000000 1.700000,0.200000 2.100000,0.700000s0.700000,1.200000 0.700000,2.100000l-1.600000,0.000000c0.000000,-0.500000 -0.100000,-0.900000 -0.200000,-1.100000S9.500000,3.700000 9.000000,3.700000c-0.400000,0.000000 -0.700000,0.200000 -0.900000,0.500000S7.700000,5.000000 7.700000,5.600000l0.000000,2.300000c0.000000,0.700000 0.100000,1.100000 0.300000,1.400000s0.600000,0.500000 1.000000,0.500000c0.300000,0.000000 0.600000,0.000000 0.700000,-0.100000s0.300000,-0.200000 0.400000,-0.300000L10.099999,7.800000L9.000000,7.800000L9.000000,6.600000l2.900000,0.000000L11.900000,9.900000z"/>
+</vector>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7773af6..de14389 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1074,8 +1074,8 @@
<!-- Label for the "No service" notification item, when expanded. -->
<string name="notification_network_selection_title">No service</string>
<!-- Label for the expanded "No service" notification item, including the
- operator name set by user -->
- <string name="notification_network_selection_text">Selected network (<xliff:g id="operator_name">%s</xliff:g>) unavailable</string>
+ operator name set by user. No space after "network", appended in nonempty value. -->
+ <string name="notification_network_selection_text">Selected network<xliff:g id="operator_name">%s</xliff:g> unavailable</string>
<!-- In-call screen: call failure message displayed in an error dialog. [CHAR_LIMIT=NONE] -->
<string name="incall_error_power_off" product="watch">Turn on mobile network, turn off airplane mode or turn off battery saver mode to make a call.</string>
diff --git a/src/com/android/phone/CallForwardEditPreference.java b/src/com/android/phone/CallForwardEditPreference.java
index bfeee7a..bdffb26 100644
--- a/src/com/android/phone/CallForwardEditPreference.java
+++ b/src/com/android/phone/CallForwardEditPreference.java
@@ -76,6 +76,11 @@
mReplaceInvalidCFNumber = replaceInvalidCFNumber;
}
+ void restoreCallForwardInfo(CallForwardInfo cf) {
+ handleCallForwardResult(cf);
+ updateSummaryText();
+ }
+
@Override
protected void onBindDialogView(View view) {
// default the button clicked to be the cancel button.
@@ -100,7 +105,15 @@
int action = (isToggled() || (mButtonClicked == DialogInterface.BUTTON_POSITIVE)) ?
CommandsInterface.CF_ACTION_REGISTRATION :
CommandsInterface.CF_ACTION_DISABLE;
- int time = (reason != CommandsInterface.CF_REASON_NO_REPLY) ? 0 : 20;
+ int time = 0;
+ if (reason == CommandsInterface.CF_REASON_NO_REPLY) {
+ PersistableBundle carrierConfig = PhoneGlobals.getInstance()
+ .getCarrierConfigForSubId(mPhone.getSubId());
+ if (carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_SUPPORT_NO_REPLY_TIMER_FOR_CFNRY_BOOL, true)) {
+ time = 20;
+ }
+ }
final String number = getPhoneNumber();
Log.d(LOG_TAG, "callForwardInfo=" + callForwardInfo);
@@ -137,7 +150,7 @@
}
}
- void handleCallForwardResult(CallForwardInfo cf) {
+ private void handleCallForwardResult(CallForwardInfo cf) {
callForwardInfo = cf;
Log.d(LOG_TAG, "handleGetCFResponse done, callForwardInfo=" + callForwardInfo);
// In some cases, the network can send call forwarding URIs for voicemail that violate the
diff --git a/src/com/android/phone/CdmaOptions.java b/src/com/android/phone/CdmaOptions.java
index 70744e5..9c713ef 100644
--- a/src/com/android/phone/CdmaOptions.java
+++ b/src/com/android/phone/CdmaOptions.java
@@ -39,6 +39,7 @@
public class CdmaOptions {
private static final String LOG_TAG = "CdmaOptions";
+ private CarrierConfigManager mCarrierConfigManager;
private CdmaSystemSelectListPreference mButtonCdmaSystemSelect;
private CdmaSubscriptionListPreference mButtonCdmaSubscription;
private RestrictedPreference mButtonAPNExpand;
@@ -59,6 +60,7 @@
mPrefFragment = prefFragment;
mPrefScreen = prefScreen;
mPrefFragment.addPreferencesFromResource(R.xml.cdma_options);
+ mCarrierConfigManager = new CarrierConfigManager(prefFragment.getContext());
// Initialize preferences.
mButtonCdmaSystemSelect = (CdmaSystemSelectListPreference) mPrefScreen
@@ -77,8 +79,7 @@
int phoneType = TelephonyManager.from(mPrefFragment.getContext())
.createForSubscriptionId(mSubId).getPhoneType();
- PersistableBundle carrierConfig =
- PhoneGlobals.getInstance().getCarrierConfigForSubId(mSubId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
// Some CDMA carriers want the APN settings.
boolean addAPNExpand = shouldAddApnExpandPreference(phoneType, carrierConfig);
boolean addCdmaSubscription =
diff --git a/src/com/android/phone/GsmUmtsCallForwardOptions.java b/src/com/android/phone/GsmUmtsCallForwardOptions.java
index e562e46..6d80621 100644
--- a/src/com/android/phone/GsmUmtsCallForwardOptions.java
+++ b/src/com/android/phone/GsmUmtsCallForwardOptions.java
@@ -31,6 +31,7 @@
private static final String KEY_TOGGLE = "toggle";
private static final String KEY_STATUS = "status";
private static final String KEY_NUMBER = "number";
+ private static final String KEY_ENABLE = "enable";
private CallForwardEditPreference mButtonCFU;
private CallForwardEditPreference mButtonCFB;
@@ -112,11 +113,12 @@
for (CallForwardEditPreference pref : mPreferences) {
Bundle bundle = mIcicle.getParcelable(pref.getKey());
pref.setToggled(bundle.getBoolean(KEY_TOGGLE));
+ pref.setEnabled(bundle.getBoolean(KEY_ENABLE));
CallForwardInfo cf = new CallForwardInfo();
cf.number = bundle.getString(KEY_NUMBER);
cf.status = bundle.getInt(KEY_STATUS);
pref.init(this, mPhone, mReplaceInvalidCFNumbers);
- pref.handleCallForwardResult(cf);
+ pref.restoreCallForwardInfo(cf);
}
}
mFirstResume = false;
@@ -131,6 +133,7 @@
for (CallForwardEditPreference pref : mPreferences) {
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_TOGGLE, pref.isToggled());
+ bundle.putBoolean(KEY_ENABLE, pref.isEnabled());
if (pref.callForwardInfo != null) {
bundle.putString(KEY_NUMBER, pref.callForwardInfo.number);
bundle.putInt(KEY_STATUS, pref.callForwardInfo.status);
diff --git a/src/com/android/phone/GsmUmtsOptions.java b/src/com/android/phone/GsmUmtsOptions.java
index 19cd3ef..a3f5cfb 100644
--- a/src/com/android/phone/GsmUmtsOptions.java
+++ b/src/com/android/phone/GsmUmtsOptions.java
@@ -16,6 +16,7 @@
package com.android.phone;
+import android.content.Context;
import android.content.Intent;
import android.os.PersistableBundle;
import android.preference.Preference;
@@ -23,6 +24,7 @@
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
+import android.telephony.TelephonyManager;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -36,6 +38,7 @@
public class GsmUmtsOptions {
private static final String LOG_TAG = "GsmUmtsOptions";
+ private CarrierConfigManager mCarrierConfigManager;
private RestrictedPreference mButtonAPNExpand;
private Preference mCategoryAPNExpand;
Preference mCarrierSettingPref;
@@ -52,8 +55,10 @@
public GsmUmtsOptions(PreferenceFragment prefFragment, PreferenceScreen prefScreen,
final int subId, INetworkQueryService queryService) {
+ final Context context = prefFragment.getContext();
mPrefFragment = prefFragment;
mPrefScreen = prefScreen;
+ mCarrierConfigManager = new CarrierConfigManager(context);
mPrefFragment.addPreferencesFromResource(R.xml.gsm_umts_options);
mButtonAPNExpand = (RestrictedPreference) mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY);
mCategoryAPNExpand = mPrefScreen.findPreference(CATEGORY_APN_EXPAND_KEY);
@@ -72,16 +77,17 @@
boolean addAPNExpand = true;
boolean addNetworkOperatorsCategory = true;
boolean addCarrierSettings = true;
+ final TelephonyManager telephonyManager = TelephonyManager.from(mPrefFragment.getContext())
+ .createForSubscriptionId(subId);
Phone phone = PhoneGlobals.getPhone(subId);
if (phone == null) return;
- if (phone.getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
+ if (telephonyManager.getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
log("Not a GSM phone");
addAPNExpand = false;
mNetworkOperator.setEnabled(false);
} else {
log("Not a CDMA phone");
- PersistableBundle carrierConfig =
- PhoneGlobals.getInstance().getCarrierConfigForSubId(subId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
// Determine which options to display. For GSM these are defaulted to true in
// CarrierConfigManager, but they maybe overriden by DefaultCarrierConfigService or a
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 7a795ed..c4f91ca 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -239,15 +239,16 @@
* doesn't set {@link CarrierConfigManager#KEY_HIDE_ENHANCED_4G_LTE_BOOL} to false.
*/
public static boolean hideEnhanced4gLteSettings(Context context) {
- List<SubscriptionInfo> sil =
+ final CarrierConfigManager carrierConfigManager = new CarrierConfigManager(context);
+ final List<SubscriptionInfo> sil =
SubscriptionManager.from(context).getActiveSubscriptionInfoList();
// Check all active subscriptions. We only hide the button if it's disabled for all
// active subscriptions.
if (sil != null) {
for (SubscriptionInfo subInfo : sil) {
ImsManager imsManager = ImsManager.getInstance(context, subInfo.getSimSlotIndex());
- PersistableBundle carrierConfig = PhoneGlobals.getInstance()
- .getCarrierConfigForSubId(subInfo.getSubscriptionId());
+ PersistableBundle carrierConfig = carrierConfigManager.getConfigForSubId(
+ subInfo.getSubscriptionId());
if ((imsManager.isVolteEnabledByPlatform()
&& imsManager.isVolteProvisionedOnDevice())
|| carrierConfig.getBoolean(
@@ -347,6 +348,7 @@
private SubscriptionManager mSubscriptionManager;
private TelephonyManager mTelephonyManager;
+ private CarrierConfigManager mCarrierConfigManager;
private int mSubId;
//UI objects
@@ -788,6 +790,7 @@
mSubscriptionManager = SubscriptionManager.from(activity);
mTelephonyManager = (TelephonyManager) activity.getSystemService(
Context.TELEPHONY_SERVICE);
+ mCarrierConfigManager = new CarrierConfigManager(getContext());
if (icicle != null) {
mExpandAdvancedFields = icicle.getBoolean(EXPAND_ADVANCED_FIELDS, false);
@@ -1052,8 +1055,7 @@
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
preferredNetworkMode);
- PersistableBundle carrierConfig =
- PhoneGlobals.getInstance().getCarrierConfigForSubId(mSubId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
mIsGlobalCdma = isLteOnCdma
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
if (carrierConfig.getBoolean(
@@ -1200,8 +1202,7 @@
// Requires that mSubId is up to date
void updateEnabledNetworksEntries() {
final int phoneType = mTelephonyManager.getPhoneType();
- final PersistableBundle carrierConfig =
- PhoneGlobals.getInstance().getCarrierConfigForSubId(mSubId);
+ final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
final int lteForced = android.provider.Settings.Global.getInt(
getContext().getContentResolver(),
@@ -1444,8 +1445,8 @@
//normally called on the toggle click
if (!mButtonDataRoam.isChecked()) {
- PersistableBundle carrierConfig =
- PhoneGlobals.getInstance().getCarrierConfigForSubId(mSubId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(
+ mSubId);
if (carrierConfig != null && carrierConfig.getBoolean(
CarrierConfigManager.KEY_DISABLE_CHARGE_INDICATION_BOOL)) {
mTelephonyManager.setDataRoamingEnabled(true);
@@ -1885,8 +1886,7 @@
return;
}
- PersistableBundle carrierConfig = PhoneGlobals.getInstance()
- .getCarrierConfigForSubId(mSubId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
if ((mImsMgr == null
|| !mImsMgr.isVolteEnabledByPlatform()
@@ -1909,8 +1909,7 @@
return;
}
- PersistableBundle carrierConfig = PhoneGlobals.getInstance()
- .getCarrierConfigForSubId(mSubId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
if (mImsMgr != null
&& mImsMgr.isVtEnabledByPlatform()
diff --git a/src/com/android/phone/NetworkOperatorPreference.java b/src/com/android/phone/NetworkOperatorPreference.java
index e582924..09c494c 100644
--- a/src/com/android/phone/NetworkOperatorPreference.java
+++ b/src/com/android/phone/NetworkOperatorPreference.java
@@ -43,16 +43,18 @@
private CellInfo mCellInfo;
private List<String> mForbiddenPlmns;
private int mLevel = -1;
+ private boolean mShow4GForLTE;
// The following constants are used to draw signal icon.
private static final Drawable EMPTY_DRAWABLE = new ColorDrawable(Color.TRANSPARENT);
private static final int NO_CELL_DATA_CONNECTED_ICON = 0;
public NetworkOperatorPreference(
- CellInfo cellinfo, Context context, List<String> forbiddenPlmns) {
+ CellInfo cellinfo, Context context, List<String> forbiddenPlmns, boolean show4GForLTE) {
super(context);
mCellInfo = cellinfo;
mForbiddenPlmns = forbiddenPlmns;
+ mShow4GForLTE = show4GForLTE;
refresh();
}
@@ -85,13 +87,15 @@
updateIcon(level);
}
- private static int getIconIdForCell(CellInfo ci) {
+ private int getIconIdForCell(CellInfo ci) {
final int type = ci.getCellIdentity().getType();
switch (type) {
case CellInfo.TYPE_GSM: return R.drawable.signal_strength_g;
case CellInfo.TYPE_WCDMA: // fall through
case CellInfo.TYPE_TDSCDMA: return R.drawable.signal_strength_3g;
- case CellInfo.TYPE_LTE: return R.drawable.signal_strength_lte;
+ case CellInfo.TYPE_LTE:
+ return mShow4GForLTE
+ ? R.drawable.signal_strength_4g : R.drawable.signal_strength_lte;
case CellInfo.TYPE_CDMA: return R.drawable.signal_strength_1x;
default: return 0;
}
diff --git a/src/com/android/phone/NetworkOperators.java b/src/com/android/phone/NetworkOperators.java
index 6d8b30f..6d798b0 100644
--- a/src/com/android/phone/NetworkOperators.java
+++ b/src/com/android/phone/NetworkOperators.java
@@ -29,6 +29,7 @@
import android.telephony.TelephonyManager;
import android.util.AttributeSet;
import android.util.Log;
+import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -193,25 +194,12 @@
// Used by both mAutoSelect and mNetworkSelect buttons.
protected void displayNetworkSelectionFailed() {
- String status = getContext().getResources().getString(R.string.connect_later);
-
- final PhoneGlobals app = PhoneGlobals.getInstance();
- app.notificationMgr.postTransientNotification(
- NotificationMgr.NETWORK_SELECTION_NOTIFICATION, status);
-
- ServiceState ss = mTelephonyManager.getServiceStateForSubscriber(mSubId);
- if (ss != null) {
- app.notificationMgr.updateNetworkSelection(ss.getState(), mSubId);
- }
+ Toast.makeText(getContext(), R.string.connect_later, Toast.LENGTH_LONG).show();
}
// Used by both mAutoSelect and mNetworkSelect buttons.
protected void displayNetworkSelectionSucceeded() {
- String status = getContext().getResources().getString(R.string.registration_done);
-
- final PhoneGlobals app = PhoneGlobals.getInstance();
- app.notificationMgr.postTransientNotification(
- NotificationMgr.NETWORK_SELECTION_NOTIFICATION, status);
+ Toast.makeText(getContext(), R.string.registration_done, Toast.LENGTH_LONG).show();
}
private void selectNetworkAutomatic(boolean autoSelect) {
diff --git a/src/com/android/phone/NetworkSelectListPreference.java b/src/com/android/phone/NetworkSelectListPreference.java
index cec914a..5b841c9 100644
--- a/src/com/android/phone/NetworkSelectListPreference.java
+++ b/src/com/android/phone/NetworkSelectListPreference.java
@@ -403,8 +403,7 @@
final OperatorInfo operatorInfo = getOperatorInfoFromCellInfo(mCellInfo);
if (DBG) logd("manually selected network: " + operatorInfo.toString());
boolean isSuccessed = mTelephonyManager.setNetworkSelectionModeManual(
- operatorInfo.getOperatorNumeric(), true /* persistSelection */);
- int mode = mTelephonyManager.getNetworkSelectionMode();
+ operatorInfo, true /* persistSelection */);
Message msg = mHandler.obtainMessage(EVENT_MANUALLY_NETWORK_SELECTION_DONE);
msg.obj = isSuccessed;
msg.sendToTarget();
diff --git a/src/com/android/phone/NetworkSelectSetting.java b/src/com/android/phone/NetworkSelectSetting.java
index 56f0187..c8a29ce 100644
--- a/src/com/android/phone/NetworkSelectSetting.java
+++ b/src/com/android/phone/NetworkSelectSetting.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -84,6 +85,7 @@
private NetworkOperatorPreference mSelectedNetworkOperatorPreference;
private TelephonyManager mTelephonyManager;
private List<String> mForbiddenPlmns;
+ private boolean mShow4GForLTE;
private final Runnable mUpdateNetworkOperatorsRunnable = () -> {
updateNetworkOperatorsPreferenceCategory();
@@ -116,6 +118,15 @@
mStatusMessagePreference = new Preference(getContext());
mSelectedNetworkOperatorPreference = null;
mTelephonyManager = TelephonyManager.from(getContext()).createForSubscriptionId(mSubId);
+ try {
+ Context con = getActivity().createPackageContext("com.android.systemui", 0);
+ int id = con.getResources().getIdentifier("config_show4GForLTE",
+ "bool", "com.android.systemui");
+ mShow4GForLTE = con.getResources().getBoolean(id);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "NameNotFoundException for show4GFotLTE");
+ mShow4GForLTE = false;
+ }
setRetainInstance(true);
}
@@ -217,7 +228,7 @@
ThreadUtils.postOnBackgroundThread(() -> {
Message msg = mHandler.obtainMessage(EVENT_SET_NETWORK_SELECTION_MANUALLY_DONE);
msg.obj = mTelephonyManager.setNetworkSelectionModeManual(
- operatorInfo.getOperatorNumeric(), true /* persistSelection */);
+ operatorInfo, true /* persistSelection */);
msg.sendToTarget();
});
@@ -268,7 +279,6 @@
mSelectedNetworkOperatorPreference.setSummary(R.string.network_connected);
} else {
if (DBG) logd("manual network selection: failed! ");
- updateNetworkSelection();
// Set summary as "Couldn't connect" to the selected network.
mSelectedNetworkOperatorPreference.setSummary(
R.string.network_could_not_connect);
@@ -393,7 +403,7 @@
for (int index = 0; index < mCellInfoList.size(); index++) {
if (!mCellInfoList.get(index).isRegistered()) {
NetworkOperatorPreference pref = new NetworkOperatorPreference(
- mCellInfoList.get(index), getContext(), mForbiddenPlmns);
+ mCellInfoList.get(index), getContext(), mForbiddenPlmns, mShow4GForLTE);
pref.setKey(CellInfoUtil.getNetworkTitle(mCellInfoList.get(index)));
pref.setOrder(index);
mNetworkOperatorsPreferences.addPreference(pref);
@@ -431,8 +441,8 @@
CellInfo cellInfo = CellInfoUtil.wrapCellInfoWithCellIdentity(cellIdentity);
if (cellInfo != null) {
if (DBG) logd("Currently registered cell: " + cellInfo.toString());
- NetworkOperatorPreference pref =
- new NetworkOperatorPreference(cellInfo, getContext(), mForbiddenPlmns);
+ NetworkOperatorPreference pref = new NetworkOperatorPreference(
+ cellInfo, getContext(), mForbiddenPlmns, mShow4GForLTE);
pref.setTitle(mTelephonyManager.getNetworkOperatorName());
pref.setSummary(R.string.network_connected);
// Update the signal strength icon, since the default signalStrength value would be
@@ -512,8 +522,8 @@
if (DBG) logd("addConnectedNetworkOperatorPreference");
// Remove the current ConnectedNetworkOperatorsPreference
removeConnectedNetworkOperatorPreference();
- final NetworkOperatorPreference pref =
- new NetworkOperatorPreference(cellInfo, getContext(), mForbiddenPlmns);
+ final NetworkOperatorPreference pref = new NetworkOperatorPreference(
+ cellInfo, getContext(), mForbiddenPlmns, mShow4GForLTE);
pref.setSummary(R.string.network_connected);
mConnectedNetworkOperatorsPreference.addPreference(pref);
PreferenceScreen preferenceScreen = getPreferenceScreen();
@@ -617,21 +627,6 @@
}
}
- /**
- * Call {@link NotificationMgr#updateNetworkSelection(int, int)} to send notification about
- * no service of user selected operator
- */
- private void updateNetworkSelection() {
- if (DBG) logd("Update notification about no service of user selected operator");
- final PhoneGlobals app = PhoneGlobals.getInstance();
- if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
- ServiceState ss = mTelephonyManager.getServiceState();
- if (ss != null) {
- app.notificationMgr.updateNetworkSelection(ss.getState(), mSubId);
- }
- }
- }
-
private void stopNetworkQuery() {
// Stop the network query process
try {
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 1b2d49e..5aa87d0 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -569,6 +569,9 @@
private void showNetworkSelection(String operator, int subId) {
if (DBG) log("showNetworkSelection(" + operator + ")...");
+ if (!TextUtils.isEmpty(operator)) {
+ operator = String.format(" (%s)", operator);
+ }
Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(android.R.drawable.stat_sys_warning)
.setContentTitle(mContext.getString(R.string.notification_network_selection_title))
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index b1e061f..67ec932 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -41,6 +41,7 @@
import android.os.UserManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
+import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
@@ -665,7 +666,9 @@
if (isAirplaneNewlyOn) {
// If we are trying to turn off the radio, make sure there are no active
// emergency calls. If there are, switch airplane mode back to off.
- if (PhoneUtils.isInEmergencyCall(mCM)) {
+ TelecomManager tm = (TelecomManager) context.getSystemService(TELECOM_SERVICE);
+
+ if (tm != null && tm.isInEmergencyCall()) {
// Switch airplane mode back to off.
ConnectivityManager.from(this).setAirplaneMode(false);
Toast.makeText(this, R.string.radio_off_during_emergency_call, Toast.LENGTH_LONG)
@@ -862,6 +865,20 @@
}
/**
+ * Called when the network selection on the subscription {@code subId} is changed by the user.
+ *
+ * @param subId the subscription id.
+ */
+ public void onNetworkSelectionChanged(int subId) {
+ Phone phone = getPhone(subId);
+ if (phone != null) {
+ notificationMgr.updateNetworkSelection(phone.getServiceState().getState(), subId);
+ } else {
+ Log.w(LOG_TAG, "onNetworkSelectionChanged on null phone, subId: " + subId);
+ }
+ }
+
+ /**
* Dismisses the message waiting (voicemail) indicator.
*
* @param subId the subscription id we should dismiss the notification for.
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 0cb4a56..353f4b5 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -57,6 +57,7 @@
import android.telephony.CellInfo;
import android.telephony.CellInfoGsm;
import android.telephony.CellInfoWcdma;
+import android.telephony.CellLocation;
import android.telephony.ClientRequestStats;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.LocationAccessPolicy;
@@ -75,6 +76,8 @@
import android.telephony.UiccSlotInfo;
import android.telephony.UssdResponse;
import android.telephony.VisualVoicemailSmsFilterSettings;
+import android.telephony.cdma.CdmaCellLocation;
+import android.telephony.gsm.GsmCellLocation;
import android.telephony.ims.aidl.IImsConfig;
import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsRcsFeature;
@@ -82,7 +85,6 @@
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.text.TextUtils;
import android.util.ArraySet;
-import android.util.EventLog;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -148,8 +150,6 @@
// Message codes used with mMainThreadHandler
private static final int CMD_HANDLE_PIN_MMI = 1;
- private static final int CMD_ANSWER_RINGING_CALL = 4;
- private static final int CMD_END_CALL = 5; // not used yet
private static final int CMD_TRANSMIT_APDU_LOGICAL_CHANNEL = 7;
private static final int EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE = 8;
private static final int CMD_OPEN_CHANNEL = 9;
@@ -203,6 +203,10 @@
private static final int EVENT_SET_CDMA_ROAMING_MODE_DONE = 57;
private static final int CMD_SET_CDMA_SUBSCRIPTION_MODE = 58;
private static final int EVENT_SET_CDMA_SUBSCRIPTION_MODE_DONE = 59;
+ private static final int CMD_GET_ALL_CELL_INFO = 60;
+ private static final int EVENT_GET_ALL_CELL_INFO_DONE = 61;
+ private static final int CMD_GET_CELL_LOCATION = 62;
+ private static final int EVENT_GET_CELL_LOCATION_DONE = 63;
// Parameters of select command.
private static final int SELECT_COMMAND = 0xA4;
@@ -376,41 +380,6 @@
break;
}
- case CMD_ANSWER_RINGING_CALL:
- request = (MainThreadRequest) msg.obj;
- int answer_subId = request.subId;
- answerRingingCallInternal(answer_subId);
- request.result = ""; // dummy result for notifying the waiting thread
- // Wake up the requesting thread
- notifyRequester(request);
- break;
-
- case CMD_END_CALL:
- request = (MainThreadRequest) msg.obj;
- int end_subId = request.subId;
- final boolean hungUp;
- Phone phone = getPhone(end_subId);
- if (phone == null) {
- if (DBG) log("CMD_END_CALL: no phone for id: " + end_subId);
- break;
- }
- int phoneType = phone.getPhoneType();
- if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
- // CDMA: If the user presses the Power button we treat it as
- // ending the complete call session
- hungUp = PhoneUtils.hangupRingingAndActive(getPhone(end_subId));
- } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
- // GSM: End the call as per the Phone state
- hungUp = PhoneUtils.hangup(mCM);
- } else {
- throw new IllegalStateException("Unexpected phone type: " + phoneType);
- }
- if (DBG) log("CMD_END_CALL: " + (hungUp ? "hung up!" : "no call to hang up"));
- request.result = hungUp;
- // Wake up the requesting thread
- notifyRequester(request);
- break;
-
case CMD_TRANSMIT_APDU_LOGICAL_CHANNEL:
request = (MainThreadRequest) msg.obj;
iccArgument = (IccAPDUArgument) request.argument;
@@ -795,7 +764,16 @@
break;
case EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE:
- handleNullReturnEvent(msg, "setNetworkSelectionModeManual");
+ ar = (AsyncResult) msg.obj;
+ request = (MainThreadRequest) ar.userObj;
+ if (ar.exception == null) {
+ request.result = true;
+ } else {
+ request.result = false;
+ loge("setNetworkSelectionModeManual " + ar.exception);
+ }
+ notifyRequester(request);
+ mApp.onNetworkSelectionChanged(request.subId);
break;
case CMD_GET_MODEM_ACTIVITY_INFO:
@@ -1002,6 +980,47 @@
notifyRequester(request);
break;
+ case CMD_GET_ALL_CELL_INFO:
+ request = (MainThreadRequest) msg.obj;
+ Pair<Phone, WorkSource> args = (Pair<Phone, WorkSource>) request.argument;
+ onCompleted = obtainMessage(EVENT_GET_ALL_CELL_INFO_DONE, request);
+ ((Phone) args.first).getAllCellInfo(args.second, onCompleted);
+ break;
+
+ case EVENT_GET_ALL_CELL_INFO_DONE:
+ ar = (AsyncResult) msg.obj;
+ request = (MainThreadRequest) ar.userObj;
+ request.result = (ar.exception == null) ? ar.result : new ArrayList<CellInfo>();
+ synchronized (request) {
+ request.notifyAll();
+ }
+ break;
+
+ case CMD_GET_CELL_LOCATION: {
+ request = (MainThreadRequest) msg.obj;
+ WorkSource ws = (WorkSource) request.argument;
+ Phone phone = getPhoneFromRequest(request);
+ phone.getCellLocation(ws, obtainMessage(EVENT_GET_CELL_LOCATION_DONE, request));
+ break;
+ }
+
+ case EVENT_GET_CELL_LOCATION_DONE: {
+ ar = (AsyncResult) msg.obj;
+ request = (MainThreadRequest) ar.userObj;
+ if (ar.exception == null) {
+ request.result = ar.result;
+ } else {
+ Phone phone = getPhoneFromRequest(request);
+ request.result = (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)
+ ? new CdmaCellLocation() : new GsmCellLocation();
+ }
+
+ synchronized (request) {
+ request.notifyAll();
+ }
+ break;
+ }
+
default:
Log.w(LOG_TAG, "MainThreadHandler: unexpected message code: " + msg.what);
break;
@@ -1159,9 +1178,6 @@
private Phone getPhone(int subId) {
return PhoneFactory.getPhone(mSubscriptionController.getPhoneId(subId));
}
- //
- // Implementation of the ITelephony interface.
- //
public void dial(String number) {
dialForSubscriber(getPreferredVoiceSubscription(), number);
@@ -1244,7 +1260,7 @@
* @return true is a call was ended
*/
public boolean endCall() {
- return endCallForSubscriber(getDefaultSubscription());
+ return false;
}
/**
@@ -1252,75 +1268,15 @@
* @return true is a call was ended
*/
public boolean endCallForSubscriber(int subId) {
- if (mApp.checkCallingOrSelfPermission(permission.MODIFY_PHONE_STATE)
- != PackageManager.PERMISSION_GRANTED) {
- Log.i(LOG_TAG, "endCall: called without modify phone state.");
- EventLog.writeEvent(0x534e4554, "67862398", -1, "");
- throw new SecurityException("MODIFY_PHONE_STATE permission required.");
- }
- final long identity = Binder.clearCallingIdentity();
- try {
- return (Boolean) sendRequest(CMD_END_CALL, null, new Integer(subId));
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
+ return false;
}
public void answerRingingCall() {
- answerRingingCallForSubscriber(getDefaultSubscription());
+ // Deprecated.
}
public void answerRingingCallForSubscriber(int subId) {
- if (DBG) log("answerRingingCall...");
- // TODO: there should eventually be a separate "ANSWER_PHONE" permission,
- // but that can probably wait till the big TelephonyManager API overhaul.
- // For now, protect this call with the MODIFY_PHONE_STATE permission.
- enforceModifyPermission();
-
- final long identity = Binder.clearCallingIdentity();
- try {
- sendRequest(CMD_ANSWER_RINGING_CALL, null, new Integer(subId));
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- }
-
- /**
- * Make the actual telephony calls to implement answerRingingCall().
- * This should only be called from the main thread of the Phone app.
- * @see #answerRingingCall
- *
- * TODO: it would be nice to return true if we answered the call, or
- * false if there wasn't actually a ringing incoming call, or some
- * other error occurred. (In other words, pass back the return value
- * from PhoneUtils.answerCall() or PhoneUtils.answerAndEndActive().)
- * But that would require calling this method via sendRequest() rather
- * than sendRequestAsync(), and right now we don't actually *need* that
- * return value, so let's just return void for now.
- */
- private void answerRingingCallInternal(int subId) {
- final boolean hasRingingCall = !getPhone(subId).getRingingCall().isIdle();
- if (hasRingingCall) {
- final boolean hasActiveCall = !getPhone(subId).getForegroundCall().isIdle();
- final boolean hasHoldingCall = !getPhone(subId).getBackgroundCall().isIdle();
- if (hasActiveCall && hasHoldingCall) {
- // Both lines are in use!
- // TODO: provide a flag to let the caller specify what
- // policy to use if both lines are in use. (The current
- // behavior is hardwired to "answer incoming, end ongoing",
- // which is how the CALL button is specced to behave.)
- PhoneUtils.answerAndEndActive(mCM, mCM.getFirstActiveRingingCall());
- return;
- } else {
- // answerCall() will automatically hold the current active
- // call, if there is one.
- PhoneUtils.answerCall(mCM.getFirstActiveRingingCall());
- return;
- }
- } else {
- // No call was ringing.
- return;
- }
+ // Deprecated
}
/**
@@ -1875,12 +1831,9 @@
try {
if (DBG_LOC) log("getCellLocation: is active user");
Bundle data = new Bundle();
- Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId());
- if (phone == null) {
- return null;
- }
-
- phone.getCellLocation(workSource).fillInNotifierBundle(data);
+ int subId = mSubscriptionController.getDefaultDataSubId();
+ CellLocation cl = (CellLocation) sendRequest(CMD_GET_CELL_LOCATION, workSource, subId);
+ cl.fillInNotifierBundle(data);
return data;
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2004,7 +1957,9 @@
try {
List<CellInfo> cellInfos = new ArrayList<CellInfo>();
for (Phone phone : PhoneFactory.getPhones()) {
- final List<CellInfo> info = phone.getAllCellInfo(workSource);
+ final List<CellInfo> info = (List<CellInfo>) sendRequest(
+ CMD_GET_ALL_CELL_INFO,
+ new Pair<Phone, WorkSource>(phone, workSource));
if (info != null) cellInfos.addAll(info);
}
return cellInfos;
@@ -2635,6 +2590,10 @@
@Override
public int getNetworkSelectionMode(int subId) {
+ if (!isActiveSubscription(subId)) {
+ return TelephonyManager.NETWORK_SELECTION_MODE_UNKNOWN;
+ }
+
return (int) sendRequest(CMD_GET_NETWORK_SELECTION_MODE, null /* argument */, subId);
}
@@ -2796,6 +2755,10 @@
return mSubscriptionController.getDefaultVoiceSubId();
}
+ private boolean isActiveSubscription(int subId) {
+ return mSubscriptionController.isActiveSubId(subId);
+ }
+
/**
* @see android.telephony.TelephonyManager.WifiCallingChoices
*/
@@ -3336,6 +3299,10 @@
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "setNetworkSelectionModeAutomatic");
+ if (!isActiveSubscription(subId)) {
+ return;
+ }
+
final long identity = Binder.clearCallingIdentity();
try {
if (DBG) log("setNetworkSelectionModeAutomatic: subId " + subId);
@@ -3345,24 +3312,35 @@
}
}
- /**
- * Set the network selection mode to manual with the selected carrier.
+ /**
+ * Ask the radio to connect to the input network and change selection mode to manual.
+ *
+ * @param subId the id of the subscription.
+ * @param operatorInfo the operator information, included the PLMN, long name and short name of
+ * the operator to attach to.
+ * @param persistSelection whether the selection will persist until reboot. If true, only allows
+ * attaching to the selected PLMN until reboot; otherwise, attach to the chosen PLMN and resume
+ * normal network selection next time.
+ * @return {@code true} on success; {@code true} on any failure.
*/
@Override
- public boolean setNetworkSelectionModeManual(int subId, String operatorNumeric,
- boolean persistSelection) {
+ public boolean setNetworkSelectionModeManual(
+ int subId, OperatorInfo operatorInfo, boolean persistSelection) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "setNetworkSelectionModeManual");
+ if (!isActiveSubscription(subId)) {
+ return false;
+ }
+
final long identity = Binder.clearCallingIdentity();
try {
- OperatorInfo operator = new OperatorInfo(
- /* operatorAlphaLong */ "",
- /* operatorAlphaShort */ "",
- operatorNumeric);
- if (DBG) log("setNetworkSelectionModeManual: subId:" + subId + " operator:" + operator);
- ManualNetworkSelectionArgument arg = new ManualNetworkSelectionArgument(operator,
+ ManualNetworkSelectionArgument arg = new ManualNetworkSelectionArgument(operatorInfo,
persistSelection);
+ if (DBG) {
+ log("setNetworkSelectionModeManual: subId: " + subId
+ + " operator: " + operatorInfo);
+ }
return (Boolean) sendRequest(CMD_SET_NETWORK_SELECTION_MODE_MANUAL, arg, subId);
} finally {
Binder.restoreCallingIdentity(identity);
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 712b8cb..9ede914 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -19,7 +19,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
-import android.bluetooth.IBluetoothHeadsetPhone;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -30,7 +29,6 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
-import android.os.RemoteException;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.VideoProfile;
@@ -106,9 +104,6 @@
/** Phone state changed event*/
private static final int PHONE_STATE_CHANGED = -1;
- /** check status then decide whether answerCall */
- private static final int MSG_CHECK_STATUS_ANSWERCALL = 100;
-
/** poll phone DISCONNECTING status interval */
private static final int DISCONNECTING_POLLING_INTERVAL_MS = 200;
@@ -125,15 +120,6 @@
*/
private static final int THEME = com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert;
- private static class FgRingCalls {
- private Call fgCall;
- private Call ringing;
- public FgRingCalls(Call fg, Call ring) {
- fgCall = fg;
- ringing = ring;
- }
- }
-
/** USSD information used to aggregate all USSD messages */
private static AlertDialog sUssdDialog = null;
private static StringBuilder sUssdMsg = new StringBuilder();
@@ -147,34 +133,6 @@
* Mute settings for each connection as needed.
*/
private static class ConnectionHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_CHECK_STATUS_ANSWERCALL:
- FgRingCalls frC = (FgRingCalls) msg.obj;
- // wait for finishing disconnecting
- // before check the ringing call state
- if ((frC.fgCall != null) &&
- (frC.fgCall.getState() == Call.State.DISCONNECTING) &&
- (msg.arg1 < DISCONNECTING_POLLING_TIMES_LIMIT)) {
- Message retryMsg =
- mConnectionHandler.obtainMessage(MSG_CHECK_STATUS_ANSWERCALL);
- retryMsg.arg1 = 1 + msg.arg1;
- retryMsg.obj = msg.obj;
- mConnectionHandler.sendMessageDelayed(retryMsg,
- DISCONNECTING_POLLING_INTERVAL_MS);
- // since hangupActiveCall() also accepts the ringing call
- // check if the ringing call was already answered or not
- // only answer it when the call still is ringing
- } else if (frC.ringing.isRinging()) {
- if (msg.arg1 == DISCONNECTING_POLLING_TIMES_LIMIT) {
- Log.e(LOG_TAG, "DISCONNECTING time out");
- }
- answerCall(frC.ringing);
- }
- break;
- }
- }
}
/**
@@ -195,294 +153,6 @@
}
/**
- * Answer the currently-ringing call.
- *
- * @return true if we answered the call, or false if there wasn't
- * actually a ringing incoming call, or some other error occurred.
- *
- * @see #answerAndEndHolding(CallManager, Call)
- * @see #answerAndEndActive(CallManager, Call)
- */
- /* package */ static boolean answerCall(Call ringingCall) {
- log("answerCall(" + ringingCall + ")...");
- final PhoneGlobals app = PhoneGlobals.getInstance();
- final CallNotifier notifier = app.notifier;
-
- final Phone phone = ringingCall.getPhone();
- final boolean phoneIsCdma = (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA);
- boolean answered = false;
- IBluetoothHeadsetPhone btPhone = null;
-
- if (phoneIsCdma) {
- // Stop any signalInfo tone being played when a Call waiting gets answered
- if (ringingCall.getState() == Call.State.WAITING) {
- notifier.stopSignalInfoTone();
- }
- }
-
- if (ringingCall != null && ringingCall.isRinging()) {
- if (DBG) log("answerCall: call state = " + ringingCall.getState());
- try {
- if (phoneIsCdma) {
- if (app.cdmaPhoneCallState.getCurrentCallState()
- == CdmaPhoneCallState.PhoneCallState.IDLE) {
- // This is the FIRST incoming call being answered.
- // Set the Phone Call State to SINGLE_ACTIVE
- app.cdmaPhoneCallState.setCurrentCallState(
- CdmaPhoneCallState.PhoneCallState.SINGLE_ACTIVE);
- } else {
- // This is the CALL WAITING call being answered.
- // Set the Phone Call State to CONF_CALL
- app.cdmaPhoneCallState.setCurrentCallState(
- CdmaPhoneCallState.PhoneCallState.CONF_CALL);
- // Enable "Add Call" option after answering a Call Waiting as the user
- // should be allowed to add another call in case one of the parties
- // drops off
- app.cdmaPhoneCallState.setAddCallMenuStateAfterCallWaiting(true);
- }
- }
-
- final boolean isRealIncomingCall = isRealIncomingCall(ringingCall.getState());
-
- //if (DBG) log("sPhone.acceptCall");
- app.mCM.acceptCall(ringingCall);
- answered = true;
-
- setAudioMode();
- } catch (CallStateException ex) {
- Log.w(LOG_TAG, "answerCall: caught " + ex, ex);
-
- if (phoneIsCdma) {
- // restore the cdmaPhoneCallState and btPhone.cdmaSetSecondCallState:
- app.cdmaPhoneCallState.setCurrentCallState(
- app.cdmaPhoneCallState.getPreviousCallState());
- if (btPhone != null) {
- try {
- btPhone.cdmaSetSecondCallState(false);
- } catch (RemoteException e) {
- Log.e(LOG_TAG, Log.getStackTraceString(new Throwable()));
- }
- }
- }
- }
- }
- return answered;
- }
-
- /**
- * Hangs up all active calls.
- */
- static void hangupAllCalls(CallManager cm) {
- final Call ringing = cm.getFirstActiveRingingCall();
- final Call fg = cm.getActiveFgCall();
- final Call bg = cm.getFirstActiveBgCall();
-
- // We go in reverse order, BG->FG->RINGING because hanging up a ringing call or an active
- // call can move a bg call to a fg call which would force us to loop over each call
- // several times. This ordering works best to ensure we dont have any more calls.
- if (bg != null && !bg.isIdle()) {
- hangup(bg);
- }
- if (fg != null && !fg.isIdle()) {
- hangup(fg);
- }
- if (ringing != null && !ringing.isIdle()) {
- hangupRingingCall(fg);
- }
- }
-
- /**
- * Smart "hang up" helper method which hangs up exactly one connection,
- * based on the current Phone state, as follows:
- * <ul>
- * <li>If there's a ringing call, hang that up.
- * <li>Else if there's a foreground call, hang that up.
- * <li>Else if there's a background call, hang that up.
- * <li>Otherwise do nothing.
- * </ul>
- * @return true if we successfully hung up, or false
- * if there were no active calls at all.
- */
- static boolean hangup(CallManager cm) {
- boolean hungup = false;
- Call ringing = cm.getFirstActiveRingingCall();
- Call fg = cm.getActiveFgCall();
- Call bg = cm.getFirstActiveBgCall();
-
- if (!ringing.isIdle()) {
- log("hangup(): hanging up ringing call");
- hungup = hangupRingingCall(ringing);
- } else if (!fg.isIdle()) {
- log("hangup(): hanging up foreground call");
- hungup = hangup(fg);
- } else if (!bg.isIdle()) {
- log("hangup(): hanging up background call");
- hungup = hangup(bg);
- } else {
- // No call to hang up! This is unlikely in normal usage,
- // since the UI shouldn't be providing an "End call" button in
- // the first place. (But it *can* happen, rarely, if an
- // active call happens to disconnect on its own right when the
- // user is trying to hang up..)
- log("hangup(): no active call to hang up");
- }
- if (DBG) log("==> hungup = " + hungup);
-
- return hungup;
- }
-
- static boolean hangupRingingCall(Call ringing) {
- if (DBG) log("hangup ringing call");
- int phoneType = ringing.getPhone().getPhoneType();
- Call.State state = ringing.getState();
-
- if (state == Call.State.INCOMING) {
- // Regular incoming call (with no other active calls)
- log("hangupRingingCall(): regular incoming call: hangup()");
- return hangup(ringing);
- } else {
- // Unexpected state: the ringing call isn't INCOMING or
- // WAITING, so there's no reason to have called
- // hangupRingingCall() in the first place.
- // (Presumably the incoming call went away at the exact moment
- // we got here, so just do nothing.)
- Log.w(LOG_TAG, "hangupRingingCall: no INCOMING or WAITING call");
- return false;
- }
- }
-
- static boolean hangupActiveCall(Call foreground) {
- if (DBG) log("hangup active call");
- return hangup(foreground);
- }
-
- static boolean hangupHoldingCall(Call background) {
- if (DBG) log("hangup holding call");
- return hangup(background);
- }
-
- /**
- * Used in CDMA phones to end the complete Call session
- * @param phone the Phone object.
- * @return true if *any* call was successfully hung up
- */
- static boolean hangupRingingAndActive(Phone phone) {
- boolean hungUpRingingCall = false;
- boolean hungUpFgCall = false;
- Call ringingCall = phone.getRingingCall();
- Call fgCall = phone.getForegroundCall();
-
- // Hang up any Ringing Call
- if (!ringingCall.isIdle()) {
- log("hangupRingingAndActive: Hang up Ringing Call");
- hungUpRingingCall = hangupRingingCall(ringingCall);
- }
-
- // Hang up any Active Call
- if (!fgCall.isIdle()) {
- log("hangupRingingAndActive: Hang up Foreground Call");
- hungUpFgCall = hangupActiveCall(fgCall);
- }
-
- return hungUpRingingCall || hungUpFgCall;
- }
-
- /**
- * Trivial wrapper around Call.hangup(), except that we return a
- * boolean success code rather than throwing CallStateException on
- * failure.
- *
- * @return true if the call was successfully hung up, or false
- * if the call wasn't actually active.
- */
- static boolean hangup(Call call) {
- try {
- CallManager cm = PhoneGlobals.getInstance().mCM;
-
- if (call.getState() == Call.State.ACTIVE && cm.hasActiveBgCall()) {
- // handle foreground call hangup while there is background call
- log("- hangup(Call): hangupForegroundResumeBackground...");
- cm.hangupForegroundResumeBackground(cm.getFirstActiveBgCall());
- } else {
- log("- hangup(Call): regular hangup()...");
- call.hangup();
- }
- return true;
- } catch (CallStateException ex) {
- Log.e(LOG_TAG, "Call hangup: caught " + ex, ex);
- }
-
- return false;
- }
-
- /**
- * Trivial wrapper around Connection.hangup(), except that we silently
- * do nothing (rather than throwing CallStateException) if the
- * connection wasn't actually active.
- */
- static void hangup(Connection c) {
- try {
- if (c != null) {
- c.hangup();
- }
- } catch (CallStateException ex) {
- Log.w(LOG_TAG, "Connection hangup: caught " + ex, ex);
- }
- }
-
- static boolean answerAndEndHolding(CallManager cm, Call ringing) {
- if (DBG) log("end holding & answer waiting: 1");
- if (!hangupHoldingCall(cm.getFirstActiveBgCall())) {
- Log.e(LOG_TAG, "end holding failed!");
- return false;
- }
-
- if (DBG) log("end holding & answer waiting: 2");
- return answerCall(ringing);
-
- }
-
- /**
- * Answers the incoming call specified by "ringing", and ends the currently active phone call.
- *
- * This method is useful when's there's an incoming call which we cannot manage with the
- * current call. e.g. when you are having a phone call with CDMA network and has received
- * a SIP call, then we won't expect our telephony can manage those phone calls simultaneously.
- * Note that some types of network may allow multiple phone calls at once; GSM allows to hold
- * an ongoing phone call, so we don't need to end the active call. The caller of this method
- * needs to check if the network allows multiple phone calls or not.
- *
- * @see #answerCall(Call)
- * @see InCallScreen#internalAnswerCall()
- */
- /* package */ static boolean answerAndEndActive(CallManager cm, Call ringing) {
- if (DBG) log("answerAndEndActive()...");
-
- // Unlike the answerCall() method, we *don't* need to stop the
- // ringer or change audio modes here since the user is already
- // in-call, which means that the audio mode is already set
- // correctly, and that we wouldn't have started the ringer in the
- // first place.
-
- // hanging up the active call also accepts the waiting call
- // while active call and waiting call are from the same phone
- // i.e. both from GSM phone
- Call fgCall = cm.getActiveFgCall();
- if (!hangupActiveCall(fgCall)) {
- Log.w(LOG_TAG, "end active call failed!");
- return false;
- }
-
- mConnectionHandler.removeMessages(MSG_CHECK_STATUS_ANSWERCALL);
- Message msg = mConnectionHandler.obtainMessage(MSG_CHECK_STATUS_ANSWERCALL);
- msg.arg1 = 1;
- msg.obj = new FgRingCalls(fgCall, ringing);
- mConnectionHandler.sendMessage(msg);
-
- return true;
- }
-
- /**
* For a CDMA phone, advance the call state upon making a new
* outgoing call.
*
@@ -676,87 +346,6 @@
return builder.toString();
}
- /**
- * Wrapper function to control when to send an empty Flash command to the network.
- * Mainly needed for CDMA networks, such as scenarios when we need to send a blank flash
- * to the network prior to placing a 3-way call for it to be successful.
- */
- static void sendEmptyFlash(Phone phone) {
- if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
- Call fgCall = phone.getForegroundCall();
- if (fgCall.getState() == Call.State.ACTIVE) {
- // Send the empty flash
- if (DBG) Log.d(LOG_TAG, "onReceive: (CDMA) sending empty flash to network");
- switchHoldingAndActive(phone.getBackgroundCall());
- }
- }
- }
-
- static void swap() {
- final PhoneGlobals mApp = PhoneGlobals.getInstance();
- if (!okToSwapCalls(mApp.mCM)) {
- // TODO: throw an error instead?
- return;
- }
-
- // Swap the fg and bg calls.
- // In the future we may provide some way for user to choose among
- // multiple background calls, for now, always act on the first background call.
- PhoneUtils.switchHoldingAndActive(mApp.mCM.getFirstActiveBgCall());
- }
-
- /**
- * @param heldCall is the background call want to be swapped
- */
- static void switchHoldingAndActive(Call heldCall) {
- log("switchHoldingAndActive()...");
- try {
- CallManager cm = PhoneGlobals.getInstance().mCM;
- if (heldCall.isIdle()) {
- // no heldCall, so it is to hold active call
- cm.switchHoldingAndActive(cm.getFgPhone().getBackgroundCall());
- } else {
- // has particular heldCall, so to switch
- cm.switchHoldingAndActive(heldCall);
- }
- setAudioMode(cm);
- } catch (CallStateException ex) {
- Log.w(LOG_TAG, "switchHoldingAndActive: caught " + ex, ex);
- }
- }
-
- static void mergeCalls() {
- mergeCalls(PhoneGlobals.getInstance().mCM);
- }
-
- static void mergeCalls(CallManager cm) {
- int phoneType = cm.getFgPhone().getPhoneType();
- if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
- log("mergeCalls(): CDMA...");
- PhoneGlobals app = PhoneGlobals.getInstance();
- if (app.cdmaPhoneCallState.getCurrentCallState()
- == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE) {
- // Set the Phone Call State to conference
- app.cdmaPhoneCallState.setCurrentCallState(
- CdmaPhoneCallState.PhoneCallState.CONF_CALL);
-
- // Send flash cmd
- // TODO: Need to change the call from switchHoldingAndActive to
- // something meaningful as we are not actually trying to swap calls but
- // instead are merging two calls by sending a Flash command.
- log("- sending flash...");
- switchHoldingAndActive(cm.getFirstActiveBgCall());
- }
- } else {
- try {
- log("mergeCalls(): calling cm.conference()...");
- cm.conference(cm.getFirstActiveBgCall());
- } catch (CallStateException ex) {
- Log.w(LOG_TAG, "mergeCalls: caught " + ex, ex);
- }
- }
- }
-
static void separateCall(Connection c) {
try {
if (DBG) log("separateCall: " + toLogSafePhoneNumber(c.getAddress()));
@@ -1741,20 +1330,6 @@
return audioManager.isSpeakerphoneOn();
}
- static boolean isInEmergencyCall(CallManager cm) {
- Call fgCall = cm.getActiveFgCall();
- // isIdle includes checks for the DISCONNECTING/DISCONNECTED state.
- if(!fgCall.isIdle()) {
- for (Connection cn : fgCall.getConnections()) {
- if (PhoneNumberUtils.isLocalEmergencyNumber(PhoneGlobals.getInstance(),
- cn.getAddress())) {
- return true;
- }
- }
- }
- return false;
- }
-
/**
* Get the mute state of foreground phone, which has the current
* foreground call
diff --git a/src/com/android/phone/RoamingDialogFragment.java b/src/com/android/phone/RoamingDialogFragment.java
index d24967b..384a120 100644
--- a/src/com/android/phone/RoamingDialogFragment.java
+++ b/src/com/android/phone/RoamingDialogFragment.java
@@ -35,6 +35,7 @@
public static final String SUB_ID_KEY = "sub_id_key";
+ private CarrierConfigManager mCarrierConfigManager;
private int mSubId;
/**
@@ -52,6 +53,7 @@
super.onAttach(context);
Bundle args = getArguments();
mSubId = args.getInt(SUB_ID_KEY);
+ mCarrierConfigManager = new CarrierConfigManager(context);
// Verify host activity implemented callback interface
FragmentManager fragmentManager = getFragmentManager();
@@ -68,8 +70,7 @@
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
int title = R.string.roaming_alert_title;
- PersistableBundle carrierConfig =
- PhoneGlobals.getInstance().getCarrierConfigForSubId(mSubId);
+ PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
if (carrierConfig != null && carrierConfig.getBoolean(
CarrierConfigManager.KEY_CHECK_PRICING_WITH_CARRIER_FOR_DATA_ROAMING_BOOL)) {
title = R.string.roaming_check_price_warning;
diff --git a/src/com/android/phone/settings/VoicemailProviderSettingsUtil.java b/src/com/android/phone/settings/VoicemailProviderSettingsUtil.java
index 8187664..3ccd4a3 100644
--- a/src/com/android/phone/settings/VoicemailProviderSettingsUtil.java
+++ b/src/com/android/phone/settings/VoicemailProviderSettingsUtil.java
@@ -137,7 +137,7 @@
prefs.edit()
.putString(key + VM_NUMBER_TAG, null)
.putInt(key + FWD_SETTINGS_TAG + FWD_SETTINGS_LENGTH_TAG, 0)
- .commit();
+ .apply();
}
private static SharedPreferences getPrefs(Context context) {
diff --git a/src/com/android/services/telephony/CdmaConferenceController.java b/src/com/android/services/telephony/CdmaConferenceController.java
index 24c3870..5d987f7 100644
--- a/src/com/android/services/telephony/CdmaConferenceController.java
+++ b/src/com/android/services/telephony/CdmaConferenceController.java
@@ -211,6 +211,7 @@
// 4) Add the conference to the connection service if it is new.
if (isNewlyCreated) {
Log.d(this, "Adding the conference call");
+ mConference.updateCallRadioTechAfterCreation();
mConnectionService.addConference(mConference);
}
} else if (conferenceConnections.isEmpty()) {
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index b196d57..5722834 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -640,6 +640,7 @@
setState(mConferenceHost.getState());
updateStatusHints();
+ putExtras(mConferenceHost.getExtras());
}
/**
diff --git a/src/com/android/services/telephony/TelephonyConferenceController.java b/src/com/android/services/telephony/TelephonyConferenceController.java
index e96815c..e9eef46 100644
--- a/src/com/android/services/telephony/TelephonyConferenceController.java
+++ b/src/com/android/services/telephony/TelephonyConferenceController.java
@@ -264,6 +264,7 @@
mTelephonyConference, connection);
mTelephonyConference.addConnection(connection);
}
+ mTelephonyConference.updateCallRadioTechAfterCreation();
mConnectionService.addConference(mTelephonyConference);
} else {
Log.d(this, "Trigger recalculate later");
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 4c1963f..3192c75 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -36,6 +36,7 @@
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
+import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.text.TextUtils;
@@ -96,6 +97,7 @@
private static final int MSG_CDMA_VOICE_PRIVACY_ON = 15;
private static final int MSG_CDMA_VOICE_PRIVACY_OFF = 16;
private static final int MSG_HANGUP = 17;
+ private static final int MSG_SET_CALL_RADIO_TECH = 18;
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
@@ -240,6 +242,31 @@
int cause = (int) msg.obj;
hangup(cause);
break;
+
+ case MSG_SET_CALL_RADIO_TECH:
+ int vrat = (int) msg.obj;
+ // Check whether Wi-Fi call tech is changed, it means call radio tech is:
+ // a) changed from IWLAN to other value, or
+ // b) changed from other value to IWLAN.
+ //
+ // In other word, below conditions are all met:
+ // 1) {@link #getCallRadioTech} is different from new vrat
+ // 2) Current call radio technology indicates Wi-Fi call, i.e. {@link #isWifi}
+ // is true, or new vrat indicates Wi-Fi call.
+ boolean isWifiTechChange = getCallRadioTech() != vrat
+ && (isWifi() || vrat == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN);
+
+ // Step 1) Updates call radio tech firstly, so that afterwards Wi-Fi related
+ // update actions are taken correctly.
+ setCallRadioTech(vrat);
+
+ // Step 2) Handles Wi-Fi call tech change.
+ if (isWifiTechChange) {
+ updateConnectionProperties();
+ updateStatusHints();
+ refreshDisableAddCall();
+ }
+ break;
}
}
};
@@ -421,14 +448,14 @@
}
/**
- * Used by {@link com.android.internal.telephony.Connection} to report a change in whether
- * the call is being made over a wifi network.
+ * Used by {@link com.android.internal.telephony.Connection} to report a change for
+ * the call radio technology.
*
- * @param isWifi True if call is made over wifi.
+ * @param vrat the RIL Voice Radio Technology used for current connection.
*/
@Override
- public void onWifiChanged(boolean isWifi) {
- setWifi(isWifi);
+ public void onCallRadioTechChanged(@ServiceState.RilRadioTechnology int vrat) {
+ mHandler.obtainMessage(MSG_SET_CALL_RADIO_TECH, vrat).sendToTarget();
}
/**
@@ -575,6 +602,11 @@
com.android.internal.telephony.Connection newConnection) {
setOriginalConnection(newConnection);
}
+
+ @Override
+ public void onIsNetworkEmergencyCallChanged(boolean isEmergencyCall) {
+ setIsNetworkIdentifiedEmergencyCall(isEmergencyCall);
+ }
};
protected com.android.internal.telephony.Connection mOriginalConnection;
@@ -599,13 +631,6 @@
private int mOriginalConnectionCapabilities;
/**
- * Determines if the {@link TelephonyConnection} is using wifi.
- * This is used when {@link TelephonyConnection#updateConnectionProperties()} is called to
- * indicate whether a call has the {@link Connection#PROPERTY_WIFI} property.
- */
- private boolean mIsWifi;
-
- /**
* Determines the audio quality is high for the {@link TelephonyConnection}.
* This is used when {@link TelephonyConnection#updateConnectionProperties}} is called to
* indicate whether a call has the {@link Connection#PROPERTY_HIGH_DEF_AUDIO} property.
@@ -620,6 +645,15 @@
private boolean mTreatAsEmergencyCall;
/**
+ * Indicates whether the network has identified this call as an emergency call. Where
+ * {@link #mTreatAsEmergencyCall} is based on comparing dialed numbers to a list of known
+ * emergency numbers, this property is based on whether the network itself has identified the
+ * call as an emergency call (which can be the case for an incoming call from emergency
+ * services).
+ */
+ private boolean mIsNetworkIdentifiedEmergencyCall;
+
+ /**
* For video calls, indicates whether the outgoing video for the call can be paused using
* the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
*/
@@ -888,6 +922,13 @@
Log.v(this, "Holding active call");
try {
Phone phone = mOriginalConnection.getCall().getPhone();
+
+ // New behavior for IMS -- don't use the clunky switchHoldingAndActive logic.
+ if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS) {
+ ImsPhone imsPhone = (ImsPhone) phone;
+ imsPhone.holdActiveCall();
+ return;
+ }
Call ringingCall = phone.getRingingCall();
// Although the method says switchHoldingAndActive, it eventually calls a RIL method
@@ -917,6 +958,13 @@
Log.v(this, "performUnhold");
if (Call.State.HOLDING == mConnectionState) {
try {
+ Phone phone = mOriginalConnection.getCall().getPhone();
+ // New behavior for IMS -- don't use the clunky switchHoldingAndActive logic.
+ if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS) {
+ ImsPhone imsPhone = (ImsPhone) phone;
+ imsPhone.unholdHeldCall();
+ return;
+ }
// Here's the deal--Telephony hold/unhold is weird because whenever there exists
// more than one call, one of them must always be active. In other words, if you
// have an active call and holding call, and you put the active call on hold, it
@@ -1021,7 +1069,7 @@
newProperties = changeBitmask(newProperties, PROPERTY_HIGH_DEF_AUDIO,
hasHighDefAudioProperty());
- newProperties = changeBitmask(newProperties, PROPERTY_WIFI, mIsWifi);
+ newProperties = changeBitmask(newProperties, PROPERTY_WIFI, isWifi());
newProperties = changeBitmask(newProperties, PROPERTY_IS_EXTERNAL_CALL,
isExternalConnection());
newProperties = changeBitmask(newProperties, PROPERTY_HAS_CDMA_VOICE_PRIVACY,
@@ -1029,6 +1077,8 @@
newProperties = changeBitmask(newProperties, PROPERTY_ASSISTED_DIALING_USED,
mIsUsingAssistedDialing);
newProperties = changeBitmask(newProperties, PROPERTY_IS_RTT, isRtt());
+ newProperties = changeBitmask(newProperties, PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL,
+ isNetworkIdentifiedEmergencyCall());
if (getConnectionProperties() != newProperties) {
setConnectionProperties(newProperties);
@@ -1108,12 +1158,14 @@
// Set video state and capabilities
setVideoState(mOriginalConnection.getVideoState());
setOriginalConnectionCapabilities(mOriginalConnection.getConnectionCapabilities());
- setWifi(mOriginalConnection.isWifi());
+ setIsNetworkIdentifiedEmergencyCall(mOriginalConnection.isNetworkIdentifiedEmergencyCall());
setAudioModeIsVoip(mOriginalConnection.getAudioModeIsVoip());
setVideoProvider(mOriginalConnection.getVideoProvider());
setAudioQuality(mOriginalConnection.getAudioQuality());
setTechnologyTypeExtra();
+ setCallRadioTech(mOriginalConnection.getCallRadioTech());
+
// Post update of extras to the handler; extras are updated via the handler to ensure thread
// safety. The Extras Bundle is cloned in case the original extras are modified while they
// are being added to mOriginalConnectionExtras in updateExtras.
@@ -1230,7 +1282,7 @@
if (isCurrentVideoCall) {
return true;
- } else if (wasVideoCall && mIsWifi && !isVowifiEnabled) {
+ } else if (wasVideoCall && isWifi() && !isVowifiEnabled) {
return true;
}
return false;
@@ -1265,7 +1317,7 @@
return false;
}
- if (mIsWifi && !canWifiCallsBeHdAudio) {
+ if (isWifi() && !canWifiCallsBeHdAudio) {
return false;
}
@@ -1824,21 +1876,31 @@
}
/**
- * Sets whether the call is using wifi. Used when rebuilding the capabilities to set or unset
- * the {@link Connection#PROPERTY_WIFI} property.
- */
- public void setWifi(boolean isWifi) {
- mIsWifi = isWifi;
- updateConnectionProperties();
- updateStatusHints();
- refreshDisableAddCall();
- }
-
- /**
* Whether the call is using wifi.
*/
boolean isWifi() {
- return mIsWifi;
+ return getCallRadioTech() == ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
+ }
+
+ /**
+ * Sets whether this call has been identified by the network as an emergency call.
+ * @param isNetworkIdentifiedEmergencyCall {@code true} if the network has identified this call
+ * as an emergency call, {@code false} otherwise.
+ */
+ public void setIsNetworkIdentifiedEmergencyCall(boolean isNetworkIdentifiedEmergencyCall) {
+ Log.d(this, "setIsNetworkIdentifiedEmergencyCall; callId=%s, "
+ + "isNetworkIdentifiedEmergencyCall=%b", getTelecomCallId(),
+ isNetworkIdentifiedEmergencyCall);
+ mIsNetworkIdentifiedEmergencyCall = isNetworkIdentifiedEmergencyCall;
+ updateConnectionProperties();
+ }
+
+ /**
+ * @return {@code true} if the network has identified this call as an emergency call,
+ * {@code false} otherwise.
+ */
+ public boolean isNetworkIdentifiedEmergencyCall() {
+ return mIsNetworkIdentifiedEmergencyCall;
}
/**
@@ -2027,7 +2089,7 @@
}
private void updateStatusHints() {
- if (mIsWifi && getPhone() != null) {
+ if (isWifi() && getPhone() != null) {
int labelId = isValidRingingCall()
? R.string.status_hint_label_incoming_wifi_call
: R.string.status_hint_label_wifi_call;
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 3aac490..3ec00b9 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -1037,7 +1037,9 @@
}
Queue<Phone> cachedPhones = mEmergencyRetryCache.second;
- Phone phoneUsed = c.getPhone();
+ // Need to refer default phone considering ImsPhone because
+ // cachedPhones is a list that contains default phones.
+ Phone phoneUsed = c.getPhone().getDefaultPhone();
if (phoneUsed == null) {
return;
}
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
index 3bd2716..a18adb8 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
@@ -21,7 +21,6 @@
import static junit.framework.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -817,6 +816,7 @@
testServiceState.setEmergencyOnly(isEmergencyOnly);
when(phone.getServiceState()).thenReturn(testServiceState);
when(phone.getPhoneId()).thenReturn(phoneId);
+ when(phone.getDefaultPhone()).thenReturn(phone);
return phone;
}
diff --git a/tests/src/com/android/services/telephony/TestTelephonyConnection.java b/tests/src/com/android/services/telephony/TestTelephonyConnection.java
index 9040257..39e4579 100644
--- a/tests/src/com/android/services/telephony/TestTelephonyConnection.java
+++ b/tests/src/com/android/services/telephony/TestTelephonyConnection.java
@@ -74,6 +74,7 @@
any(Connection.PostDialListener.class));
when(mMockPhone.getRingingCall()).thenReturn(mMockCall);
when(mMockPhone.getContext()).thenReturn(null);
+ when(mMockPhone.getDefaultPhone()).thenReturn(mMockPhone);
when(mMockCall.getState()).thenReturn(Call.State.ACTIVE);
when(mMockCall.getPhone()).thenReturn(mMockPhone);
}
@@ -107,6 +108,11 @@
mLastConnectionEventExtras.add(extras);
}
+ @Override
+ void clearOriginalConnection() {
+ // Do nothing since the original connection is mock object
+ }
+
public int getNotifyPhoneAccountChangedCount() {
return mNotifyPhoneAccountChangedCount;
}