From b25c9a6cb3a20c79d99c8131ab5613ba065d5454 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Tue, 12 Feb 2019 15:30:13 +0800 Subject: [PATCH] Clear all lingering notifications when network is disconnected In aosp/861571, it tried to refine the design to prevent the lingering notification is cleared unexpectedly. However, all notifications should be cleared when network is disconnected. Refine the design by clearing all lingering notifications when network is disconnected. Bug: 123488640 Bug: 123537643 Test: 1.Build pass 2.atest FrameworksNetTests 3.Connect to a hotspot which doesn't have internet, after getting "NO_INTERNET" notification, disconnect the wifi and check if "NO_INTERNET" notification will be cleared or not. Change-Id: Iac45ec186cf81915c318dba37f43136609d579f6 --- services/core/java/com/android/server/ConnectivityService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index af2bbfbb1d..9b4cd23042 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -2832,6 +2832,8 @@ public class ConnectivityService extends IConnectivityManager.Stub if (DBG) { log(nai.name() + " got DISCONNECTED, was satisfying " + nai.numNetworkRequests()); } + // Clear all notifications of this network. + mNotifier.clearNotification(nai.network.netId); // A network agent has disconnected. // TODO - if we move the logic to the network agent (have them disconnect // because they lost all their requests or because their score isn't good)