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

Commit 5f1bef2f authored by Darrell Shi's avatar Darrell Shi
Browse files

Pipeline "showComplications" to DreamOverlayService.

Allow a boolean in the intent extra when connecting to
DreamOverlayService to indicate whether complications should be rendered
on the overlay.

Test: atest DreamOverlayServiceTest
Bug: 211519550
Change-Id: I09eb8e55e0f7d494184938c217d1291000259692
parent bd4a9f58
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2305,6 +2305,7 @@ package android.service.dreams {
    method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method public abstract void onStartDream(@NonNull android.view.WindowManager.LayoutParams);
    method public final void requestExit();
    method public final boolean shouldShowComplications();
  }

}
+10 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.view.WindowManager;
public abstract class DreamOverlayService extends Service {
    private static final String TAG = "DreamOverlayService";
    private static final boolean DEBUG = false;
    private boolean mShowComplications;

    private IDreamOverlay mDreamOverlay = new IDreamOverlay.Stub() {
        @Override
@@ -53,6 +54,8 @@ public abstract class DreamOverlayService extends Service {
    @Nullable
    @Override
    public final IBinder onBind(@NonNull Intent intent) {
        mShowComplications = intent.getBooleanExtra(DreamService.EXTRA_SHOW_COMPLICATIONS,
                DreamService.DEFAULT_SHOW_COMPLICATIONS);
        return mDreamOverlay.asBinder();
    }

@@ -74,4 +77,11 @@ public abstract class DreamOverlayService extends Service {
            Log.e(TAG, "Could not request exit:" + e);
        }
    }

    /**
     * Returns whether to show complications on the dream overlay.
     */
    public final boolean shouldShowComplications() {
        return mShowComplications;
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -189,6 +189,19 @@ public class DreamService extends Service implements Window.Callback {
     */
    public static final String DREAM_META_DATA = "android.service.dream";

    /**
     * Extra containing a boolean for whether to show complications on the overlay.
     * @hide
     */
    public static final String EXTRA_SHOW_COMPLICATIONS =
            "android.service.dreams.SHOW_COMPLICATIONS";

    /**
     * The default value for whether to show complications on the overlay.
     * @hide
     */
    public static final boolean DEFAULT_SHOW_COMPLICATIONS = true;

    private final IDreamManager mDreamManager;
    private final Handler mHandler = new Handler(Looper.getMainLooper());
    private IBinder mDreamToken;
+21 −0
Original line number Diff line number Diff line
@@ -16,12 +16,15 @@

package com.android.systemui.dreams;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Intent;
import android.os.IBinder;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamOverlay;
import android.service.dreams.IDreamOverlayCallback;
import android.testing.AndroidTestingRunner;
@@ -195,4 +198,22 @@ public class DreamOverlayServiceTest extends SysuiTestCase {
        mService.onDestroy();
        verify(mDreamOverlayStateController).removeCallback(callbackCapture.getValue());
    }

    @Test
    public void testShouldShowComplicationsTrueByDefault() {
        assertThat(mService.shouldShowComplications()).isTrue();

        mService.onBind(new Intent());

        assertThat(mService.shouldShowComplications()).isTrue();
    }

    @Test
    public void testShouldShowComplicationsSetByIntentExtra() {
        final Intent intent = new Intent();
        intent.putExtra(DreamService.EXTRA_SHOW_COMPLICATIONS, false);
        mService.onBind(intent);

        assertThat(mService.shouldShowComplications()).isFalse();
    }
}