Loading src/com/android/settings/sim/SimDialogActivity.java +8 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.settings.sim; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.SubscriptionManager; Loading Loading @@ -54,6 +53,8 @@ public class SimDialogActivity extends FragmentActivity { public static final int PREFERRED_PICK = 3; // Show the "select SMS subscription" dialog, but don't save as default, just return a result public static final int SMS_PICK_FOR_MESSAGE = 4; // Dismiss the current dialog and finish the activity. public static final int PICK_DISMISS = 5; @Override protected void onCreate(Bundle savedInstanceState) { Loading @@ -70,6 +71,12 @@ public class SimDialogActivity extends FragmentActivity { private void showOrUpdateDialog() { final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK); if (dialogType == PICK_DISMISS) { finishAndRemoveTask(); return; } final String tag = Integer.toString(dialogType); final FragmentManager fragmentManager = getSupportFragmentManager(); SimDialogFragment fragment = (SimDialogFragment) fragmentManager.findFragmentByTag(tag); Loading src/com/android/settings/sim/SimSelectNotification.java +18 −5 Original line number Diff line number Diff line Loading @@ -20,10 +20,10 @@ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS; import static android.provider.Settings.EXTRA_ENABLE_MMS_DATA_REQUEST_REASON; import static android.provider.Settings.EXTRA_SUB_ID; import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_NAMES; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE; Loading @@ -32,6 +32,9 @@ import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_T import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID; import static android.telephony.data.ApnSetting.TYPE_MMS; import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME; import static com.android.settings.sim.SimDialogActivity.PICK_DISMISS; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading @@ -51,7 +54,6 @@ import com.android.settings.HelpTrampoline; import com.android.settings.R; import com.android.settings.network.SubscriptionUtil; import com.android.settings.network.telephony.MobileNetworkActivity; import com.android.settingslib.HelpUtils; public class SimSelectNotification extends BroadcastReceiver { private static final String TAG = "SimSelectNotification"; Loading Loading @@ -159,6 +161,16 @@ public class SimSelectNotification extends BroadcastReceiver { // Cancel any previous notifications cancelSimSelectNotification(context); // If the dialog type is to dismiss. if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS) { Intent newIntent = new Intent(context, SimDialogActivity.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newIntent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, PICK_DISMISS); context.startActivity(newIntent); return; } // Create a notification to tell the user that some defaults are missing createSimSelectNotification(context); Loading Loading @@ -186,10 +198,11 @@ public class SimSelectNotification extends BroadcastReceiver { final int warningType = intent.getIntExtra(EXTRA_SIM_COMBINATION_WARNING_TYPE, EXTRA_SIM_COMBINATION_WARNING_TYPE_NONE); if (warningType == EXTRA_SIM_COMBINATION_WARNING_TYPE_DUAL_CDMA) { // Cancel any previous notifications cancelSimCombinationWarningNotification(context); // Create a notification to tell the user that some defaults are missing if (warningType == EXTRA_SIM_COMBINATION_WARNING_TYPE_DUAL_CDMA) { // Create a notification to tell the user that there's a sim combination warning. createSimCombinationWarningNotification(context, intent); } } Loading tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java +51 −1 Original line number Diff line number Diff line Loading @@ -21,11 +21,17 @@ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS; import static android.provider.Settings.EXTRA_ENABLE_MMS_DATA_REQUEST_REASON; import static android.provider.Settings.EXTRA_SUB_ID; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_NAMES; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE_DUAL_CDMA; import static android.telephony.data.ApnSetting.TYPE_MMS; import static com.android.settings.sim.SimDialogActivity.DATA_PICK; import static com.android.settings.sim.SimDialogActivity.INVALID_PICK; import static com.android.settings.sim.SimDialogActivity.PICK_DISMISS; import static com.android.settings.sim.SimSelectNotification.ENABLE_MMS_NOTIFICATION_CHANNEL; import static com.android.settings.sim.SimSelectNotification.ENABLE_MMS_NOTIFICATION_ID; import static com.android.settings.sim.SimSelectNotification.SIM_WARNING_NOTIFICATION_CHANNEL; Loading @@ -36,6 +42,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading @@ -54,7 +61,6 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.settings.R; import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; import org.junit.Before; Loading Loading @@ -196,6 +202,50 @@ public class SimSelectNotificationTest { verify(mNotificationManager, never()).createNotificationChannel(any()); } @Test public void onReceivePrimarySubListChange_WithDataPickExtra_shouldStartActivity() { Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED); intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA); mSimSelectNotification.onReceive(mContext, intent); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mContext).startActivity(intentCaptor.capture()); Intent capturedIntent = intentCaptor.getValue(); assertThat(capturedIntent).isNotNull(); assertThat(capturedIntent.getComponent().getClassName()).isEqualTo( SimDialogActivity.class.getName()); assertThat(capturedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) .isNotEqualTo(0); assertThat(capturedIntent.getIntExtra(SimDialogActivity.DIALOG_TYPE_KEY, INVALID_PICK)) .isEqualTo(DATA_PICK); } @Test public void onReceivePrimarySubListChange_WithDismissExtra_shouldDismiss() { Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED); intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA); mSimSelectNotification.onReceive(mContext, intent); clearInvocations(mContext); // Dismiss. intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS); mSimSelectNotification.onReceive(mContext, intent); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mContext).startActivity(intentCaptor.capture()); Intent capturedIntent = intentCaptor.getValue(); assertThat(capturedIntent).isNotNull(); assertThat(capturedIntent.getComponent().getClassName()).isEqualTo( SimDialogActivity.class.getName()); assertThat(capturedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) .isNotEqualTo(0); assertThat(capturedIntent.getIntExtra(SimDialogActivity.DIALOG_TYPE_KEY, INVALID_PICK)) .isEqualTo(PICK_DISMISS); } @Test public void onReceivePrimarySubListChange_DualCdmaWarning_notificationShouldSend() { Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED); Loading Loading
src/com/android/settings/sim/SimDialogActivity.java +8 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.settings.sim; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.SubscriptionManager; Loading Loading @@ -54,6 +53,8 @@ public class SimDialogActivity extends FragmentActivity { public static final int PREFERRED_PICK = 3; // Show the "select SMS subscription" dialog, but don't save as default, just return a result public static final int SMS_PICK_FOR_MESSAGE = 4; // Dismiss the current dialog and finish the activity. public static final int PICK_DISMISS = 5; @Override protected void onCreate(Bundle savedInstanceState) { Loading @@ -70,6 +71,12 @@ public class SimDialogActivity extends FragmentActivity { private void showOrUpdateDialog() { final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK); if (dialogType == PICK_DISMISS) { finishAndRemoveTask(); return; } final String tag = Integer.toString(dialogType); final FragmentManager fragmentManager = getSupportFragmentManager(); SimDialogFragment fragment = (SimDialogFragment) fragmentManager.findFragmentByTag(tag); Loading
src/com/android/settings/sim/SimSelectNotification.java +18 −5 Original line number Diff line number Diff line Loading @@ -20,10 +20,10 @@ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS; import static android.provider.Settings.EXTRA_ENABLE_MMS_DATA_REQUEST_REASON; import static android.provider.Settings.EXTRA_SUB_ID; import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_NAMES; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE; Loading @@ -32,6 +32,9 @@ import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_T import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID; import static android.telephony.data.ApnSetting.TYPE_MMS; import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME; import static com.android.settings.sim.SimDialogActivity.PICK_DISMISS; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading @@ -51,7 +54,6 @@ import com.android.settings.HelpTrampoline; import com.android.settings.R; import com.android.settings.network.SubscriptionUtil; import com.android.settings.network.telephony.MobileNetworkActivity; import com.android.settingslib.HelpUtils; public class SimSelectNotification extends BroadcastReceiver { private static final String TAG = "SimSelectNotification"; Loading Loading @@ -159,6 +161,16 @@ public class SimSelectNotification extends BroadcastReceiver { // Cancel any previous notifications cancelSimSelectNotification(context); // If the dialog type is to dismiss. if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS) { Intent newIntent = new Intent(context, SimDialogActivity.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newIntent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, PICK_DISMISS); context.startActivity(newIntent); return; } // Create a notification to tell the user that some defaults are missing createSimSelectNotification(context); Loading Loading @@ -186,10 +198,11 @@ public class SimSelectNotification extends BroadcastReceiver { final int warningType = intent.getIntExtra(EXTRA_SIM_COMBINATION_WARNING_TYPE, EXTRA_SIM_COMBINATION_WARNING_TYPE_NONE); if (warningType == EXTRA_SIM_COMBINATION_WARNING_TYPE_DUAL_CDMA) { // Cancel any previous notifications cancelSimCombinationWarningNotification(context); // Create a notification to tell the user that some defaults are missing if (warningType == EXTRA_SIM_COMBINATION_WARNING_TYPE_DUAL_CDMA) { // Create a notification to tell the user that there's a sim combination warning. createSimCombinationWarningNotification(context, intent); } } Loading
tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java +51 −1 Original line number Diff line number Diff line Loading @@ -21,11 +21,17 @@ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_ import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS; import static android.provider.Settings.EXTRA_ENABLE_MMS_DATA_REQUEST_REASON; import static android.provider.Settings.EXTRA_SUB_ID; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA; import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_NAMES; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE; import static android.telephony.TelephonyManager.EXTRA_SIM_COMBINATION_WARNING_TYPE_DUAL_CDMA; import static android.telephony.data.ApnSetting.TYPE_MMS; import static com.android.settings.sim.SimDialogActivity.DATA_PICK; import static com.android.settings.sim.SimDialogActivity.INVALID_PICK; import static com.android.settings.sim.SimDialogActivity.PICK_DISMISS; import static com.android.settings.sim.SimSelectNotification.ENABLE_MMS_NOTIFICATION_CHANNEL; import static com.android.settings.sim.SimSelectNotification.ENABLE_MMS_NOTIFICATION_ID; import static com.android.settings.sim.SimSelectNotification.SIM_WARNING_NOTIFICATION_CHANNEL; Loading @@ -36,6 +42,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading @@ -54,7 +61,6 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.settings.R; import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; import org.junit.Before; Loading Loading @@ -196,6 +202,50 @@ public class SimSelectNotificationTest { verify(mNotificationManager, never()).createNotificationChannel(any()); } @Test public void onReceivePrimarySubListChange_WithDataPickExtra_shouldStartActivity() { Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED); intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA); mSimSelectNotification.onReceive(mContext, intent); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mContext).startActivity(intentCaptor.capture()); Intent capturedIntent = intentCaptor.getValue(); assertThat(capturedIntent).isNotNull(); assertThat(capturedIntent.getComponent().getClassName()).isEqualTo( SimDialogActivity.class.getName()); assertThat(capturedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) .isNotEqualTo(0); assertThat(capturedIntent.getIntExtra(SimDialogActivity.DIALOG_TYPE_KEY, INVALID_PICK)) .isEqualTo(DATA_PICK); } @Test public void onReceivePrimarySubListChange_WithDismissExtra_shouldDismiss() { Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED); intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA); mSimSelectNotification.onReceive(mContext, intent); clearInvocations(mContext); // Dismiss. intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE, EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS); mSimSelectNotification.onReceive(mContext, intent); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mContext).startActivity(intentCaptor.capture()); Intent capturedIntent = intentCaptor.getValue(); assertThat(capturedIntent).isNotNull(); assertThat(capturedIntent.getComponent().getClassName()).isEqualTo( SimDialogActivity.class.getName()); assertThat(capturedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) .isNotEqualTo(0); assertThat(capturedIntent.getIntExtra(SimDialogActivity.DIALOG_TYPE_KEY, INVALID_PICK)) .isEqualTo(PICK_DISMISS); } @Test public void onReceivePrimarySubListChange_DualCdmaWarning_notificationShouldSend() { Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED); Loading