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

Commit 9fbebce2 authored by Lucas Silva's avatar Lucas Silva
Browse files

Fix small bug in DreamOverlayService destroy.

Currently we are registering the callback for the second time instead of
removing the callback.

Test: atest DreamOverlayService
Change-Id: I56aa05b52f85ce60b15cb73e9be3a25501534656
parent d478d792
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -122,10 +122,12 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ

    @Override
    public void onDestroy() {
        mKeyguardUpdateMonitor.registerCallback(mKeyguardCallback);
        mKeyguardUpdateMonitor.removeCallback(mKeyguardCallback);
        setCurrentState(Lifecycle.State.DESTROYED);
        final WindowManager windowManager = mContext.getSystemService(WindowManager.class);
        if (mWindow != null) {
            windowManager.removeView(mWindow.getDecorView());
        }
        mStateController.setOverlayActive(false);
        super.onDestroy();
    }
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.testing.AndroidTestingRunner;
import android.view.WindowManager;
import android.view.WindowManagerImpl;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import androidx.test.filters.SmallTest;
@@ -191,4 +192,14 @@ public class DreamOverlayServiceTest extends SysuiTestCase {
                        | Complication.COMPLICATION_TYPE_WEATHER;
        verify(mStateController).setAvailableComplicationTypes(expectedTypes);
    }

    @Test
    public void testDestroy() {
        mService.onDestroy();
        mMainExecutor.runAllReady();

        verify(mKeyguardUpdateMonitor).removeCallback(any());
        verify(mLifecycleRegistry).setCurrentState(Lifecycle.State.DESTROYED);
        verify(mStateController).setOverlayActive(false);
    }
}