From 6a9bff92aec1e03e17d6a4651cb33826cdce8047 Mon Sep 17 00:00:00 2001 From: Sarah Chin Date: Wed, 25 Nov 2020 12:15:14 -0800 Subject: [PATCH] Move phone ID to extra for action provision Previously, the phone ID was appended to the broadcast in DCT and sent to ConnectivityManager. Instead of sending both as an action, send the phone ID as an extra instead to make the action a protected broadcast. Test: manually verify a SecurityException when action provision is sent Test: atest DcTrackerTest Bug: 172459128 Change-Id: Ic4129def86949d7191d15056852718dadbd72fba Merged-In: Ic4129def86949d7191d15056852718dadbd72fba --- core/java/android/net/ConnectivityManager.java | 4 ++-- .../server/connectivity/NetworkNotificationManager.java | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index a29f878260..ed03f5198d 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -3115,9 +3115,9 @@ public class ConnectivityManager { } /** - * Set sign in error notification to visible or in visible + * Set sign in error notification to visible or invisible * - * {@hide} + * @hide * @deprecated Doesn't properly deal with multiple connected networks of the same type. */ @Deprecated diff --git a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java index 34b0aa2464..71ef0e2809 100644 --- a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java +++ b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java @@ -324,7 +324,13 @@ public class NetworkNotificationManager { */ public void setProvNotificationVisible(boolean visible, int id, String action) { if (visible) { - Intent intent = new Intent(action); + // For legacy purposes, action is sent as the action + the phone ID from DcTracker. + // Split the string here and send the phone ID as an extra instead. + String[] splitAction = action.split(":"); + Intent intent = new Intent(splitAction[0]); + try { + intent.putExtra("provision.phone.id", Integer.parseInt(splitAction[1])); + } catch (NumberFormatException ignored) { } PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); showNotification(id, NotificationType.SIGN_IN, null, null, pendingIntent, false); } else {