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

Commit f75a1c67 authored by Bryce Lee's avatar Bryce Lee Committed by Automerger Merge Worker
Browse files

Merge "Revert "Marshal dream overlay connection logic with Handler."" into...

Merge "Revert "Marshal dream overlay connection logic with Handler."" into tm-qpr-dev am: b5e24da9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18051655



Change-Id: I2b27dbda96473a419141f34e0d2c5fc68bb9e2b4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dc1a990c b5e24da9
Loading
Loading
Loading
Loading
+23 −35
Original line number Diff line number Diff line
@@ -251,8 +251,6 @@ public class DreamService extends Service implements Window.Callback {
        // A Queue of pending requests to execute on the overlay.
        private final ArrayDeque<Consumer<IDreamOverlay>> mRequests;

        private Handler mHandler = new Handler(Looper.getMainLooper());

        private boolean mBound;

        OverlayConnection() {
@@ -261,7 +259,6 @@ public class DreamService extends Service implements Window.Callback {

        public void bind(Context context, @Nullable ComponentName overlayService,
                ComponentName dreamService) {
            mHandler.post(() -> {
            if (overlayService == null) {
                return;
            }
@@ -276,25 +273,20 @@ public class DreamService extends Service implements Window.Callback {
            context.bindService(overlayIntent,
                    this, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE);
            mBound = true;
            });
        }

        public void unbind(Context context) {
            mHandler.post(() -> {
            if (!mBound) {
                return;
            }

            context.unbindService(this);
            mBound = false;
            });
        }

        public void request(Consumer<IDreamOverlay> request) {
            mHandler.post(() -> {
            mRequests.push(request);
            evaluate();
            });
        }

        private void evaluate() {
@@ -312,19 +304,15 @@ public class DreamService extends Service implements Window.Callback {

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            mHandler.post(() -> {
            // Store Overlay and execute pending requests.
            mOverlay = IDreamOverlay.Stub.asInterface(service);
            evaluate();
            });
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            mHandler.post(() -> {
            // Clear Overlay binder to prevent further request processing.
            mOverlay = null;
            });
        }
    }