From 2af502226a11af8df62e205f7054c650856fb636 Mon Sep 17 00:00:00 2001 From: paulhu Date: Sun, 11 Oct 2020 22:52:27 +0800 Subject: [PATCH] Replace PendingIntent @hide APIs Connectivity service module is using some PendingIntent @hide APIs but they are not able to call after CS becomes a mainline module. Thus, replace them with similar System APIs. Bug: 170593746 Test: atest FrameworksNetTests Manually test notifications can show normally. Change-Id: I92ab7216f5fd46d449b6d8f80d3441f8966ac890 --- .../core/java/com/android/server/ConnectivityService.java | 8 +++----- .../com/android/server/connectivity/LingerMonitor.java | 8 +++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 8a1baf2548..7729cf2036 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -3998,13 +3998,11 @@ public class ConnectivityService extends IConnectivityManager.Stub settingsPkgName + ".wifi.WifiNoInternetDialog"); } - PendingIntent pendingIntent = PendingIntent.getActivityAsUser( - mContext, + PendingIntent pendingIntent = PendingIntent.getActivity( + mContext.createContextAsUser(UserHandle.CURRENT, 0 /* flags */), 0 /* requestCode */, intent, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, - null /* options */, - UserHandle.CURRENT); + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); mNotifier.showNotification(nai.network.netId, type, nai, null, pendingIntent, highPriority); } diff --git a/services/core/java/com/android/server/connectivity/LingerMonitor.java b/services/core/java/com/android/server/connectivity/LingerMonitor.java index 7fdc7a0a52..f99f4c6559 100644 --- a/services/core/java/com/android/server/connectivity/LingerMonitor.java +++ b/services/core/java/com/android/server/connectivity/LingerMonitor.java @@ -159,9 +159,11 @@ public class LingerMonitor { @VisibleForTesting protected PendingIntent createNotificationIntent() { - return PendingIntent.getActivityAsUser(mContext, 0 /* requestCode */, CELLULAR_SETTINGS, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, - null /* options */, UserHandle.CURRENT); + return PendingIntent.getActivity( + mContext.createContextAsUser(UserHandle.CURRENT, 0 /* flags */), + 0 /* requestCode */, + CELLULAR_SETTINGS, + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); } // Removes any notification that was put up as a result of switching to nai.