From 42f8a914cfca03312f75742ee34391890729025c Mon Sep 17 00:00:00 2001 From: lucaslin Date: Mon, 2 Nov 2020 11:53:16 +0800 Subject: [PATCH 1/2] Use local defined constants for notification channels ConnectivityService mainline module cannot call the members inside SystemNotificationChannels.java. So use the local defined constants instead. Bug: 172040168 Test: atest FrameworksNetTests Test: Manual test NO_INTERNET, SIGN_IN, PARTIAL_CONNECTIVITY, VPN_ALWAYS_ON notifications. Change-Id: I223b207c4346e8239dee78e50dd2b0532a3e55b0 --- .../connectivity/NetworkNotificationManager.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java index 3d22d6d37c..26eca19b90 100644 --- a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java +++ b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java @@ -41,7 +41,6 @@ import android.widget.Toast; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; -import com.android.internal.notification.SystemNotificationChannels; public class NetworkNotificationManager { @@ -72,7 +71,12 @@ public class NetworkNotificationManager { private static final String TAG = NetworkNotificationManager.class.getSimpleName(); private static final boolean DBG = true; - private static final boolean VDBG = false; + + // Notification channels used by ConnectivityService mainline module, it should be aligned with + // SystemNotificationChannels. + public static final String NOTIFICATION_NETWORK_STATUS = "NETWORK_STATUS"; + public static final String NOTIFICATION_NETWORK_ALERTS = "NETWORK_ALERTS"; + public static final String NOTIFICATION_VPN = "VPN"; // The context is for the current user (system server) private final Context mContext; @@ -255,8 +259,7 @@ public class NetworkNotificationManager { // the tag. final boolean hasPreviousNotification = previousNotifyType != null; final String channelId = (highPriority && !hasPreviousNotification) - ? SystemNotificationChannels.NETWORK_ALERTS - : SystemNotificationChannels.NETWORK_STATUS; + ? NOTIFICATION_NETWORK_ALERTS : NOTIFICATION_NETWORK_STATUS; Notification.Builder builder = new Notification.Builder(mContext, channelId) .setWhen(System.currentTimeMillis()) .setShowWhen(notifyType == NotificationType.NETWORK_SWITCH) From ec9ab79f1abf77ed3681d5f97190950d990e7b19 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Mon, 2 Nov 2020 16:05:02 +0800 Subject: [PATCH 2/2] Use hasIpv[4|6]DefaultRoute instead of hasIPv[4|6]DefaultRoute ConnectivityService is going to be a mainline module, it can only use formal APIs or @SystemApi. So use @SystemApi hasIpv4DefaultRoute and hasIpv6DefaultRoute instead of hasIPv4DefaultRoute and hasIPv6DefaultRoute. Bug: 172183305 Test: atest FrameworksNetTests Change-Id: I67e5fa234fbb6d0b9739ae3295eb0b0ea108f582 --- .../core/java/com/android/server/ConnectivityService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index da2a3de9f9..88de82f08e 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -6432,8 +6432,8 @@ public class ConnectivityService extends IConnectivityManager.Stub && !nai.networkAgentConfig.allowBypass && nc.getOwnerUid() != Process.SYSTEM_UID && lp.getInterfaceName() != null - && (lp.hasIPv4DefaultRoute() || lp.hasIpv4UnreachableDefaultRoute()) - && (lp.hasIPv6DefaultRoute() || lp.hasIpv6UnreachableDefaultRoute()); + && (lp.hasIpv4DefaultRoute() || lp.hasIpv4UnreachableDefaultRoute()) + && (lp.hasIpv6DefaultRoute() || lp.hasIpv6UnreachableDefaultRoute()); } private void updateUids(NetworkAgentInfo nai, NetworkCapabilities prevNc,