Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c584d62 authored by Bernardo Rufino's avatar Bernardo Rufino
Browse files

Surround platform-compat check with Binder.clearCallingIdentity()

Otherwise it fails permission check since it would use the caller's uid.

Bug: 148521528
Test: Post a background custom toast and observe it either posts the
      toast or shows a textual warning toast (before this change,
      neither would happen and we'd see a SE in logcat).

Change-Id: I338846bda08b8a002440dd3b1a43393f2ff25011
parent c847a7ad
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2682,6 +2682,7 @@ public class NotificationManagerService extends SystemService {

            if (callback != null && !appIsForeground && !isSystemToast) {
                boolean block;
                long id = Binder.clearCallingIdentity();
                try {
                    block = mPlatformCompat.isChangeEnabledByPackageName(
                            CHANGE_BACKGROUND_CUSTOM_TOAST_BLOCK, pkg,
@@ -2691,6 +2692,8 @@ public class NotificationManagerService extends SystemService {
                    Slog.e(TAG, "Unexpected exception while checking block background custom toasts"
                            + " change", e);
                    block = false;
                } finally {
                    Binder.restoreCallingIdentity(id);
                }
                if (block) {
                    // TODO(b/144152069): Remove informative toast