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

Commit 2cfeb1ac authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Don't create a delegate for null callbacks." into lmp-dev

parents 60386251 3d0c57a1
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -471,24 +471,32 @@ public final class DisplayManagerGlobal {
        private VirtualDisplayCallbacksDelegate mDelegate;

        public VirtualDisplayCallbacks(VirtualDisplay.Callbacks callbacks, Handler handler) {
            if (callbacks != null) {
                mDelegate = new VirtualDisplayCallbacksDelegate(callbacks, handler);
            }
        }

        @Override // Binder call
        public void onDisplayPaused() {
            if (mDelegate != null) {
                mDelegate.sendEmptyMessage(VirtualDisplayCallbacksDelegate.MSG_DISPLAY_PAUSED);
            }
        }

        @Override // Binder call
        public void onDisplayResumed() {
            if (mDelegate != null) {
                mDelegate.sendEmptyMessage(VirtualDisplayCallbacksDelegate.MSG_DISPLAY_RESUMED);
            }
        }

        @Override // Binder call
        public void onDisplayStopped() {
            if (mDelegate != null) {
                mDelegate.sendEmptyMessage(VirtualDisplayCallbacksDelegate.MSG_DISPLAY_STOPPED);
            }
        }
    }

    private final static class VirtualDisplayCallbacksDelegate extends Handler {
        public static final int MSG_DISPLAY_PAUSED = 0;
@@ -505,9 +513,6 @@ public final class DisplayManagerGlobal {

        @Override
        public void handleMessage(Message msg) {
            if (mCallbacks == null) {
                return;
            }
            switch (msg.what) {
                case MSG_DISPLAY_PAUSED:
                    mCallbacks.onDisplayPaused();