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

Commit eb9be3e7 authored by Will Leshner's avatar Will Leshner
Browse files

Manually track dreams being obscured.

This change introduces a new IDreamManager method to allow SysUI to
report when a dream is obscured by something (notification shade,
bouncer, etc.). This allows handling a power button tap to bring the
dream back to the front (rather than turning the display off).

This change also removes a previous attempt to use focus to achieve the
same effect (focus ended up not quite working in all cases).

Bug: 329125239, 337302237
Test: atest DreamOverlayServiceTest
Test: atest DreamOverlayContainerViewControllerTest
Test: atest DreamServiceTests
Flag: ACONFIG android.service.dreams.dream_handles_being_obscured STAGING
Change-Id: I35d9a0dff492443fa2e659b7ed442b8e4e3c641b
parent 77a7c56c
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import static android.Manifest.permission.WRITE_SECURE_SETTINGS;

import android.annotation.FlaggedApi;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemService;
@@ -30,6 +31,7 @@ import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.dreams.DreamService;
import android.service.dreams.Flags;
import android.service.dreams.IDreamManager;

/**
@@ -217,4 +219,19 @@ public class DreamManager {
        }
        return false;
    }

    /**
     * Sets whether the dream is obscured by something.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_DREAM_HANDLES_BEING_OBSCURED)
    @RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)
    public void setDreamIsObscured(boolean isObscured) {
        try {
            mService.setDreamIsObscured(isObscured);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+2 −11
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package android.service.dreams;

import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.service.dreams.Flags.dreamHandlesConfirmKeys;
import static android.service.dreams.Flags.dreamTracksFocus;
import static android.service.dreams.Flags.dreamHandlesBeingObscured;

import android.annotation.FlaggedApi;
import android.annotation.IdRes;
@@ -571,15 +571,6 @@ public class DreamService extends Service implements Window.Callback {
    /** {@inheritDoc} */
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if (!dreamTracksFocus()) {
            return;
        }

        try {
            mDreamManager.onDreamFocusChanged(hasFocus);
        } catch (RemoteException ex) {
            // system server died
        }
    }

    /** {@inheritDoc} */
@@ -1737,7 +1728,7 @@ public class DreamService extends Service implements Window.Callback {

        @Override
        public void comeToFront() {
            if (!dreamTracksFocus()) {
            if (!dreamHandlesBeingObscured()) {
                return;
            }

+2 −1
Original line number Diff line number Diff line
@@ -48,5 +48,6 @@ interface IDreamManager {
    void setSystemDreamComponent(in ComponentName componentName);
    void registerDreamOverlayService(in ComponentName componentName);
    void startDreamActivity(in Intent intent);
    void onDreamFocusChanged(in boolean hasFocus);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)")
    oneway void setDreamIsObscured(in boolean isObscured);
}
+6 −3
Original line number Diff line number Diff line
@@ -39,8 +39,11 @@ flag {
}

flag {
  name: "dream_tracks_focus"
  name: "dream_handles_being_obscured"
  namespace: "communal"
  description: "This flag enables the ability for dreams to track whether or not they have focus"
  bug: "331798001"
  description: "This flag enables the ability for dreams to handle being obscured"
  bug: "337302237"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+13 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.DreamManager;
import android.content.res.Resources;
import android.graphics.Region;
import android.os.Handler;
@@ -45,8 +46,10 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.ambient.touch.scrim.BouncerlessScrimController;
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.communal.domain.interactor.CommunalInteractor;
import com.android.systemui.complication.ComplicationHostViewController;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
import com.android.systemui.statusbar.BlurUtils;

import kotlinx.coroutines.CoroutineDispatcher;
@@ -115,6 +118,12 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
    DreamOverlayStateController mStateController;
    @Mock
    KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    @Mock
    ShadeInteractor mShadeInteractor;
    @Mock
    CommunalInteractor mCommunalInteractor;
    @Mock
    private DreamManager mDreamManager;

    DreamOverlayContainerViewController mController;

@@ -146,7 +155,10 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
                mAnimationsController,
                mStateController,
                mBouncerlessScrimController,
                mKeyguardTransitionInteractor);
                mKeyguardTransitionInteractor,
                mShadeInteractor,
                mCommunalInteractor,
                mDreamManager);
    }

    @Test
Loading