From 1e087ac4a87f2aa51d280252aec7c79b029e3c8d Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Thu, 13 Jun 2019 14:11:49 +0800 Subject: [PATCH] Suppress the wtf log for notifications that are expected PARTIAL and NO_INTERNET may happen in the real world for those transport types that provide internet. These two notification types should be reasonable notificaitons, not a terrible failure as the log. For Q, it may be too risky to display more notifications with other information instead of SSID. Thus, suppress the wtf log for these two notifications. Bug: 135043192 Test: atest FrameworksNetTests Change-Id: I35f3718fa93b403858587d918f0bc596f6c92f3e --- .../NetworkNotificationManager.java | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java index f6735d9834661..bcf5a71344b06 100644 --- a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java +++ b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java @@ -178,15 +178,31 @@ public class NetworkNotificationManager { CharSequence title; CharSequence details; int icon = getIcon(transportType, notifyType); - if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) { - title = r.getString(R.string.wifi_no_internet, - WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID())); - details = r.getString(R.string.wifi_no_internet_detailed); - } else if (notifyType == NotificationType.PARTIAL_CONNECTIVITY - && transportType == TRANSPORT_WIFI) { - title = r.getString(R.string.network_partial_connectivity, - WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID())); - details = r.getString(R.string.network_partial_connectivity_detailed); + if (notifyType == NotificationType.NO_INTERNET) { + switch (transportType) { + case TRANSPORT_WIFI: + title = r.getString(R.string.wifi_no_internet, + WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID())); + details = r.getString(R.string.wifi_no_internet_detailed); + break; + default: + // TODO: Display notifications for those networks that provide internet. + // except VPN. + return; + } + + } else if (notifyType == NotificationType.PARTIAL_CONNECTIVITY) { + switch (transportType) { + case TRANSPORT_WIFI: + title = r.getString(R.string.network_partial_connectivity, + WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID())); + details = r.getString(R.string.network_partial_connectivity_detailed); + break; + default: + // TODO: Display notifications for those networks that provide internet. + // except VPN. + return; + } } else if (notifyType == NotificationType.LOST_INTERNET && transportType == TRANSPORT_WIFI) { title = r.getString(R.string.wifi_no_internet,