diff options
author | Stephen Chen <stewchen@google.com> | 2017-01-12 22:11:57 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-01-12 22:11:57 +0000 |
commit | 6d5c1366f07af4859b72272775a4bdf0c342e617 (patch) | |
tree | 9777ceac2d190f59784e5bcbc43323a5ab6f7ce1 | |
parent | 534074986a68b197f3c4f3fb881102f1fb99f3d0 (diff) | |
parent | e14eb36c16d8ad6b6617a6b1d9c7560d07221f04 (diff) | |
download | NetworkRecommendation-6d5c1366f07af4859b72272775a4bdf0c342e617.tar.gz |
Make sure notifications work when score is provided but no badging.
am: e14eb36c16
Change-Id: I168d7592b2963716bb9817b9f8570252b314dbe5
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_0_bars.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_1_bar.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_2_bars.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_3_bars.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_4_bars.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_4k.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_hd.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_ld.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_badged_sd.xml | 2 | ||||
-rw-r--r-- | res/drawable/ic_signal_wifi_no_network.xml | 2 | ||||
-rw-r--r-- | res/drawable/stat_notify_wifi_in_range.xml | 2 | ||||
-rw-r--r-- | src/com/android/networkrecommendation/WifiNotificationHelper.java | 3 | ||||
-rw-r--r-- | tests/src/com/android/networkrecommendation/WifiNotificationControllerTest.java | 24 |
13 files changed, 22 insertions, 27 deletions
diff --git a/res/drawable/ic_signal_wifi_badged_0_bars.xml b/res/drawable/ic_signal_wifi_badged_0_bars.xml index bd1eb41..e458378 100644 --- a/res/drawable/ic_signal_wifi_badged_0_bars.xml +++ b/res/drawable/ic_signal_wifi_badged_0_bars.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_1_bar.xml b/res/drawable/ic_signal_wifi_badged_1_bar.xml index aedb12c..1fc239e 100644 --- a/res/drawable/ic_signal_wifi_badged_1_bar.xml +++ b/res/drawable/ic_signal_wifi_badged_1_bar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_2_bars.xml b/res/drawable/ic_signal_wifi_badged_2_bars.xml index 6f07cb5..d388365 100644 --- a/res/drawable/ic_signal_wifi_badged_2_bars.xml +++ b/res/drawable/ic_signal_wifi_badged_2_bars.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_3_bars.xml b/res/drawable/ic_signal_wifi_badged_3_bars.xml index c41a8ca..c64cb72 100644 --- a/res/drawable/ic_signal_wifi_badged_3_bars.xml +++ b/res/drawable/ic_signal_wifi_badged_3_bars.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_4_bars.xml b/res/drawable/ic_signal_wifi_badged_4_bars.xml index ec0a52f..de56b4c 100644 --- a/res/drawable/ic_signal_wifi_badged_4_bars.xml +++ b/res/drawable/ic_signal_wifi_badged_4_bars.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_4k.xml b/res/drawable/ic_signal_wifi_badged_4k.xml index 78bd0a0..2a94891 100644 --- a/res/drawable/ic_signal_wifi_badged_4k.xml +++ b/res/drawable/ic_signal_wifi_badged_4k.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_hd.xml b/res/drawable/ic_signal_wifi_badged_hd.xml index 78085c2..d8cf77b 100644 --- a/res/drawable/ic_signal_wifi_badged_hd.xml +++ b/res/drawable/ic_signal_wifi_badged_hd.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_ld.xml b/res/drawable/ic_signal_wifi_badged_ld.xml index f660ab7..41576d7 100644 --- a/res/drawable/ic_signal_wifi_badged_ld.xml +++ b/res/drawable/ic_signal_wifi_badged_ld.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_badged_sd.xml b/res/drawable/ic_signal_wifi_badged_sd.xml index 43b8653..72658b1 100644 --- a/res/drawable/ic_signal_wifi_badged_sd.xml +++ b/res/drawable/ic_signal_wifi_badged_sd.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2017 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. diff --git a/res/drawable/ic_signal_wifi_no_network.xml b/res/drawable/ic_signal_wifi_no_network.xml index 0e677f6..75375a3 100644 --- a/res/drawable/ic_signal_wifi_no_network.xml +++ b/res/drawable/ic_signal_wifi_no_network.xml @@ -1,5 +1,5 @@ <!-- -Copyright (C) 2014 The Android Open Source Project +Copyright (C) 2017 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. diff --git a/res/drawable/stat_notify_wifi_in_range.xml b/res/drawable/stat_notify_wifi_in_range.xml index a271ca5..c2af105 100644 --- a/res/drawable/stat_notify_wifi_in_range.xml +++ b/res/drawable/stat_notify_wifi_in_range.xml @@ -1,5 +1,5 @@ <!-- -Copyright (C) 2014 The Android Open Source Project +Copyright (C) 2017 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. diff --git a/src/com/android/networkrecommendation/WifiNotificationHelper.java b/src/com/android/networkrecommendation/WifiNotificationHelper.java index 0bf4cb8..e4c8c4e 100644 --- a/src/com/android/networkrecommendation/WifiNotificationHelper.java +++ b/src/com/android/networkrecommendation/WifiNotificationHelper.java @@ -207,6 +207,9 @@ public class WifiNotificationHelper { } private Bitmap getBadgedWifiBitmap(int badgeEnum, int rssi) { + if (badgeEnum == ScoredNetwork.BADGING_NONE) { + return null; + } int signalLevel = WifiManager.calculateSignalLevel(rssi, 5); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{ mContext.getDrawable(WIFI_PIE_FOR_BADGING[signalLevel]), diff --git a/tests/src/com/android/networkrecommendation/WifiNotificationControllerTest.java b/tests/src/com/android/networkrecommendation/WifiNotificationControllerTest.java index 83fb850..a8ef979 100644 --- a/tests/src/com/android/networkrecommendation/WifiNotificationControllerTest.java +++ b/tests/src/com/android/networkrecommendation/WifiNotificationControllerTest.java @@ -160,8 +160,7 @@ public class WifiNotificationControllerTest { TestUtil.sendScanResultsAvailable(mBroadcastReceiver, mContext); TestUtil.sendScanResultsAvailable(mBroadcastReceiver, mContext); verify(mNotificationManager, never()) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); // Changing to and from "SCANNING" state should not affect the counter. TestUtil.sendNetworkStateChanged(mBroadcastReceiver, mContext, @@ -169,15 +168,13 @@ public class WifiNotificationControllerTest { TestUtil.sendNetworkStateChanged(mBroadcastReceiver, mContext, NetworkInfo.DetailedState.DISCONNECTED); verify(mNotificationManager, never()) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); // The third scan result notification will trigger the notification. TestUtil.sendScanResultsAvailable(mBroadcastReceiver, mContext); verify(mWifiNotificationHelper).createMainNotification(any(WifiConfiguration.class), any(Bitmap.class)); verify(mNotificationManager) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); verify(mNotificationManager, never()) .cancelAsUser(any(String.class), anyInt(), any(UserHandle.class)); } @@ -200,16 +197,14 @@ public class WifiNotificationControllerTest { TestUtil.sendScanResultsAvailable(mBroadcastReceiver, mContext); TestUtil.sendScanResultsAvailable(mBroadcastReceiver, mContext); verify(mNotificationManager, never()) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); // DoNotConnect Recommendation result. when(mNetworkRecommendationProvider.requestRecommendation(any(RecommendationRequest.class))) .thenReturn(RecommendationResult.createDoNotConnectRecommendation()); TestUtil.sendScanResultsAvailable(mBroadcastReceiver, mContext); verify(mNotificationManager, never()) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); } /** @@ -233,8 +228,7 @@ public class WifiNotificationControllerTest { verify(mWifiNotificationHelper).createMainNotification(any(WifiConfiguration.class), any(Bitmap.class)); verify(mNotificationManager) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); // Send connect intent, should attempt to connect to Wi-Fi Intent intent = new Intent( @@ -246,8 +240,7 @@ public class WifiNotificationControllerTest { // Show connecting notification. verify(mNotificationManager, times(2)) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); // Verify callback to dismiss connecting notification exists. assertTrue(mHandler.hasCallbacks( mWifiNotificationController.mShowFailedToConnectNotificationRunnable)); @@ -258,8 +251,7 @@ public class WifiNotificationControllerTest { verify(mWifiNotificationHelper).createConnectedNotification(any(WifiConfiguration.class), any(Bitmap.class)); verify(mNotificationManager, times(3)) - .notifyAsUser(any(String.class), anyInt(), any(Notification.class), - any(UserHandle.class)); + .notify(any(String.class), anyInt(), any(Notification.class)); // Verify callback to dismiss connected notification exists. assertTrue(mHandler.hasCallbacks( |