Merge "Pipeline "showComplications" to DreamOverlayService."
This commit is contained in:
@@ -2320,6 +2320,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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user