Use displayName instead of operator name in MMS data notification

When the phone is in DSDS mode and the user tries to send an MMS message
from the SIM that isn't the default for data, we need to pop up a
notification letting them know that the action can't succeed unless they
turn on the advanced option to allow data use for MMS messages. This
notification was using the operator name instead of the subscription
display name, so it didn't reflect any renaming the user might have done
to keep track of their SIMs, which is obviously confusing especially if
they have two different SIMs for the same carrier. This CL switches to
using the subscription display name in this notification.

Fixes: 134771858
Test: make RunSettingsRoboTests
Change-Id: I6995bf9dd6d5e9544e26f0d8e30e97c4e73ab783
This commit is contained in:
Antony Sargent
2019-06-17 13:23:10 -07:00
parent 9a1c75c57a
commit 37008824e6
2 changed files with 15 additions and 4 deletions

View File

@@ -40,12 +40,14 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.MobileNetworkActivity; import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settingslib.HelpUtils; import com.android.settingslib.HelpUtils;
@@ -104,6 +106,11 @@ public class SimSelectNotification extends BroadcastReceiver {
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId); Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
return; return;
} }
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(subId);
if (info == null) {
Log.w(TAG, "onEnableMmsDataRequest null SubscriptionInfo for sub ID " + subId);
return;
}
// Getting request reason from extra, which will determine the notification title. // Getting request reason from extra, which will determine the notification title.
CharSequence notificationTitle = null; CharSequence notificationTitle = null;
@@ -128,7 +135,7 @@ public class SimSelectNotification extends BroadcastReceiver {
} }
CharSequence notificationSummary = context.getResources().getString( CharSequence notificationSummary = context.getResources().getString(
R.string.enable_mms_notification_summary, tm.getSimOperatorName()); R.string.enable_mms_notification_summary, SubscriptionUtil.getDisplayName(info));
cancelEnableMmsNotification(context); cancelEnableMmsNotification(context);

View File

@@ -49,6 +49,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
@@ -80,8 +81,10 @@ public class SimSelectNotificationTest {
private PackageManager mPackageManager; private PackageManager mPackageManager;
@Mock @Mock
private Resources mResources; private Resources mResources;
@Mock
private SubscriptionInfo mSubInfo;
private final String mFakeOperatorName = "fake_operator_name"; private final String mFakeDisplayName = "fake_display_name";
private final CharSequence mFakeNotificationChannelTitle = "fake_notification_channel_title"; private final CharSequence mFakeNotificationChannelTitle = "fake_notification_channel_title";
private final CharSequence mFakeNotificationTitle = "fake_notification_title"; private final CharSequence mFakeNotificationTitle = "fake_notification_title";
private final String mFakeNotificationSummary = "fake_notification_Summary"; private final String mFakeNotificationSummary = "fake_notification_Summary";
@@ -113,9 +116,10 @@ public class SimSelectNotificationTest {
.thenReturn(PackageManager.PERMISSION_GRANTED); .thenReturn(PackageManager.PERMISSION_GRANTED);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager); when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mTelephonyManager.getSimOperatorName()).thenReturn(mFakeOperatorName);
when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(false); when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(false);
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true);
when(mSubscriptionManager.getActiveSubscriptionInfo(mSubId)).thenReturn(mSubInfo);
when(mSubInfo.getDisplayName()).thenReturn(mFakeDisplayName);
when(mContext.getResources()).thenReturn(mResources); when(mContext.getResources()).thenReturn(mResources);
when(mResources.getText(R.string.enable_sending_mms_notification_title)) when(mResources.getText(R.string.enable_sending_mms_notification_title))
@@ -123,7 +127,7 @@ public class SimSelectNotificationTest {
when(mResources.getText(R.string.enable_mms_notification_channel_title)) when(mResources.getText(R.string.enable_mms_notification_channel_title))
.thenReturn(mFakeNotificationChannelTitle); .thenReturn(mFakeNotificationChannelTitle);
when(mResources.getString(R.string.enable_mms_notification_summary, when(mResources.getString(R.string.enable_mms_notification_summary,
mFakeOperatorName)).thenReturn(mFakeNotificationSummary); mFakeDisplayName)).thenReturn(mFakeNotificationSummary);
when(mResources.getText(R.string.dual_cdma_sim_warning_notification_channel_title)) when(mResources.getText(R.string.dual_cdma_sim_warning_notification_channel_title))
.thenReturn(mFakeDualCdmaWarningChannelTitle); .thenReturn(mFakeDualCdmaWarningChannelTitle);