summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-07-21 17:19:53 -0700
committerNate Jiang <qiangjiang@google.com>2020-07-24 22:49:28 +0000
commit861ad6f20d3a060aa4337138b256b8f56881a07e (patch)
tree364962be5002dfbbfa46113c329974ed2515ee05 /tests
parentae80e463faa006cfe1451a2941da67bc34fd7b0b (diff)
Update IMSI protection notification flow
Bug: 161932419 Test: atest com.android.server.wifi Merged-In: I8be7c1b9e66162fdd244946b47367290116a7747 Change-Id: I8be7c1b9e66162fdd244946b47367290116a7747
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java75
1 files changed, 50 insertions, 25 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
index 2c1c2ec91..750e8d46b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
@@ -19,6 +19,7 @@ package com.android.server.wifi;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION;
+import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_CLICKED_INTENT_ACTION;
import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION;
import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_DISMISSED_INTENT_ACTION;
@@ -166,6 +167,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
when(mNotificationBuilder.setTicker(any())).thenReturn(mNotificationBuilder);
when(mNotificationBuilder.setContentTitle(any())).thenReturn(mNotificationBuilder);
when(mNotificationBuilder.setStyle(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setContentIntent(any())).thenReturn(mNotificationBuilder);
when(mNotificationBuilder.setDeleteIntent(any())).thenReturn(mNotificationBuilder);
when(mNotificationBuilder.setShowWhen(anyBoolean())).thenReturn(mNotificationBuilder);
when(mNotificationBuilder.setLocalOnly(anyBoolean())).thenReturn(mNotificationBuilder);
@@ -1538,26 +1540,13 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
- validateUserApprovalDialog(CARRIER_NAME);
-
- // Simulate user clicking on allow in the dialog.
- ArgumentCaptor<DialogInterface.OnClickListener> clickListenerCaptor =
- ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
- verify(mAlertDialogBuilder, atLeastOnce()).setPositiveButton(
- any(), clickListenerCaptor.capture());
- assertNotNull(clickListenerCaptor.getValue());
- clickListenerCaptor.getValue().onClick(mAlertDialog, 0);
- mLooper.dispatchAll();
- ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mContext).sendBroadcast(intentCaptor.capture());
- assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
verify(mWifiConfigManager).saveToStore(true);
assertTrue(mImsiDataSource.hasNewDataToSerialize());
assertTrue(mWifiCarrierInfoManager
.hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
verify(mListener).onUserAllowed(DATA_CARRIER_ID);
verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
- WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, true);
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
}
@Test
@@ -1607,7 +1596,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
validateImsiProtectionNotification(CARRIER_NAME);
//Simulate user dismissal the notification
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
- CARRIER_NAME, DATA_SUBID);
+ CARRIER_NAME, DATA_CARRIER_ID);
verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
WifiCarrierInfoManager.ACTION_USER_DISMISS, false);
reset(mNotificationManger);
@@ -1618,7 +1607,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
// As there is notification is active, should not send notification again.
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
- CARRIER_NAME, DATA_SUBID);
+ CARRIER_NAME, DATA_CARRIER_ID);
verifyNoMoreInteractions(mNotificationManger);
verify(mWifiConfigManager, never()).saveToStore(true);
assertFalse(mImsiDataSource.hasNewDataToSerialize());
@@ -1642,12 +1631,10 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
validateImsiProtectionNotification(CARRIER_NAME);
- // Simulate user clicking on allow in the notification.
- sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
- CARRIER_NAME, DATA_SUBID);
+ // Simulate user clicking on the notification.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_CLICKED_INTENT_ACTION,
+ CARRIER_NAME, DATA_CARRIER_ID);
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
- verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
- WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
validateUserApprovalDialog(CARRIER_NAME);
// Simulate user clicking on disallow in the dialog.
@@ -1685,11 +1672,10 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
validateImsiProtectionNotification(CARRIER_NAME);
- sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
- CARRIER_NAME, DATA_SUBID);
+ // Simulate user clicking on the notification.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_CLICKED_INTENT_ACTION,
+ CARRIER_NAME, DATA_CARRIER_ID);
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
- verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
- WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
validateUserApprovalDialog(CARRIER_NAME);
// Simulate user clicking on dismissal in the dialog.
@@ -1718,6 +1704,45 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
}
@Test
+ public void testSendImsiProtectionExemptionDialogWithUserAllowed() {
+ // Setup carrier without IMSI privacy protection
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ // Simulate user clicking on the notification.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_CLICKED_INTENT_ACTION,
+ CARRIER_NAME, DATA_CARRIER_ID);
+ verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ validateUserApprovalDialog(CARRIER_NAME);
+
+ // Simulate user clicking on allow in the dialog.
+ ArgumentCaptor<DialogInterface.OnClickListener> clickListenerCaptor =
+ ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
+ verify(mAlertDialogBuilder, atLeastOnce()).setPositiveButton(
+ any(), clickListenerCaptor.capture());
+ assertNotNull(clickListenerCaptor.getValue());
+ clickListenerCaptor.getValue().onClick(mAlertDialog, 0);
+ mLooper.dispatchAll();
+ ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcast(intentCaptor.capture());
+ assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
+ verify(mWifiConfigManager).saveToStore(true);
+ assertTrue(mImsiDataSource.hasNewDataToSerialize());
+ verify(mListener).onUserAllowed(DATA_CARRIER_ID);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, true);
+ }
+
+ @Test
public void testUserDataStoreIsNotLoadedNotificationWillNotBeSent() {
// reset data source to unloaded state.
mImsiDataSource.reset();