Popup a notification after logging in the captive portal network
Captive portal app will be auto dismissed after user login the
captive portal network. In order to improve the user experience,
popup a notification to notify user that the captive portal
network is connected.
Bug: 113629026
Test: 1.atest FrameworksNetTests:NetworkNotificationManagerTest
2.Connect to a captive portal network and login, check if
there is a notification popup.
Change-Id: Id54d12268e107af2f213c2bb348c5f7908e880f4
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.server.connectivity;
|
||||
|
||||
import static com.android.server.connectivity.NetworkNotificationManager.NotificationType.*;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.eq;
|
||||
@@ -34,26 +35,24 @@ import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.server.connectivity.NetworkNotificationManager.NotificationType;
|
||||
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class NetworkNotificationManagerTest {
|
||||
@@ -194,4 +193,54 @@ public class NetworkNotificationManagerTest {
|
||||
mManager.clearNotification(id);
|
||||
verify(mNotificationManager, times(1)).cancelAsUser(eq(tag), eq(SIGN_IN.eventId), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameLevelNotifications() {
|
||||
final int id = 101;
|
||||
final String tag = NetworkNotificationManager.tagFor(id);
|
||||
|
||||
mManager.showNotification(id, LOGGED_IN, mWifiNai, mCellNai, null, false);
|
||||
verify(mNotificationManager, times(1))
|
||||
.notifyAsUser(eq(tag), eq(LOGGED_IN.eventId), any(), any());
|
||||
|
||||
mManager.showNotification(id, LOST_INTERNET, mWifiNai, mCellNai, null, false);
|
||||
verify(mNotificationManager, times(1))
|
||||
.notifyAsUser(eq(tag), eq(LOST_INTERNET.eventId), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearNotificationByType() {
|
||||
final int id = 101;
|
||||
final String tag = NetworkNotificationManager.tagFor(id);
|
||||
|
||||
// clearNotification(int id, NotificationType notifyType) will check if given type is equal
|
||||
// to previous type or not. If they are equal then clear the notification; if they are not
|
||||
// equal then return.
|
||||
|
||||
mManager.showNotification(id, LOGGED_IN, mWifiNai, mCellNai, null, false);
|
||||
verify(mNotificationManager, times(1))
|
||||
.notifyAsUser(eq(tag), eq(LOGGED_IN.eventId), any(), any());
|
||||
|
||||
// Previous notification is LOGGED_IN and given type is LOGGED_IN too. The notification
|
||||
// should be cleared.
|
||||
mManager.clearNotification(id, LOGGED_IN);
|
||||
verify(mNotificationManager, times(1))
|
||||
.cancelAsUser(eq(tag), eq(LOGGED_IN.eventId), any());
|
||||
|
||||
mManager.showNotification(id, LOGGED_IN, mWifiNai, mCellNai, null, false);
|
||||
verify(mNotificationManager, times(2))
|
||||
.notifyAsUser(eq(tag), eq(LOGGED_IN.eventId), any(), any());
|
||||
|
||||
// LOST_INTERNET notification popup after LOGGED_IN notification.
|
||||
mManager.showNotification(id, LOST_INTERNET, mWifiNai, mCellNai, null, false);
|
||||
verify(mNotificationManager, times(1))
|
||||
.notifyAsUser(eq(tag), eq(LOST_INTERNET.eventId), any(), any());
|
||||
|
||||
// Previous notification is LOST_INTERNET and given type is LOGGED_IN. The notification
|
||||
// shouldn't be cleared.
|
||||
mManager.clearNotification(id, LOGGED_IN);
|
||||
// LOST_INTERNET shouldn't be cleared.
|
||||
verify(mNotificationManager, never())
|
||||
.cancelAsUser(eq(tag), eq(LOST_INTERNET.eventId), any());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user