Merge "Merge android10-qpr2-s3-release to aosp/master - DO NOT MERGE"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3209da9..50a26c2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -24,6 +24,8 @@
<string name="allow">Allow</string>
<!-- Strings for Dialog deny button -->
<string name="deny">Deny</string>
+ <!-- Used in confirmation dialogs as the action that the user will tap to turn on the feature. [CHAR LIMIT=40]-->
+ <string name="confirmation_turn_on">Turn on</string>
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
<string name="device_info_default">Unknown</string>
@@ -6996,19 +6998,33 @@
<string name="enhanced_4g_lte_mode_summary">Use LTE services to improve voice and other communications (recommended)</string>
<!-- Enhaced 4G LTE Mode summary for 4g calling. [CHAR LIMIT=100] -->
<string name="enhanced_4g_lte_mode_summary_4g_calling">Use 4G services to improve voice and other communications (recommended)</string>
- <!-- Title of a preference determining whether or not the user has enabled contact discovery,
- which is a service that uses the phone numbers in your contacts to determine if your
+ <!-- Title of a preference determining whether or not the user has allowed the device to share
+ their contacts' phone numbers with their carrier in order to implement contact discovery,
+ which is a service that exchanges contacts with the carrier to determine if your
contacts support advanced calling features, such as video calling. [CHAR LIMIT=50]-->
- <string name="contact_discovery_opt_in_title">Contact discovery</string>
- <!-- Summary of a preference determining whether or not the user has enabled contact discovery.
- [CHAR LIMIT=110] -->
- <string name="contact_discovery_opt_in_summary">Allows your carrier to discover which calling features your contacts support.</string>
- <!-- Title of the dialog shown when the user tries to enable Contact Discovery.
+ <string name="contact_discovery_opt_in_title">Send contacts to carrier</string>
+ <!-- Summary of a preference determining whether or not the user has enabled contact discovery,
+ which is a service that exchanges contacts with the carrier to determine if your contacts
+ support enhanced features, such as video calling and RCS messaging. [CHAR LIMIT=110] -->
+ <string name="contact_discovery_opt_in_summary">Send your contacts\u2019 phone numbers to provide enhanced features</string>
+ <!-- Title of the dialog shown when the user tries to enable Contact Discovery, which is a
+ service that exchanges contacts with the carrier to determine if your contacts support
+ enhanced features, such as video calling and RCS messaging. [CHAR LIMIT=50] -->
+ <string name="contact_discovery_opt_in_dialog_title">Send contacts to <xliff:g id="carrier" example="T-mobile">%1$s</xliff:g>?</string>
+ <!-- Title of the dialog shown when the carrier name is not known and the user tries to enable
+ Contact Discovery, which is a service that exchanges contacts with the carrier to determine
+ if your contacts support enhanced features, such as video calling and RCS messaging.
[CHAR LIMIT=50] -->
- <string name="contact_discovery_opt_in_dialog_title">Enable contact discovery?</string>
- <!-- Text displayed in the dialog shown when the user tries to enable Contact Discovery.
- [CHAR LIMIT=NONE]-->
- <string name="contact_discovery_opt_in_dialog_message">All of the phone numbers in your contacts will be periodically sent to your carrier in order to discover which calling features are supported.</string>
+ <string name="contact_discovery_opt_in_dialog_title_no_carrier_defined">Send contacts to your carrier?</string>
+ <!-- The text displayed in the dialog shown when the user tries to enable Contact Discovery,
+ which is a service that exchanges contacts with the carrier to determine if your contacts
+ support enhanced features, such as video calling and RCS messaging. [CHAR LIMIT=NONE]-->
+ <string name="contact_discovery_opt_in_dialog_message">Your contacts\u2019 phone numbers will be periodically sent to <xliff:g id="carrier" example="T-mobile">%1$s</xliff:g>.<xliff:g id="empty_line" example=" ">\n\n</xliff:g>This info identifies whether your contacts can use certain features, like video calls or some messaging features.</string>
+ <!-- The text displayed in the dialog shown when the mobile carrier's name is not known and the
+ user tries to enable Contact Discovery, which is a service that exchanges contacts with
+ the carrier to determine if your contacts support enhanced features, such as video calling
+ and RCS messaging. [CHAR LIMIT=NONE]-->
+ <string name="contact_discovery_opt_in_dialog_message_no_carrier_defined">Your contacts\u2019 phone numbers will be periodically sent to your carrier.<xliff:g id="empty_line" example=" ">\n\n</xliff:g>This info identifies whether your contacts can use certain features, like video calls or some messaging features.</string>
<!-- Preferred network type title. [CHAR LIMIT=50] -->
<string name="preferred_network_type_title">Preferred network type</string>
<!-- Preferred network type summary. [CHAR LIMIT=100] -->
diff --git a/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
index a6db773..aec3648 100644
--- a/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
@@ -20,6 +20,7 @@
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
+import android.text.TextUtils;
import com.android.settings.core.BasePreferenceController;
@@ -49,6 +50,6 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return TextUtils.isEmpty(getSummary()) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
}
diff --git a/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragment.java b/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragment.java
index 7273010..26398d7 100644
--- a/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragment.java
+++ b/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragment.java
@@ -23,6 +23,7 @@
import android.os.Bundle;
import android.telephony.ims.ImsManager;
import android.telephony.ims.ImsRcsManager;
+import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentManager;
@@ -39,9 +40,11 @@
implements DialogInterface.OnClickListener {
private static final String SUB_ID_KEY = "sub_id_key";
+ private static final String CARRIER_NAME_KEY = "carrier_name_key";
private static final String DIALOG_TAG = "discovery_dialog:";
private int mSubId;
+ private CharSequence mCarrierName;
private ImsManager mImsManager;
/**
@@ -50,10 +53,11 @@
* @param subId The subscription ID to associate with this Dialog.
* @return a new instance of ContactDiscoveryDialogFragment.
*/
- public static ContactDiscoveryDialogFragment newInstance(int subId) {
+ public static ContactDiscoveryDialogFragment newInstance(int subId, CharSequence carrierName) {
final ContactDiscoveryDialogFragment dialogFragment = new ContactDiscoveryDialogFragment();
final Bundle args = new Bundle();
args.putInt(SUB_ID_KEY, subId);
+ args.putCharSequence(CARRIER_NAME_KEY, carrierName);
dialogFragment.setArguments(args);
return dialogFragment;
@@ -64,18 +68,30 @@
super.onAttach(context);
final Bundle args = getArguments();
mSubId = args.getInt(SUB_ID_KEY);
+ mCarrierName = args.getCharSequence(CARRIER_NAME_KEY);
mImsManager = getImsManager(context);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- final int title = R.string.contact_discovery_opt_in_dialog_title;
- int message = R.string.contact_discovery_opt_in_dialog_message;
- builder.setMessage(getResources().getString(message))
+ CharSequence title;
+ CharSequence message;
+ if (!TextUtils.isEmpty(mCarrierName)) {
+ title = getContext().getString(
+ R.string.contact_discovery_opt_in_dialog_title, mCarrierName);
+ message = getContext().getString(
+ R.string.contact_discovery_opt_in_dialog_message, mCarrierName);
+ } else {
+ title = getContext().getString(
+ R.string.contact_discovery_opt_in_dialog_title_no_carrier_defined);
+ message = getContext().getString(
+ R.string.contact_discovery_opt_in_dialog_message_no_carrier_defined);
+ }
+ builder.setMessage(message)
.setTitle(title)
.setIconAttribute(android.R.attr.alertDialogIcon)
- .setPositiveButton(android.R.string.ok, this)
+ .setPositiveButton(R.string.confirmation_turn_on, this)
.setNegativeButton(android.R.string.cancel, this);
return builder.create();
}
diff --git a/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceController.java b/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceController.java
index 21d49d9..880c444 100644
--- a/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceController.java
+++ b/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceController.java
@@ -22,6 +22,7 @@
import android.os.PersistableBundle;
import android.provider.Telephony;
import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionInfo;
import android.telephony.ims.ImsManager;
import android.util.Log;
@@ -34,6 +35,8 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
+import com.android.settings.network.SubscriptionUtil;
+
/**
* Controller for the "Contact Discovery" option present in MobileNetworkSettings.
@@ -130,7 +133,19 @@
private void showContentDiscoveryDialog() {
ContactDiscoveryDialogFragment dialog = ContactDiscoveryDialogFragment.newInstance(
- mSubId);
+ mSubId, getCarrierDisplayName(preference.getContext()));
dialog.show(mFragmentManager, ContactDiscoveryDialogFragment.getFragmentTag(mSubId));
}
+
+ private CharSequence getCarrierDisplayName(Context context) {
+ CharSequence result = "";
+
+ for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(context)) {
+ if (mSubId == info.getSubscriptionId()) {
+ result = info.getDisplayName();
+ break;
+ }
+ }
+ return result;
+ }
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 16c5adc..90b73f8 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -205,16 +205,9 @@
final Intent intent = getIntent();
if (intent != null) {
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
- if (subId != SUB_ID_NULL) {
- for (SubscriptionInfo subscription :
- SubscriptionUtil.getAvailableSubscriptions(this)) {
- if (subscription.getSubscriptionId() == subId) {
- return subscription;
- }
- }
- }
+ SubscriptionInfo info = getSubscriptionInfo(subId);
+ if (info != null) return info;
}
-
if (CollectionUtils.isEmpty(mSubscriptionInfos)) {
return null;
}
@@ -222,6 +215,23 @@
}
/**
+ * @return the subscription associated with a given subscription ID or null if none can be
+ * found.
+ */
+ SubscriptionInfo getSubscriptionInfo(int subId) {
+ if (subId == SUB_ID_NULL) {
+ return null;
+ }
+
+ for (SubscriptionInfo subscription : SubscriptionUtil.getAvailableSubscriptions(this)) {
+ if (subscription.getSubscriptionId() == subId) {
+ return subscription;
+ }
+ }
+ return null;
+ }
+
+ /**
* Get the current subId to display.
*/
@VisibleForTesting
@@ -340,6 +350,11 @@
}
private void maybeShowContactDiscoveryDialog(int subId) {
+ SubscriptionInfo info = getSubscriptionInfo(subId);
+ CharSequence carrierName = "";
+ if (info != null) {
+ carrierName = info.getDisplayName();
+ }
// If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
// associated dialog only if the opt-in has not been granted yet.
boolean showOptInDialog = doesIntentContainOptInAction(getIntent())
@@ -350,7 +365,7 @@
ContactDiscoveryDialogFragment fragment = getContactDiscoveryFragment(subId);
if (showOptInDialog) {
if (fragment == null) {
- fragment = ContactDiscoveryDialogFragment.newInstance(subId);
+ fragment = ContactDiscoveryDialogFragment.newInstance(subId, carrierName);
}
// Only try to show the dialog if it has not already been added, otherwise we may
// accidentally add it multiple times, causing multiple dialogs.
diff --git a/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragmentTest.java
index 6aef699..f2db71f 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryDialogFragmentTest.java
@@ -48,6 +48,7 @@
@Config(shadows = ShadowAlertDialog.class)
public class ContactDiscoveryDialogFragmentTest {
private static final int TEST_SUB_ID = 2;
+ private static final String TEST_CARRIER = "TestMobile";
@Mock private ImsManager mImsManager;
@Mock private ImsRcsManager mImsRcsManager;
@@ -60,7 +61,8 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mActivity = Robolectric.buildActivity(FragmentActivity.class).setup().get();
- mDialogFragmentUT = spy(ContactDiscoveryDialogFragment.newInstance(TEST_SUB_ID));
+ mDialogFragmentUT = spy(ContactDiscoveryDialogFragment.newInstance(TEST_SUB_ID,
+ TEST_CARRIER));
doReturn(mImsManager).when(mDialogFragmentUT).getImsManager(any());
doReturn(mImsRcsManager).when(mImsManager).getImsRcsManager(TEST_SUB_ID);
doReturn(mRcsUceAdapter).when(mImsRcsManager).getUceAdapter();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceControllerTest.java
index 0370bfa..3d54cfb 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/ContactDiscoveryPreferenceControllerTest.java
@@ -48,6 +48,7 @@
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.SwitchPreference;
+import com.android.settings.network.SubscriptionUtil;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -59,6 +60,8 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.Collections;
+
@RunWith(RobolectricTestRunner.class)
public class ContactDiscoveryPreferenceControllerTest {
@@ -99,6 +102,8 @@
mPreferenceControllerUT = new ContactDiscoveryPreferenceController(mContext,
"ContactDiscovery");
+ // Ensure subscriptionInfo check doesn't fail.
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(Collections.emptyList());
mPreferenceControllerUT.init(mFragmentManager, TEST_SUB_ID, mLifecycle);
mSwitchPreferenceUT = spy(new SwitchPreference(mContext));
mSwitchPreferenceUT.setKey(mPreferenceControllerUT.getPreferenceKey());