From 9fa8329b02d5db5c782ca815fd955ee7bceb5c86 Mon Sep 17 00:00:00 2001 From: Raff Tsai Date: Fri, 8 Mar 2019 16:19:30 +0800 Subject: [PATCH 1/7] Do not allow draw on top for App notification settings Fixes: 119115683 Test: manual Change-Id: Ib7b878a23b4a99171c58b5de992fb87feca8a28a Merged-In: Ib7b878a23b4a99171c58b5de992fb87feca8a28a (cherry picked from commit fe86a2a51f0b8e01e5f595bd60edc594eef58aba) --- .../notification/AppNotificationSettings.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index 99e94589cc5..bbfbe5ea86e 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -16,6 +16,8 @@ package com.android.settings.notification; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; + import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.content.Context; @@ -28,6 +30,8 @@ import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; import android.text.TextUtils; import android.util.Log; +import android.view.Window; +import android.view.WindowManager; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.widget.LockPatternUtils; @@ -81,6 +85,9 @@ public class AppNotificationSettings extends NotificationSettingsBase { public void onResume() { super.onResume(); + getActivity().getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); + android.util.EventLog.writeEvent(0x534e4554, "119115683", -1, ""); + if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) { Log.w(TAG, "Missing package or uid or packageinfo"); finish(); @@ -114,6 +121,15 @@ public class AppNotificationSettings extends NotificationSettingsBase { updatePreferenceStates(); } + @Override + public void onPause() { + super.onPause(); + final Window window = getActivity().getWindow(); + final WindowManager.LayoutParams attrs = window.getAttributes(); + attrs.privateFlags &= ~PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; + window.setAttributes(attrs); + } + @Override protected String getLogTag() { return TAG; From 3562c9744117b24b7ed4a9bbfe4b875436f2ba28 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 28 May 2019 10:38:55 -0400 Subject: [PATCH 2/7] Add snooze notification setting Test: atest Bug: 133494458 Change-Id: I3c0534860aaeb374384c4e30764313b1cb83c82a --- res/values/strings.xml | 3 + res/xml/configure_notification_settings.xml | 5 + ...noozeNotificationPreferenceController.java | 56 +++++++++ ...eNotificationPreferenceControllerTest.java | 109 ++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 src/com/android/settings/notification/SnoozeNotificationPreferenceController.java create mode 100644 tests/robotests/src/com/android/settings/notification/SnoozeNotificationPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 171fe42d2cd..b7090088bc3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7901,6 +7901,9 @@ Automatically show suggested actions & replies + + Allow notification snoozing + Hide icons from gentle notifications diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml index 224a9107414..63f67510490 100644 --- a/res/xml/configure_notification_settings.xml +++ b/res/xml/configure_notification_settings.xml @@ -79,6 +79,11 @@ android:order="15" settings:initialExpandedChildrenCount="0"> + + Date: Tue, 28 May 2019 15:03:23 -0700 Subject: [PATCH 3/7] Switch to using an intent for eSIM erasing We initially landed support for erasing an eSIM subscription in ag/7208624 for b/124254555 using our own confirmation/progress UI, and calling the EuiccManager.deleteSubscription method to do the deletion. It turns out this is a low-level API which doesn't handle some important cases such as subscription grouping or the eSIM slot not being active. This CL changes Settings to just launch an intent to begin an eSIM Manager flow to delete a subscription that provides its own confirmation/progress UI, and should properly handle subscription grouping and making the eSIM slot active as needed. Bug: 132114333 Test: make RunSettingsRoboTests Change-Id: Ie59fea37fa73c5e6573e1181e271ffb5d453bd08 --- AndroidManifest.xml | 2 - .../DeleteSimProfileConfirmationDialog.java | 83 ----------- .../DeleteSimProfilePreferenceController.java | 15 +- .../DeleteSimProfileProgressDialog.java | 120 --------------- .../telephony/MobileNetworkSettings.java | 11 +- ...eleteSimProfileConfirmationDialogTest.java | 79 ---------- ...eteSimProfilePreferenceControllerTest.java | 30 +++- .../DeleteSimProfileProgressDialogTest.java | 139 ------------------ .../telephony/MobileNetworkSettingsTest.java | 17 +++ 9 files changed, 61 insertions(+), 435 deletions(-) delete mode 100644 src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialog.java delete mode 100644 src/com/android/settings/network/telephony/DeleteSimProfileProgressDialog.java delete mode 100644 tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialogTest.java delete mode 100644 tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialogTest.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f4ff282238c..fc3888b8df7 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -102,8 +102,6 @@ - - { - final DeleteSimProfileConfirmationDialog dialogFragment = - DeleteSimProfileConfirmationDialog.newInstance(mSubscriptionInfo); - dialogFragment.setTargetFragment(mParentFragment, 0); - dialogFragment.show(mParentFragment.getFragmentManager(), - DeleteSimProfileConfirmationDialog.TAG); + final Intent intent = new Intent(EuiccManager.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED); + intent.putExtra(EuiccManager.EXTRA_SUBSCRIPTION_ID, + mSubscriptionInfo.getSubscriptionId()); + mParentFragment.startActivityForResult(intent, mRequestCode); return true; }); } diff --git a/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialog.java b/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialog.java deleted file mode 100644 index c176f3cc911..00000000000 --- a/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialog.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2019 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.settings.network.telephony; - -import android.app.Activity; -import android.app.Dialog; -import android.app.PendingIntent; -import android.app.ProgressDialog; -import android.app.settings.SettingsEnums; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.telephony.euicc.EuiccManager; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; - -import com.android.settings.R; -import com.android.settings.core.instrumentation.InstrumentedDialogFragment; - -public class DeleteSimProfileProgressDialog extends InstrumentedDialogFragment { - public static final String TAG = "delete_sim_progress"; - - // Note that this must be listed in AndroidManfiest.xml in a tag - @VisibleForTesting - static final String PENDING_INTENT = - "com.android.settings.DELETE_SIM_PROFILE_RESULT"; - private static final int PENDING_INTENT_REQUEST_CODE = 1; - private static final String KEY_SUBSCRIPTION_ID = "subscription_id"; - @VisibleForTesting - static final String KEY_DELETE_STARTED = "delete_started"; - - private boolean mDeleteStarted; - private BroadcastReceiver mReceiver; - - public static DeleteSimProfileProgressDialog newInstance(int subscriptionId) { - final DeleteSimProfileProgressDialog dialog = new DeleteSimProfileProgressDialog(); - final Bundle args = new Bundle(); - args.putInt(KEY_SUBSCRIPTION_ID, subscriptionId); - dialog.setArguments(args); - return dialog; - } - - @Override - public void onSaveInstanceState(@NonNull Bundle outState) { - super.onSaveInstanceState(outState); - outState.putBoolean(KEY_DELETE_STARTED, mDeleteStarted); - } - - @NonNull - @Override - public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { - if (savedInstanceState != null) { - mDeleteStarted = savedInstanceState.getBoolean(KEY_DELETE_STARTED, false); - } - final Context context = getContext(); - final ProgressDialog progressDialog = new ProgressDialog(context); - progressDialog.setMessage( - context.getString(R.string.mobile_network_erase_sim_dialog_progress)); - - mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - dismiss(); - final Activity activity = getActivity(); - if (activity != null && !activity.isFinishing()) { - activity.finish(); - } - } - }; - context.registerReceiver(mReceiver, new IntentFilter(PENDING_INTENT)); - - if (!mDeleteStarted) { - final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, - PENDING_INTENT_REQUEST_CODE, new Intent(PENDING_INTENT), - PendingIntent.FLAG_ONE_SHOT); - - final EuiccManager euiccManager = context.getSystemService(EuiccManager.class); - final int subId = getArguments().getInt(KEY_SUBSCRIPTION_ID); - euiccManager.deleteSubscription(subId, pendingIntent); - mDeleteStarted = true; - } - - return progressDialog; - } - - @Override - public void onDismiss(@NonNull DialogInterface dialog) { - if (mReceiver != null) { - final Context context = getContext(); - if (context != null) { - context.unregisterReceiver(mReceiver); - } - mReceiver = null; - } - } - - @Override - public int getMetricsCategory() { - return SettingsEnums.DIALOG_DELETE_SIM_PROGRESS; - } -} diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java index e18971d43d6..f8e5c3a518f 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java +++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java @@ -61,6 +61,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { private static final String LOG_TAG = "NetworkSettings"; public static final int REQUEST_CODE_EXIT_ECM = 17; + public static final int REQUEST_CODE_DELETE_SUBSCRIPTION = 18; @VisibleForTesting static final String KEY_CLICKED_PREF = "key_clicked_pref"; @@ -138,7 +139,8 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { use(BillingCyclePreferenceController.class).init(mSubId); use(MmsMessagePreferenceController.class).init(mSubId); use(DisabledSubscriptionController.class).init(getLifecycle(), mSubId); - use(DeleteSimProfilePreferenceController.class).init(mSubId, this); + use(DeleteSimProfilePreferenceController.class).init(mSubId, this, + REQUEST_CODE_DELETE_SUBSCRIPTION); } use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId); use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId); @@ -226,6 +228,13 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment { } break; + case REQUEST_CODE_DELETE_SUBSCRIPTION: + final Activity activity = getActivity(); + if (activity != null && !activity.isFinishing()) { + activity.finish(); + } + break; + default: break; } diff --git a/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialogTest.java b/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialogTest.java deleted file mode 100644 index 9b6f5511e0d..00000000000 --- a/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileConfirmationDialogTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2019 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.settings.network.telephony; - -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - -import android.app.Activity; -import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; -import android.telephony.SubscriptionInfo; - -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.FragmentActivity; - -import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.androidx.fragment.FragmentController; - -@RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowAlertDialogCompat.class) -public class DeleteSimProfileConfirmationDialogTest { - @Mock - private SubscriptionInfo mSubscriptionInfo; - - private DeleteSimProfileConfirmationDialog mDialogFragment; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - mDialogFragment = spy(DeleteSimProfileConfirmationDialog.newInstance(mSubscriptionInfo)); - doNothing().when(mDialogFragment).beginDeletionWithProgress(); - } - - @Test - public void showDialog_dialogCancelled_deleteNotCalled() { - FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, - 0 /* containerViewId */, - null /* bundle */); - final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick(); - verify(mDialogFragment, never()).beginDeletionWithProgress(); - } - - @Test - public void showDialog_dialogOk_deleteWasCalled() { - FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, - 0 /* containerViewId */, - null /* bundle */); - final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); - verify(mDialogFragment).beginDeletionWithProgress(); - } -} diff --git a/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfilePreferenceControllerTest.java index 21fd19bf50b..ca8fcf80fc4 100644 --- a/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfilePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfilePreferenceControllerTest.java @@ -18,11 +18,15 @@ package com.android.settings.network.telephony; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; +import android.content.Intent; import android.telephony.SubscriptionInfo; +import android.telephony.SubscriptionManager; import android.telephony.euicc.EuiccManager; import androidx.fragment.app.Fragment; @@ -35,6 +39,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; @@ -46,12 +51,12 @@ import java.util.Arrays; @RunWith(RobolectricTestRunner.class) public class DeleteSimProfilePreferenceControllerTest { private static final String PREF_KEY = "delete_profile_key"; + private static final int REQUEST_CODE = 4321; private static final int SUB_ID = 1234; private static final int OTHER_ID = 5678; @Mock private Fragment mFragment; - @Mock private SubscriptionInfo mSubscriptionInfo; @Mock @@ -85,27 +90,42 @@ public class DeleteSimProfilePreferenceControllerTest { @Test public void getAvailabilityStatus_noSubs_notAvailable() { SubscriptionUtil.setAvailableSubscriptionsForTesting(new ArrayList<>()); - mController.init(SUB_ID, mFragment); + mController.init(SUB_ID, mFragment, REQUEST_CODE); assertThat(mController.isAvailable()).isFalse(); } @Test public void getAvailabilityStatus_physicalSim_notAvailable() { when(mSubscriptionInfo.isEmbedded()).thenReturn(false); - mController.init(SUB_ID, mFragment); + mController.init(SUB_ID, mFragment, REQUEST_CODE); assertThat(mController.isAvailable()).isFalse(); } @Test public void getAvailabilityStatus_unknownSim_notAvailable() { when(mSubscriptionInfo.getSubscriptionId()).thenReturn(OTHER_ID); - mController.init(SUB_ID, mFragment); + mController.init(SUB_ID, mFragment, REQUEST_CODE); assertThat(mController.isAvailable()).isFalse(); } @Test public void getAvailabilityStatus_knownEsim_isAvailable() { - mController.init(SUB_ID, mFragment); + mController.init(SUB_ID, mFragment, REQUEST_CODE); assertThat(mController.isAvailable()).isTrue(); } + + @Test + public void onPreferenceClick_startsIntent() { + mController.init(SUB_ID, mFragment, REQUEST_CODE); + mController.displayPreference(mScreen); + mPreference.performClick(); + + final ArgumentCaptor intentCaptor = ArgumentCaptor.forClass(Intent.class); + verify(mFragment).startActivityForResult(intentCaptor.capture(), eq(REQUEST_CODE)); + final Intent intent = intentCaptor.getValue(); + assertThat(intent.getAction()).isEqualTo( + EuiccManager.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED); + assertThat(intent.getIntExtra(EuiccManager.EXTRA_SUBSCRIPTION_ID, + SubscriptionManager.INVALID_SUBSCRIPTION_ID)).isEqualTo(SUB_ID); + } } diff --git a/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialogTest.java b/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialogTest.java deleted file mode 100644 index aebcc461ea2..00000000000 --- a/tests/robotests/src/com/android/settings/network/telephony/DeleteSimProfileProgressDialogTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2019 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.settings.network.telephony; - -import static com.android.settings.network.telephony.DeleteSimProfileProgressDialog.KEY_DELETE_STARTED; -import static com.android.settings.network.telephony.DeleteSimProfileProgressDialog.PENDING_INTENT; - -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.ArgumentMatchers.notNull; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.app.Dialog; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.telephony.euicc.EuiccManager; - -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; - -import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -@RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowAlertDialogCompat.class) -public class DeleteSimProfileProgressDialogTest { - private static final int SUB_ID = 111; - - @Mock - private FragmentActivity mActivity; - @Mock - private Fragment mTargetFragment; - @Mock - private EuiccManager mEuiccManager; - - private Context mContext; - private DeleteSimProfileProgressDialog mDialogFragment; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - mContext = spy(RuntimeEnvironment.application); - - when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager); - mDialogFragment = spy(DeleteSimProfileProgressDialog.newInstance(SUB_ID)); - when(mDialogFragment.getContext()).thenReturn(mContext); - when(mDialogFragment.getTargetFragment()).thenReturn(mTargetFragment); - when(mDialogFragment.getActivity()).thenReturn(mActivity); - } - - @Test - public void onCreateDialog_firstShowing_deleteStartedAndRecordedInOutState() { - mDialogFragment.onCreateDialog(null); - verify(mEuiccManager).deleteSubscription(eq(SUB_ID), notNull()); - - final Bundle outState = new Bundle(); - mDialogFragment.onSaveInstanceState(outState); - assertThat(outState.containsKey(KEY_DELETE_STARTED)).isTrue(); - assertThat(outState.getBoolean(KEY_DELETE_STARTED)).isTrue(); - } - - @Test - public void showDialog_secondShowing_deleteNotStarted() { - final Bundle inState = new Bundle(); - inState.putBoolean(KEY_DELETE_STARTED, true); - mDialogFragment.onCreateDialog(inState); - - verify(mEuiccManager, never()).deleteSubscription(anyInt(), any()); - - final Bundle outState = new Bundle(); - mDialogFragment.onSaveInstanceState(outState); - assertThat(outState.containsKey(KEY_DELETE_STARTED)).isTrue(); - assertThat(outState.getBoolean(KEY_DELETE_STARTED)).isTrue(); - } - - @Test - public void showDialog_pendingIntentReceiverFired_activityFinished() { - mDialogFragment.onCreateDialog(null); - - final ArgumentCaptor intentCaptor = ArgumentCaptor.forClass( - PendingIntent.class); - verify(mEuiccManager).deleteSubscription(eq(SUB_ID), intentCaptor.capture()); - assertThat(intentCaptor.getValue()).isNotNull(); - - final ArgumentCaptor receiverCaptor = ArgumentCaptor.forClass( - BroadcastReceiver.class); - verify(mContext).registerReceiver(receiverCaptor.capture(), any(IntentFilter.class)); - - doNothing().when(mDialogFragment).dismiss(); - receiverCaptor.getValue().onReceive(mContext, new Intent(PENDING_INTENT)); - verify(mDialogFragment).dismiss(); - verify(mActivity).finish(); - } - - @Test - public void onDismiss_receiverUnregistered() { - Dialog dialog = mDialogFragment.onCreateDialog(null); - final ArgumentCaptor receiverCaptor = ArgumentCaptor.forClass( - BroadcastReceiver.class); - verify(mContext).registerReceiver(receiverCaptor.capture(), any(IntentFilter.class)); - - mDialogFragment.onDismiss(dialog); - verify(mContext).unregisterReceiver(eq(receiverCaptor.getValue())); - } -} diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java index 011bca5733e..a999a9ee1cf 100644 --- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java +++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java @@ -16,11 +16,14 @@ package com.android.settings.network.telephony; +import static com.android.settings.network.telephony.MobileNetworkSettings.REQUEST_CODE_DELETE_SUBSCRIPTION; + import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.usage.NetworkStatsManager; @@ -80,6 +83,7 @@ public class MobileNetworkSettingsTest { args.putInt(Settings.EXTRA_SUB_ID, subscriptionId); mFragment.setArguments(args); when(mFragment.getActivity()).thenReturn(mActivity); + when(mActivity.isFinishing()).thenReturn(false); when(mActivity.getSystemService(NetworkPolicyManager.class)).thenReturn( mNetworkPolicyManager); } @@ -118,4 +122,17 @@ public class MobileNetworkSettingsTest { .count()) .isEqualTo(1); } + + @Test + public void onActivityResult_noActivity_noCrash() { + when(mFragment.getActivity()).thenReturn(null); + // this should not crash + mFragment.onActivityResult(REQUEST_CODE_DELETE_SUBSCRIPTION, 0, null); + } + + @Test + public void onActivityResult_deleteSubscription_activityFinishes() { + mFragment.onActivityResult(REQUEST_CODE_DELETE_SUBSCRIPTION, 0, null); + verify(mActivity).finish(); + } } From e0285703b21c4e51ee6c5e4a38e76cccd20cdd14 Mon Sep 17 00:00:00 2001 From: Amit Mahajan Date: Tue, 28 May 2019 16:03:55 -0700 Subject: [PATCH 4/7] Allow renaming inactive subscriptions. Test: manual Bug: 132922483 Change-Id: I30b4b88ddf53b917081a57bd9a917a51b4b44ec6 --- .../telephony/RenameMobileNetworkDialogFragment.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java index f7e7de58f0d..82554c2eca7 100644 --- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java +++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java @@ -95,13 +95,9 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen builder.setTitle(R.string.mobile_network_sim_name) .setView(view) .setPositiveButton(R.string.mobile_network_sim_name_rename, (dialog, which) -> { - SubscriptionInfo currentInfo = mSubscriptionManager.getActiveSubscriptionInfo( - mSubId); String newName = mNameView.getText().toString(); - if (currentInfo != null && !currentInfo.getDisplayName().equals(newName)) { - mSubscriptionManager.setDisplayName(newName, mSubId, - SubscriptionManager.NAME_SOURCE_USER_INPUT); - } + mSubscriptionManager.setDisplayName(newName, mSubId, + SubscriptionManager.NAME_SOURCE_USER_INPUT); }) .setNegativeButton(android.R.string.cancel, null); return builder.create(); From a5bbb26dfeb25cd600ddf37b65bed121272781f9 Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Wed, 29 May 2019 11:13:09 +0800 Subject: [PATCH 5/7] Add EID as a synonym to SIM status We can't use EID as keyword to search for it because EID info is located in the SIM status dialog in which it's not searchable. EID is added as a synonym of SIM status to support its search result. Fixes: 133801685 Test: Settings > Search settings > type "eid" then will show "SIM status" search result Change-Id: I03b49bf6f2951c468440f635d7b211266bb00d83 --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 171fe42d2cd..6688f461d15 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7335,7 +7335,7 @@ gesture face, unlock, auth, sign in imei, meid, min, prl version, imei sv - network, mobile network state, service state, signal strength, mobile network type, roaming, iccid + network, mobile network state, service state, signal strength, mobile network type, roaming, iccid, eid serial number, hardware version android security patch level, baseband version, kernel version From 685d247730c6b2907ef63a252cc5920d6c17dff8 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Wed, 29 May 2019 08:27:43 +0000 Subject: [PATCH 6/7] Revert "Tweak title for "App content"" This reverts commit a00e725b0aae876ca44ce6c20271405992e1c33b. Reason for revert: The string change only for Google Settings instead of AOSP. Test: visual Bug: 133370964 Change-Id: Ib21bff1abc2fd169f957f10154914f85c71d22d1 --- res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 2e505ab4dd2..49ac4cce010 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11216,11 +11216,11 @@ You may lose access to any remaining time or data. Check with your provider before removing. - content capture, app content, app data + content capture, app content - Personalize using app data + App content - Allow apps to send content to the Android system. Tap to learn more. + Allow apps to send content to the Android system Capture system heap dump From b18ec1958a0d3cdaa05406d8c92491927639b4ff Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Wed, 29 May 2019 13:19:37 -0400 Subject: [PATCH 7/7] Change title to "Alerting" Test: visual Fixes: 133825282 Change-Id: I08c58328eafdc37ba993d5189c8830e2c00115e6 --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 2e505ab4dd2..465e8d8b6ca 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -8101,7 +8101,7 @@ Silent - Prioritized + Alerting Allow interruptions