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

Commit 078e715c authored by Bryce Lee's avatar Bryce Lee
Browse files

Clear DreamOverlayCallback reference on destroy.

This changelist ensures DreamService doesn't reference
DreamOverlayCallback after it's destroyed, allowing it to be garbage
collected before the DreamService.

Test: manual - ensured dream and overly properly entered and exited
across invocations and selections.
Fixed: b/291723667

Change-Id: I54309e539f4417655e0d1dd47c5190494b5c6715
parent 804840c5
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -244,13 +244,7 @@ public class DreamService extends Service implements Window.Callback {

    private DreamOverlayConnectionHandler mOverlayConnection;

    private final IDreamOverlayCallback mOverlayCallback = new IDreamOverlayCallback.Stub() {
        @Override
        public void onExitRequested() {
            // Simply finish dream when exit is requested.
            mHandler.post(() -> finish());
        }
    };
    private IDreamOverlayCallback mOverlayCallback;


    public DreamService() {
@@ -877,6 +871,13 @@ public class DreamService extends Service implements Window.Callback {
        mDreamComponent = new ComponentName(this, getClass());
        mShouldShowComplications = fetchShouldShowComplications(this /*context*/,
                fetchServiceInfo(this /*context*/, mDreamComponent));
        mOverlayCallback = new IDreamOverlayCallback.Stub() {
            @Override
            public void onExitRequested() {
                // Simply finish dream when exit is requested.
                mHandler.post(() -> finish());
            }
        };

        super.onCreate();
    }
@@ -1083,7 +1084,7 @@ public class DreamService extends Service implements Window.Callback {

        // Just in case destroy came in before detach, let's take care of that now
        detach();

        mOverlayCallback = null;
        super.onDestroy();
    }