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
This commit is contained in:
lucaslin
2020-11-02 11:53:16 +08:00
parent bc2369abe9
commit 42f8a914cf

View File

@@ -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)