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

Commit fada2c5d authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Clear Binder identity on calls into DreamService." into main

parents bd93cfa2 c027f365
Loading
Loading
Loading
Loading
+40 −9
Original line number Diff line number Diff line
@@ -1211,13 +1211,23 @@ public class DreamService extends Service implements Window.Callback {
        mOverlayCallback = new IDreamOverlayCallback.Stub() {
            @Override
            public void onExitRequested() {
                final long token = Binder.clearCallingIdentity();
                try {
                    // Simply finish dream when exit is requested.
                    mHandler.post(() -> finishInternal());
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            }

            @Override
            public void onRedirectWake(boolean redirect) {
                final long token = Binder.clearCallingIdentity();
                try {
                    mRedirectWake = redirect;
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            }
        };

@@ -1883,25 +1893,46 @@ public class DreamService extends Service implements Window.Callback {
        @Override
        public void attach(final IBinder dreamToken, final boolean canDoze,
                final boolean isPreviewMode, IRemoteCallback started) {
            post(dreamService -> dreamService.attach(dreamToken, canDoze, isPreviewMode, started));
            final long token = Binder.clearCallingIdentity();
            try {
                post(dreamService -> dreamService.attach(dreamToken, canDoze, isPreviewMode,
                        started));
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override
        public void detach() {
            final long token = Binder.clearCallingIdentity();
            try {
                post(DreamService::detach);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override
        public void wakeUp() {
            final long token = Binder.clearCallingIdentity();
            try {
                post(dreamService -> dreamService.wakeUp(true /*fromSystem*/));
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override
        public void comeToFront() {
            final long token = Binder.clearCallingIdentity();
            try {
                if (!dreamHandlesBeingObscured()) {
                    return;
                }
                post(DreamService::comeToFront);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }