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

Commit db48e2b6 authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Fix small bug in DreamOverlayService destroy."

parents 2e2ab6f1 9fbebce2
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);
    }
}