Merge "Disable "Preferred Network Type" setting in 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/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/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 dcb0520..9e8eaf3 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
@@ -789,6 +791,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);
@@ -1053,8 +1056,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/PhoneApp.java b/src/com/android/phone/PhoneApp.java
index f16d8ce..df151bf 100644
--- a/src/com/android/phone/PhoneApp.java
+++ b/src/com/android/phone/PhoneApp.java
@@ -19,14 +19,13 @@
import android.app.Application;
import android.os.UserHandle;
-import com.android.services.telephony.TelephonyGlobals;
+import com.android.services.telephony.TelecomAccountRegistry;
/**
* Top-level Application class for the Phone app.
*/
public class PhoneApp extends Application {
PhoneGlobals mPhoneGlobals;
- TelephonyGlobals mTelephonyGlobals;
public PhoneApp() {
}
@@ -39,8 +38,7 @@
mPhoneGlobals = new PhoneGlobals(this);
mPhoneGlobals.onCreate();
- mTelephonyGlobals = new TelephonyGlobals(this);
- mTelephonyGlobals.onCreate();
+ TelecomAccountRegistry.getInstance(this).setupOnBoot();
}
}
}
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 2e4684e..353f4b5 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -764,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:
@@ -1169,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);
@@ -2584,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);
}
@@ -2745,6 +2755,10 @@
return mSubscriptionController.getDefaultVoiceSubId();
}
+ private boolean isActiveSubscription(int subId) {
+ return mSubscriptionController.isActiveSubId(subId);
+ }
+
/**
* @see android.telephony.TelephonyManager.WifiCallingChoices
*/
@@ -3285,6 +3299,10 @@
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "setNetworkSelectionModeAutomatic");
+ if (!isActiveSubscription(subId)) {
+ return;
+ }
+
final long identity = Binder.clearCallingIdentity();
try {
if (DBG) log("setNetworkSelectionModeAutomatic: subId " + subId);
@@ -3310,6 +3328,11 @@
int subId, OperatorInfo operatorInfo, boolean persistSelection) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "setNetworkSelectionModeManual");
+
+ if (!isActiveSubscription(subId)) {
+ return false;
+ }
+
final long identity = Binder.clearCallingIdentity();
try {
ManualNetworkSelectionArgument arg = new ManualNetworkSelectionArgument(operatorInfo,
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index c5625e9..9ede914 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -1330,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/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 642af85..6b7a002 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -64,7 +64,7 @@
* Owns all data we have registered with Telecom including handling dynamic addition and
* removal of SIMs and SIP accounts.
*/
-final class TelecomAccountRegistry {
+public final class TelecomAccountRegistry {
private static final boolean DBG = false; /* STOP SHIP if true */
// This icon is the one that is used when the Slot ID that we have for a particular SIM
@@ -659,7 +659,10 @@
mSubscriptionManager = SubscriptionManager.from(context);
}
- static synchronized final TelecomAccountRegistry getInstance(Context context) {
+ /**
+ * Get the singleton instance.
+ */
+ public static synchronized TelecomAccountRegistry getInstance(Context context) {
if (sInstance == null && context != null) {
sInstance = new TelecomAccountRegistry(context);
}
@@ -828,7 +831,7 @@
/**
* Sets up all the phone accounts for SIMs on first boot.
*/
- void setupOnBoot() {
+ public void setupOnBoot() {
// TODO: When this object "finishes" we should unregister by invoking
// SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener);
// This is not strictly necessary because it will be unregistered if the
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 7d25767..3192c75 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -602,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;
@@ -640,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.
*/
@@ -681,6 +695,11 @@
private boolean mIsHoldable;
/**
+ * Indicates whether TTY is enabled; used to determine whether a call is VT capable.
+ */
+ private boolean mIsTtyEnabled;
+
+ /**
* Indicates whether this call is using assisted dialing.
*/
private boolean mIsUsingAssistedDialing;
@@ -1058,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);
@@ -1137,6 +1158,7 @@
// Set video state and capabilities
setVideoState(mOriginalConnection.getVideoState());
setOriginalConnectionCapabilities(mOriginalConnection.getConnectionCapabilities());
+ setIsNetworkIdentifiedEmergencyCall(mOriginalConnection.isNetworkIdentifiedEmergencyCall());
setAudioModeIsVoip(mOriginalConnection.getAudioModeIsVoip());
setVideoProvider(mOriginalConnection.getVideoProvider());
setAudioQuality(mOriginalConnection.getAudioQuality());
@@ -1845,8 +1867,10 @@
capabilities = changeBitmask(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL,
can(mOriginalConnectionCapabilities, Capability.SUPPORTS_VT_REMOTE_BIDIRECTIONAL));
+ boolean isLocalVideoSupported = can(mOriginalConnectionCapabilities,
+ Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL) && !mIsTtyEnabled;
capabilities = changeBitmask(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL,
- can(mOriginalConnectionCapabilities, Capability.SUPPORTS_VT_LOCAL_BIDIRECTIONAL));
+ isLocalVideoSupported);
return capabilities;
}
@@ -1859,6 +1883,27 @@
}
/**
+ * 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;
+ }
+
+ /**
* @return {@code true} if this is an outgoing call, {@code false} otherwise.
*/
boolean isOutgoingCall() {
@@ -1963,6 +2008,15 @@
}
/**
+ * Sets whether TTY is enabled or not.
+ * @param isTtyEnabled
+ */
+ public void setTtyEnabled(boolean isTtyEnabled) {
+ mIsTtyEnabled = isTtyEnabled;
+ updateConnectionCapabilities();
+ }
+
+ /**
* Whether the original connection is an IMS connection.
* @return {@code True} if the original connection is an IMS connection, {@code false}
* otherwise.
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 195194c..3ec00b9 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -17,9 +17,11 @@
package com.android.services.telephony;
import android.content.ActivityNotFoundException;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
@@ -119,6 +121,23 @@
}
};
+ private final BroadcastReceiver mTtyBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ Log.v(this, "onReceive, action: %s", action);
+ if (action.equals(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED)) {
+ int newPreferredTtyMode = intent.getIntExtra(
+ TelecomManager.EXTRA_TTY_PREFERRED_MODE, TelecomManager.TTY_MODE_OFF);
+
+ boolean isTtyNowEnabled = newPreferredTtyMode != TelecomManager.TTY_MODE_OFF;
+ if (isTtyNowEnabled != mIsTtyEnabled) {
+ handleTtyModeChange(isTtyNowEnabled);
+ }
+ }
+ }
+ };
+
private final TelephonyConferenceController mTelephonyConferenceController =
new TelephonyConferenceController(mTelephonyConnectionServiceProxy);
private final CdmaConferenceController mCdmaConferenceController =
@@ -131,6 +150,7 @@
private RadioOnHelper mRadioOnHelper;
private EmergencyTonePlayer mEmergencyTonePlayer;
private HoldTracker mHoldTracker;
+ private boolean mIsTtyEnabled;
// Contains one TelephonyConnection that has placed a call and a memory of which Phones it has
// already tried to connect with. There should be only one TelephonyConnection trying to place a
@@ -263,6 +283,17 @@
mEmergencyTonePlayer = new EmergencyTonePlayer(this);
TelecomAccountRegistry.getInstance(this).setTelephonyConnectionService(this);
mHoldTracker = new HoldTracker();
+ mIsTtyEnabled = isTtyModeEnabled(getApplicationContext());
+
+ IntentFilter intentFilter = new IntentFilter(
+ TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED);
+ registerReceiver(mTtyBroadcastReceiver, intentFilter);
+ }
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ unregisterReceiver(mTtyBroadcastReceiver);
+ return super.onUnbind(intent);
}
@Override
@@ -633,8 +664,9 @@
}
final Context context = getApplicationContext();
- if (VideoProfile.isVideo(request.getVideoState()) && isTtyModeEnabled(context) &&
- !isEmergencyNumber) {
+ final boolean isTtyModeEnabled = isTtyModeEnabled(context);
+ if (VideoProfile.isVideo(request.getVideoState()) && isTtyModeEnabled
+ && !isEmergencyNumber) {
return Connection.createFailedConnection(DisconnectCauseUtil.toTelecomDisconnectCause(
android.telephony.DisconnectCause.VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED,
null, phone.getPhoneId()));
@@ -670,7 +702,7 @@
connection.setInitializing();
connection.setVideoState(request.getVideoState());
connection.setRttTextStream(request.getRttTextStream());
-
+ connection.setTtyEnabled(isTtyModeEnabled);
return connection;
}
@@ -1005,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;
}
@@ -1453,4 +1487,15 @@
}
}
}
+
+ private void handleTtyModeChange(boolean isTtyEnabled) {
+ Log.i(this, "handleTtyModeChange; isTtyEnabled=%b", isTtyEnabled);
+ mIsTtyEnabled = isTtyEnabled;
+ for (Connection connection : getAllConnections()) {
+ if (connection instanceof TelephonyConnection) {
+ TelephonyConnection telephonyConnection = (TelephonyConnection) connection;
+ telephonyConnection.setTtyEnabled(isTtyEnabled);
+ }
+ }
+ }
}
diff --git a/src/com/android/services/telephony/TelephonyGlobals.java b/src/com/android/services/telephony/TelephonyGlobals.java
deleted file mode 100644
index 02ef639..0000000
--- a/src/com/android/services/telephony/TelephonyGlobals.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.services.telephony;
-
-import android.content.Context;
-
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Singleton entry point for the telephony-services app. Initializes ongoing systems relating to
- * PSTN calls. This is started when the device starts and will be restarted automatically
- * if it goes away for any reason (e.g., crashes).
- * This is separate from the actual Application class because we only support one instance of this
- * app - running as the default user. {@link com.android.phone.PhoneApp} determines whether or not
- * we are running as the default user and if we are, then initializes and runs this class's
- * {@link #onCreate}.
- */
-public class TelephonyGlobals {
- private static TelephonyGlobals sInstance;
-
- /** The application context. */
- private final Context mContext;
-
- // For supporting MSIM phone, change Phone and TtyManager as 1 to 1
- private List<TtyManager> mTtyManagers = new ArrayList<>();
-
- /**
- * Persists the specified parameters.
- *
- * @param context The application context.
- */
- public TelephonyGlobals(Context context) {
- mContext = context.getApplicationContext();
- }
-
- public static synchronized TelephonyGlobals getInstance(Context context) {
- if (sInstance == null) {
- sInstance = new TelephonyGlobals(context);
- }
- return sInstance;
- }
-
- public void onCreate() {
- // Make this work with Multi-SIM devices
- Phone[] phones = PhoneFactory.getPhones();
- for (Phone phone : phones) {
- mTtyManagers.add(new TtyManager(mContext, phone));
- }
-
- TelecomAccountRegistry.getInstance(mContext).setupOnBoot();
- }
-}
diff --git a/src/com/android/services/telephony/TtyManager.java b/src/com/android/services/telephony/TtyManager.java
deleted file mode 100644
index 3389ce8..0000000
--- a/src/com/android/services/telephony/TtyManager.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.services.telephony;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Message;
-import android.provider.Settings;
-import android.telecom.TelecomManager;
-
-import com.android.internal.telephony.Phone;
-
-final class TtyManager {
- private final static int MSG_SET_TTY_MODE_RESPONSE = 1;
- private final static int MSG_GET_TTY_MODE_RESPONSE = 2;
-
- private final TtyBroadcastReceiver mReceiver = new TtyBroadcastReceiver();
- private final Phone mPhone;
- private int mTtyMode;
- private int mUiTtyMode = -1;
-
- private final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_SET_TTY_MODE_RESPONSE: {
- Log.v(TtyManager.this, "got setTtyMode response");
- AsyncResult ar = (AsyncResult) msg.obj;
- if (ar.exception != null) {
- Log.d(TtyManager.this, "setTTYMode exception: %s", ar.exception);
- }
- mPhone.queryTTYMode(obtainMessage(MSG_GET_TTY_MODE_RESPONSE));
- break;
- }
- case MSG_GET_TTY_MODE_RESPONSE: {
- Log.v(TtyManager.this, "got queryTTYMode response");
- AsyncResult ar = (AsyncResult) msg.obj;
- if (ar.exception != null) {
- Log.d(TtyManager.this, "queryTTYMode exception: %s", ar.exception);
- } else {
- int ttyMode = phoneModeToTelecomMode(((int[]) ar.result)[0]);
- if (ttyMode != mTtyMode) {
- Log.d(TtyManager.this, "setting TTY mode failed, attempted %d, got: %d",
- mTtyMode, ttyMode);
- } else {
- Log.d(TtyManager.this, "setting TTY mode to %d succeeded", ttyMode);
- }
- }
- break;
- }
- }
- }
- };
-
- TtyManager(Context context, Phone phone) {
- mPhone = phone;
-
- IntentFilter intentFilter = new IntentFilter(
- TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
- intentFilter.addAction(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED);
- context.registerReceiver(mReceiver, intentFilter);
-
- int ttyMode = TelecomManager.TTY_MODE_OFF;
- TelecomManager telecomManager = TelecomManager.from(context);
- if (telecomManager != null) {
- ttyMode = telecomManager.getCurrentTtyMode();
- }
- updateTtyMode(ttyMode);
- //Get preferred TTY mode from data base as UI Tty mode is always user preferred Tty mode.
- ttyMode = Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.PREFERRED_TTY_MODE, TelecomManager.TTY_MODE_OFF);
- updateUiTtyMode(ttyMode);
- }
-
- private void updateTtyMode(int ttyMode) {
- Log.v(this, "updateTtyMode %d -> %d", mTtyMode, ttyMode);
- mTtyMode = ttyMode;
- mPhone.setTTYMode(telecomModeToPhoneMode(ttyMode),
- mHandler.obtainMessage(MSG_SET_TTY_MODE_RESPONSE));
- }
-
- private void updateUiTtyMode(int ttyMode) {
- Log.i(this, "updateUiTtyMode %d -> %d", mUiTtyMode, ttyMode);
- if(mUiTtyMode != ttyMode) {
- mUiTtyMode = ttyMode;
- mPhone.setUiTTYMode(telecomModeToPhoneMode(ttyMode), null);
- } else {
- Log.i(this, "ui tty mode didnt change");
- }
- }
-
- private final class TtyBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- Log.v(TtyManager.this, "onReceive, action: %s", action);
- if (action.equals(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED)) {
- int ttyMode = intent.getIntExtra(
- TelecomManager.EXTRA_CURRENT_TTY_MODE, TelecomManager.TTY_MODE_OFF);
- updateTtyMode(ttyMode);
- } else if (action.equals(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED)) {
- int newPreferredTtyMode = intent.getIntExtra(
- TelecomManager.EXTRA_TTY_PREFERRED_MODE, TelecomManager.TTY_MODE_OFF);
- updateUiTtyMode(newPreferredTtyMode);
- }
- }
- }
-
- private static int telecomModeToPhoneMode(int telecomMode) {
- switch (telecomMode) {
- // AT command only has 0 and 1, so mapping VCO
- // and HCO to FULL
- case TelecomManager.TTY_MODE_FULL:
- case TelecomManager.TTY_MODE_VCO:
- case TelecomManager.TTY_MODE_HCO:
- return Phone.TTY_MODE_FULL;
- default:
- return Phone.TTY_MODE_OFF;
- }
- }
-
- private static int phoneModeToTelecomMode(int phoneMode) {
- switch (phoneMode) {
- case Phone.TTY_MODE_FULL:
- return TelecomManager.TTY_MODE_FULL;
- case Phone.TTY_MODE_VCO:
- return TelecomManager.TTY_MODE_VCO;
- case Phone.TTY_MODE_HCO:
- return TelecomManager.TTY_MODE_HCO;
- case Phone.TTY_MODE_OFF:
- default:
- return TelecomManager.TTY_MODE_OFF;
- }
- }
-}
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;
}