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

Commit 449ab85f authored by Alexander Roederer's avatar Alexander Roederer
Browse files

Fix isSystemUi ManagedServiceInfo bool

Checks the status bar permission for ManagedServiceInfos when they're
added, so we can tell which one is SystemUi. Stores value in boolean.
The previous method of doing this, which just checked the caller, won't
work because the caller is usually system server.

Bug: 327471672
Test: build+flash
Flag: ACONFIG android.app.lifetime_extension_refactor STAGING
Change-Id: Ie952cb5d0f1faafb6106b708aa6d18c87b9b3b6c
parent 2115135c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -12050,11 +12050,12 @@ public class NotificationManagerService extends SystemService {
        @Override
        public void onServiceAdded(ManagedServiceInfo info) {
            if (lifetimeExtensionRefactor()) {
                // Generally, only System or System UI should have the permissions to call
                // registerSystemService.
                // isCallerSystemorPhone tells us whether the caller is System. Then, if it's not
                // the system, we know it's system UI.
                info.isSystemUi = !isCallerSystemOrPhone();
                // We explicitly check the status bar permission for the uid in the info object.
                // We can't use the calling uid here because it's probably always system server.
                // Note that this will also be true for the shell.
                info.isSystemUi = getContext().checkPermission(
                        android.Manifest.permission.STATUS_BAR_SERVICE, -1, info.uid)
                        == PERMISSION_GRANTED;
            }
            final INotificationListener listener = (INotificationListener) info.service;
            final NotificationRankingUpdate update;