diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 27f5b926411c6..34c392219f675 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2403,8 +2403,6 @@ package android.service.dreams { public abstract class DreamOverlayService extends android.app.Service { ctor public DreamOverlayService(); - method @Nullable public final CharSequence getDreamLabel(); - method public final boolean isPreviewMode(); 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(); diff --git a/core/java/android/service/dreams/DreamOverlayService.java b/core/java/android/service/dreams/DreamOverlayService.java index bfc3b8b39385e..163d6ed4b18ba 100644 --- a/core/java/android/service/dreams/DreamOverlayService.java +++ b/core/java/android/service/dreams/DreamOverlayService.java @@ -36,9 +36,6 @@ public abstract class DreamOverlayService extends Service { private static final String TAG = "DreamOverlayService"; private static final boolean DEBUG = false; private boolean mShowComplications; - private boolean mIsPreviewMode; - @Nullable - private CharSequence mDreamLabel; private IDreamOverlay mDreamOverlay = new IDreamOverlay.Stub() { @Override @@ -59,8 +56,6 @@ public abstract class DreamOverlayService extends Service { public final IBinder onBind(@NonNull Intent intent) { mShowComplications = intent.getBooleanExtra(DreamService.EXTRA_SHOW_COMPLICATIONS, DreamService.DEFAULT_SHOW_COMPLICATIONS); - mIsPreviewMode = intent.getBooleanExtra(DreamService.EXTRA_IS_PREVIEW, false); - mDreamLabel = intent.getCharSequenceExtra(DreamService.EXTRA_DREAM_LABEL); return mDreamOverlay.asBinder(); } @@ -89,19 +84,4 @@ public abstract class DreamOverlayService extends Service { public final boolean shouldShowComplications() { return mShowComplications; } - - /** - * Returns whether the dream is running in preview mode. - */ - public final boolean isPreviewMode() { - return mIsPreviewMode; - } - - /** - * Returns the user-facing label of the currently running dream. - */ - @Nullable - public final CharSequence getDreamLabel() { - return mDreamLabel; - } } diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index d4f8a3beb89b7..bd25572313269 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -215,18 +215,6 @@ public class DreamService extends Service implements Window.Callback { public static final String EXTRA_SHOW_COMPLICATIONS = "android.service.dreams.SHOW_COMPLICATIONS"; - /** - * Extra containing a boolean for whether we are showing this dream in preview mode. - * @hide - */ - public static final String EXTRA_IS_PREVIEW = "android.service.dreams.IS_PREVIEW"; - - /** - * The user-facing label of the current dream service. - * @hide - */ - public static final String EXTRA_DREAM_LABEL = "android.service.dreams.DREAM_LABEL"; - /** * The default value for whether to show complications on the overlay. * @hide @@ -270,7 +258,7 @@ public class DreamService extends Service implements Window.Callback { } public void bind(Context context, @Nullable ComponentName overlayService, - ComponentName dreamService, boolean isPreviewMode) { + ComponentName dreamService) { if (overlayService == null) { return; } @@ -281,8 +269,6 @@ public class DreamService extends Service implements Window.Callback { overlayIntent.setComponent(overlayService); overlayIntent.putExtra(EXTRA_SHOW_COMPLICATIONS, fetchShouldShowComplications(context, serviceInfo)); - overlayIntent.putExtra(EXTRA_DREAM_LABEL, fetchDreamLabel(context, serviceInfo)); - overlayIntent.putExtra(EXTRA_IS_PREVIEW, isPreviewMode); context.bindService(overlayIntent, this, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE); @@ -1007,8 +993,7 @@ public class DreamService extends Service implements Window.Callback { mOverlayConnection.bind( /* context= */ this, intent.getParcelableExtra(EXTRA_DREAM_OVERLAY_COMPONENT), - new ComponentName(this, getClass()), - intent.getBooleanExtra(EXTRA_IS_PREVIEW, /* defaultValue= */ false)); + new ComponentName(this, getClass())); } return mDreamServiceWrapper; diff --git a/packages/SystemUI/res/layout/dream_overlay_complication_preview.xml b/packages/SystemUI/res/layout/dream_overlay_complication_preview.xml deleted file mode 100644 index ca5c4996cddbc..0000000000000 --- a/packages/SystemUI/res/layout/dream_overlay_complication_preview.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index db225cf498b02..96f77b3654c58 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -38,7 +38,6 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.Complication; -import com.android.systemui.dreams.complication.DreamPreviewComplication; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; @@ -63,7 +62,6 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ // content area). private final DreamOverlayContainerViewController mDreamOverlayContainerViewController; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final DreamPreviewComplication mPreviewComplication; private final UiEventLogger mUiEventLogger; // A reference to the {@link Window} used to hold the dream overlay. @@ -127,14 +125,12 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ DreamOverlayComponent.Factory dreamOverlayComponentFactory, DreamOverlayStateController stateController, KeyguardUpdateMonitor keyguardUpdateMonitor, - DreamPreviewComplication previewComplication, UiEventLogger uiEventLogger) { mContext = context; mExecutor = executor; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mKeyguardUpdateMonitor.registerCallback(mKeyguardCallback); mStateController = stateController; - mPreviewComplication = previewComplication; mUiEventLogger = uiEventLogger; final DreamOverlayComponent component = @@ -159,9 +155,6 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ windowManager.removeView(mWindow.getDecorView()); } mStateController.setOverlayActive(false); - mPreviewComplication.setDreamLabel(null); - mStateController.removeComplication(mPreviewComplication); - mStateController.setPreviewMode(false); mDestroyed = true; super.onDestroy(); } @@ -177,11 +170,6 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ return; } mStateController.setShouldShowComplications(shouldShowComplications()); - mStateController.setPreviewMode(isPreviewMode()); - if (isPreviewMode()) { - mPreviewComplication.setDreamLabel(getDreamLabel()); - mStateController.addComplication(mPreviewComplication); - } addOverlayWindowLocked(layoutParams); setCurrentState(Lifecycle.State.RESUMED); mStateController.setOverlayActive(true); diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java index 6860998680cb7..fc71e2fb23296 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java @@ -50,7 +50,6 @@ public class DreamOverlayStateController implements private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); public static final int STATE_DREAM_OVERLAY_ACTIVE = 1 << 0; - public static final int STATE_PREVIEW_MODE = 1 << 1; private static final int OP_CLEAR_STATE = 1; private static final int OP_SET_STATE = 2; @@ -250,18 +249,4 @@ public class DreamOverlayStateController implements mCallbacks.forEach(Callback::onAvailableComplicationTypesChanged); }); } - - /** - * Sets whether the dream is running in preview mode. - */ - public void setPreviewMode(boolean isPreviewMode) { - modifyState(isPreviewMode ? OP_SET_STATE : OP_CLEAR_STATE, STATE_PREVIEW_MODE); - } - - /** - * Returns whether the dream is running in preview mode. - */ - public boolean isPreviewMode() { - return containsState(STATE_PREVIEW_MODE); - } } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/DreamPreviewComplication.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/DreamPreviewComplication.java deleted file mode 100644 index cc2e571282044..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/DreamPreviewComplication.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.dreams.complication; - -import static com.android.systemui.dreams.complication.dagger.DreamPreviewComplicationComponent.DREAM_LABEL; -import static com.android.systemui.dreams.complication.dagger.DreamPreviewComplicationComponent.DreamPreviewComplicationModule.DREAM_PREVIEW_COMPLICATION_LAYOUT_PARAMS; -import static com.android.systemui.dreams.complication.dagger.DreamPreviewComplicationComponent.DreamPreviewComplicationModule.DREAM_PREVIEW_COMPLICATION_VIEW; - -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.text.TextUtils; -import android.view.View; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import com.android.systemui.dreams.complication.dagger.DreamPreviewComplicationComponent; -import com.android.systemui.util.ViewController; - -import javax.inject.Inject; -import javax.inject.Named; - -/** - * Preview complication shown when user is previewing a dream. - */ -public class DreamPreviewComplication implements Complication { - DreamPreviewComplicationComponent.Factory mComponentFactory; - @Nullable - private CharSequence mDreamLabel; - - /** - * Default constructor for {@link DreamPreviewComplication}. - */ - @Inject - public DreamPreviewComplication( - DreamPreviewComplicationComponent.Factory componentFactory) { - mComponentFactory = componentFactory; - } - - /** - * Create {@link DreamPreviewViewHolder}. - */ - @Override - public ViewHolder createView(ComplicationViewModel model) { - return mComponentFactory.create(model, mDreamLabel).getViewHolder(); - } - - /** - * Sets the user-facing label for the current dream. - */ - public void setDreamLabel(@Nullable CharSequence dreamLabel) { - mDreamLabel = dreamLabel; - } - - /** - * ViewHolder to contain value/logic associated with a Preview Complication View. - */ - public static class DreamPreviewViewHolder implements ViewHolder { - private final TextView mView; - private final ComplicationLayoutParams mLayoutParams; - private final DreamPreviewViewController mViewController; - - @Inject - DreamPreviewViewHolder(@Named(DREAM_PREVIEW_COMPLICATION_VIEW) TextView view, - DreamPreviewViewController controller, - @Named(DREAM_PREVIEW_COMPLICATION_LAYOUT_PARAMS) - ComplicationLayoutParams layoutParams, - @Named(DREAM_LABEL) @Nullable CharSequence dreamLabel) { - mView = view; - mLayoutParams = layoutParams; - mViewController = controller; - mViewController.init(); - - if (!TextUtils.isEmpty(dreamLabel)) { - mView.setText(dreamLabel); - } - for (Drawable drawable : mView.getCompoundDrawablesRelative()) { - if (drawable instanceof BitmapDrawable) { - drawable.setAutoMirrored(true); - } - } - } - - @Override - public View getView() { - return mView; - } - - @Override - public ComplicationLayoutParams getLayoutParams() { - return mLayoutParams; - } - - @Override - public int getCategory() { - return CATEGORY_SYSTEM; - } - } - - /** - * ViewController to contain value/logic associated with a Preview Complication View. - */ - static class DreamPreviewViewController extends ViewController { - private final ComplicationViewModel mViewModel; - - @Inject - DreamPreviewViewController(@Named(DREAM_PREVIEW_COMPLICATION_VIEW) TextView view, - ComplicationViewModel viewModel) { - super(view); - mViewModel = viewModel; - } - - @Override - protected void onViewAttached() { - mView.setOnClickListener(v -> mViewModel.exitDream()); - } - - @Override - protected void onViewDetached() { - mView.setOnClickListener(null); - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/DreamPreviewComplicationComponent.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/DreamPreviewComplicationComponent.java deleted file mode 100644 index 502e31ed0c7fb..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/DreamPreviewComplicationComponent.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.dreams.complication.dagger; - - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import android.view.LayoutInflater; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import com.android.internal.util.Preconditions; -import com.android.systemui.R; -import com.android.systemui.dreams.complication.ComplicationLayoutParams; -import com.android.systemui.dreams.complication.ComplicationViewModel; -import com.android.systemui.dreams.complication.DreamPreviewComplication.DreamPreviewViewHolder; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; - -import javax.inject.Named; -import javax.inject.Scope; - -import dagger.BindsInstance; -import dagger.Module; -import dagger.Provides; -import dagger.Subcomponent; - -/** - * {@link DreamPreviewComplicationComponent} is responsible for generating dependencies - * surrounding the - * Preview {@link com.android.systemui.dreams.complication.Complication}, such as the layout - * details. - */ -@Subcomponent(modules = { - DreamPreviewComplicationComponent.DreamPreviewComplicationModule.class, -}) -@DreamPreviewComplicationComponent.DreamPreviewComplicationScope -public interface DreamPreviewComplicationComponent { - String DREAM_LABEL = "dream_label"; - - /** - * Creates {@link DreamPreviewViewHolder}. - */ - DreamPreviewViewHolder getViewHolder(); - - @Documented - @Retention(RUNTIME) - @Scope - @interface DreamPreviewComplicationScope { - } - - /** - * Generates {@link DreamPreviewComplicationComponent}. - */ - @Subcomponent.Factory - interface Factory { - DreamPreviewComplicationComponent create( - @BindsInstance ComplicationViewModel viewModel, - @Named(DREAM_LABEL) @BindsInstance @Nullable CharSequence dreamLabel); - } - - /** - * Scoped values for {@link DreamPreviewComplicationComponent}. - */ - @Module - interface DreamPreviewComplicationModule { - String DREAM_PREVIEW_COMPLICATION_VIEW = "preview_complication_view"; - String DREAM_PREVIEW_COMPLICATION_LAYOUT_PARAMS = "preview_complication_layout_params"; - // Order weight of insert into parent container - int INSERT_ORDER_WEIGHT = 1000; - - /** - * Provides the complication view. - */ - @Provides - @DreamPreviewComplicationScope - @Named(DREAM_PREVIEW_COMPLICATION_VIEW) - static TextView provideComplicationView(LayoutInflater layoutInflater) { - return Preconditions.checkNotNull((TextView) - layoutInflater.inflate(R.layout.dream_overlay_complication_preview, - null, false), - "R.layout.dream_overlay_complication_preview did not properly inflated"); - } - - /** - * Provides the layout parameters for the complication view. - */ - @Provides - @DreamPreviewComplicationScope - @Named(DREAM_PREVIEW_COMPLICATION_LAYOUT_PARAMS) - static ComplicationLayoutParams provideLayoutParams() { - return new ComplicationLayoutParams(0, - ViewGroup.LayoutParams.WRAP_CONTENT, - ComplicationLayoutParams.POSITION_TOP - | ComplicationLayoutParams.POSITION_START, - ComplicationLayoutParams.DIRECTION_DOWN, - INSERT_ORDER_WEIGHT, /* snapToGuide= */ true); - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java index c7b02cd00e96b..c1dff248818f1 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java @@ -19,7 +19,6 @@ package com.android.systemui.dreams.dagger; import android.content.Context; import com.android.settingslib.dream.DreamBackend; -import com.android.systemui.dreams.complication.dagger.DreamPreviewComplicationComponent; import com.android.systemui.dreams.complication.dagger.RegisteredComplicationsModule; import dagger.Module; @@ -33,7 +32,6 @@ import dagger.Provides; }, subcomponents = { DreamOverlayComponent.class, - DreamPreviewComplicationComponent.class, }) public interface DreamModule { /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java index f567b55b7caa9..9d4275e65302c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java @@ -41,7 +41,6 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SysuiTestCase; -import com.android.systemui.dreams.complication.DreamPreviewComplication; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; import com.android.systemui.util.concurrency.FakeExecutor; @@ -99,9 +98,6 @@ public class DreamOverlayServiceTest extends SysuiTestCase { @Mock DreamOverlayStateController mStateController; - @Mock - DreamPreviewComplication mPreviewComplication; - @Mock ViewGroup mDreamOverlayContainerViewParent; @@ -133,7 +129,6 @@ public class DreamOverlayServiceTest extends SysuiTestCase { mDreamOverlayComponentFactory, mStateController, mKeyguardUpdateMonitor, - mPreviewComplication, mUiEventLogger); } @@ -208,31 +203,6 @@ public class DreamOverlayServiceTest extends SysuiTestCase { assertThat(mService.shouldShowComplications()).isTrue(); } - @Test - public void testPreviewModeFalseByDefault() { - mService.onBind(new Intent()); - - assertThat(mService.isPreviewMode()).isFalse(); - } - - @Test - public void testPreviewModeSetByIntentExtra() { - final Intent intent = new Intent(); - intent.putExtra(DreamService.EXTRA_IS_PREVIEW, true); - mService.onBind(intent); - - assertThat(mService.isPreviewMode()).isTrue(); - } - - @Test - public void testDreamLabel() { - final Intent intent = new Intent(); - intent.putExtra(DreamService.EXTRA_DREAM_LABEL, "TestDream"); - mService.onBind(intent); - - assertThat(mService.getDreamLabel()).isEqualTo("TestDream"); - } - @Test public void testDestroy() { mService.onDestroy(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java index 3ce9889571f19..fb64c7b58aacd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java @@ -82,38 +82,6 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase { assertThat(stateController.isOverlayActive()).isFalse(); } - @Test - public void testStateChange_isPreviewMode() { - final DreamOverlayStateController stateController = new DreamOverlayStateController( - mExecutor); - stateController.addCallback(mCallback); - stateController.setPreviewMode(true); - mExecutor.runAllReady(); - - verify(mCallback).onStateChanged(); - assertThat(stateController.isPreviewMode()).isTrue(); - - Mockito.clearInvocations(mCallback); - stateController.setPreviewMode(true); - mExecutor.runAllReady(); - verify(mCallback, never()).onStateChanged(); - } - - @Test - public void testPreviewModeFalseByDefault() { - final DreamOverlayStateController stateController = new DreamOverlayStateController( - mExecutor); - assertThat(stateController.isPreviewMode()).isFalse(); - } - - @Test - public void testPreviewModeSetToTrue() { - final DreamOverlayStateController stateController = new DreamOverlayStateController( - mExecutor); - stateController.setPreviewMode(true); - assertThat(stateController.isPreviewMode()).isTrue(); - } - @Test public void testCallback() { final DreamOverlayStateController stateController = new DreamOverlayStateController( diff --git a/services/core/java/com/android/server/dreams/DreamController.java b/services/core/java/com/android/server/dreams/DreamController.java index 4a1a950c6a078..4e4f4544e068e 100644 --- a/services/core/java/com/android/server/dreams/DreamController.java +++ b/services/core/java/com/android/server/dreams/DreamController.java @@ -140,7 +140,6 @@ final class DreamController { intent.setComponent(name); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); intent.putExtra(DreamService.EXTRA_DREAM_OVERLAY_COMPONENT, overlayComponentName); - intent.putExtra(DreamService.EXTRA_IS_PREVIEW, isPreviewMode); try { if (!mContext.bindServiceAsUser(intent, mCurrentDream, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,