Loading core/java/android/app/Notification.java +6 −3 Original line number Diff line number Diff line Loading @@ -3586,12 +3586,15 @@ public class Notification implements Parcelable * Sets the token used for background operations for the pending intents associated with this * notification. * * This token is automatically set during deserialization for you, you usually won't need to * call this unless you want to change the existing token, if any. * * @hide */ public void overrideAllowlistToken(IBinder token) { mAllowlistToken = token; public void clearAllowlistToken() { mAllowlistToken = null; if (publicVersion != null) { publicVersion.overrideAllowlistToken(token); publicVersion.clearAllowlistToken(); } } Loading services/core/java/com/android/server/notification/NotificationManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -741,7 +741,7 @@ public class NotificationManagerService extends SystemService { private static final int MY_UID = Process.myUid(); private static final int MY_PID = Process.myPid(); static final IBinder ALLOWLIST_TOKEN = new Binder(); private static final IBinder ALLOWLIST_TOKEN = new Binder(); protected RankingHandler mRankingHandler; private long mLastOverRateLogTime; private float mMaxPackageEnqueueRate = DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE; Loading Loading @@ -4875,7 +4875,7 @@ public class NotificationManagerService extends SystemService { // Remove background token before returning notification to untrusted app, this // ensures the app isn't able to perform background operations that are // associated with notification interactions. notification.overrideAllowlistToken(null); notification.clearAllowlistToken(); return new StatusBarNotification( sbn.getPackageName(), sbn.getOpPkg(), Loading Loading @@ -7884,8 +7884,6 @@ public class NotificationManagerService extends SystemService { } } notification.overrideAllowlistToken(ALLOWLIST_TOKEN); // Remote views? Are they too big? checkRemoteViews(pkg, tag, id, notification); } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +0 −30 Original line number Diff line number Diff line Loading @@ -325,7 +325,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; Loading Loading @@ -13225,35 +13224,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test public void fixNotification_customAllowlistToken() throws Exception { Notification n = new Notification.Builder(mContext, "test") .build(); try { Field allowlistToken = Class.forName("android.app.Notification"). getDeclaredField("mAllowlistToken"); allowlistToken.setAccessible(true); allowlistToken.set(n, new Binder()); } catch (Exception e) { throw new RuntimeException(e); } mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true); IBinder actual = null; try { Field allowlistToken = Class.forName("android.app.Notification"). getDeclaredField("mAllowlistToken"); allowlistToken.setAccessible(true); actual = (IBinder) allowlistToken.get(n); } catch (Exception e) { throw new RuntimeException(e); } assertTrue(mService.ALLOWLIST_TOKEN == actual); } @Test public void testCancelAllNotifications_IgnoreUserInitiatedJob() throws Exception { when(mJsi.isNotificationAssociatedWithAnyUserInitiatedJobs(anyInt(), anyInt(), anyString())) Loading
core/java/android/app/Notification.java +6 −3 Original line number Diff line number Diff line Loading @@ -3586,12 +3586,15 @@ public class Notification implements Parcelable * Sets the token used for background operations for the pending intents associated with this * notification. * * This token is automatically set during deserialization for you, you usually won't need to * call this unless you want to change the existing token, if any. * * @hide */ public void overrideAllowlistToken(IBinder token) { mAllowlistToken = token; public void clearAllowlistToken() { mAllowlistToken = null; if (publicVersion != null) { publicVersion.overrideAllowlistToken(token); publicVersion.clearAllowlistToken(); } } Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -741,7 +741,7 @@ public class NotificationManagerService extends SystemService { private static final int MY_UID = Process.myUid(); private static final int MY_PID = Process.myPid(); static final IBinder ALLOWLIST_TOKEN = new Binder(); private static final IBinder ALLOWLIST_TOKEN = new Binder(); protected RankingHandler mRankingHandler; private long mLastOverRateLogTime; private float mMaxPackageEnqueueRate = DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE; Loading Loading @@ -4875,7 +4875,7 @@ public class NotificationManagerService extends SystemService { // Remove background token before returning notification to untrusted app, this // ensures the app isn't able to perform background operations that are // associated with notification interactions. notification.overrideAllowlistToken(null); notification.clearAllowlistToken(); return new StatusBarNotification( sbn.getPackageName(), sbn.getOpPkg(), Loading Loading @@ -7884,8 +7884,6 @@ public class NotificationManagerService extends SystemService { } } notification.overrideAllowlistToken(ALLOWLIST_TOKEN); // Remote views? Are they too big? checkRemoteViews(pkg, tag, id, notification); } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +0 −30 Original line number Diff line number Diff line Loading @@ -325,7 +325,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; Loading Loading @@ -13225,35 +13224,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test public void fixNotification_customAllowlistToken() throws Exception { Notification n = new Notification.Builder(mContext, "test") .build(); try { Field allowlistToken = Class.forName("android.app.Notification"). getDeclaredField("mAllowlistToken"); allowlistToken.setAccessible(true); allowlistToken.set(n, new Binder()); } catch (Exception e) { throw new RuntimeException(e); } mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true); IBinder actual = null; try { Field allowlistToken = Class.forName("android.app.Notification"). getDeclaredField("mAllowlistToken"); allowlistToken.setAccessible(true); actual = (IBinder) allowlistToken.get(n); } catch (Exception e) { throw new RuntimeException(e); } assertTrue(mService.ALLOWLIST_TOKEN == actual); } @Test public void testCancelAllNotifications_IgnoreUserInitiatedJob() throws Exception { when(mJsi.isNotificationAssociatedWithAnyUserInitiatedJobs(anyInt(), anyInt(), anyString()))