Merge changes I339886d1,Id53bfc8c into udc-dev am: 7f4445dfd1 am: 5cb37f47d8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23242775 Change-Id: Ibecc4fda82ac52b74e45aadbf6609d97559b88d8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,18 +17,12 @@
|
|||||||
package com.android.wm.shell.bubbles;
|
package com.android.wm.shell.bubbles;
|
||||||
|
|
||||||
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||||
import static android.content.pm.ActivityInfo.CONFIG_ASSETS_PATHS;
|
|
||||||
import static android.content.pm.ActivityInfo.CONFIG_DENSITY;
|
|
||||||
import static android.content.pm.ActivityInfo.CONFIG_FONT_SCALE;
|
|
||||||
import static android.content.pm.ActivityInfo.CONFIG_LAYOUT_DIRECTION;
|
|
||||||
import static android.content.pm.ActivityInfo.CONFIG_UI_MODE;
|
|
||||||
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_DELETED;
|
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_DELETED;
|
||||||
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_UPDATED;
|
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_UPDATED;
|
||||||
import static android.service.notification.NotificationListenerService.REASON_CANCEL;
|
import static android.service.notification.NotificationListenerService.REASON_CANCEL;
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
|
||||||
|
|
||||||
import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_CONTROLLER;
|
import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_CONTROLLER;
|
||||||
import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_GESTURE;
|
import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_GESTURE;
|
||||||
@@ -53,7 +47,6 @@ import android.app.Notification;
|
|||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentCallbacks2;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@@ -81,6 +74,7 @@ import android.util.Pair;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewRootImpl;
|
import android.view.ViewRootImpl;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
@@ -108,7 +102,6 @@ import com.android.wm.shell.common.SingleInstanceRemoteListener;
|
|||||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||||
import com.android.wm.shell.common.TaskStackListenerCallback;
|
import com.android.wm.shell.common.TaskStackListenerCallback;
|
||||||
import com.android.wm.shell.common.TaskStackListenerImpl;
|
import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||||
import com.android.wm.shell.common.annotations.ExternalMainThread;
|
|
||||||
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
|
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
|
||||||
import com.android.wm.shell.common.annotations.ShellMainThread;
|
import com.android.wm.shell.common.annotations.ShellMainThread;
|
||||||
import com.android.wm.shell.common.bubbles.BubbleBarUpdate;
|
import com.android.wm.shell.common.bubbles.BubbleBarUpdate;
|
||||||
@@ -116,6 +109,7 @@ import com.android.wm.shell.draganddrop.DragAndDropController;
|
|||||||
import com.android.wm.shell.onehanded.OneHandedController;
|
import com.android.wm.shell.onehanded.OneHandedController;
|
||||||
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
|
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
|
||||||
import com.android.wm.shell.pip.PinnedStackListenerForwarder;
|
import com.android.wm.shell.pip.PinnedStackListenerForwarder;
|
||||||
|
import com.android.wm.shell.sysui.ConfigurationChangeListener;
|
||||||
import com.android.wm.shell.sysui.ShellCommandHandler;
|
import com.android.wm.shell.sysui.ShellCommandHandler;
|
||||||
import com.android.wm.shell.sysui.ShellController;
|
import com.android.wm.shell.sysui.ShellController;
|
||||||
import com.android.wm.shell.sysui.ShellInit;
|
import com.android.wm.shell.sysui.ShellInit;
|
||||||
@@ -141,7 +135,7 @@ import java.util.function.IntConsumer;
|
|||||||
*
|
*
|
||||||
* The controller manages addition, removal, and visible state of bubbles on screen.
|
* The controller manages addition, removal, and visible state of bubbles on screen.
|
||||||
*/
|
*/
|
||||||
public class BubbleController implements ComponentCallbacks2,
|
public class BubbleController implements ConfigurationChangeListener,
|
||||||
RemoteCallable<BubbleController> {
|
RemoteCallable<BubbleController> {
|
||||||
|
|
||||||
private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES;
|
private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES;
|
||||||
@@ -159,6 +153,7 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
private static final boolean BUBBLE_BAR_ENABLED =
|
private static final boolean BUBBLE_BAR_ENABLED =
|
||||||
SystemProperties.getBoolean("persist.wm.debug.bubble_bar", false);
|
SystemProperties.getBoolean("persist.wm.debug.bubble_bar", false);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface to send updates to bubble views.
|
* Common interface to send updates to bubble views.
|
||||||
*/
|
*/
|
||||||
@@ -242,17 +237,17 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
/** Whether or not the BubbleStackView has been added to the WindowManager. */
|
/** Whether or not the BubbleStackView has been added to the WindowManager. */
|
||||||
private boolean mAddedToWindowManager = false;
|
private boolean mAddedToWindowManager = false;
|
||||||
|
|
||||||
/**
|
/** Saved screen density, used to detect display size changes in {@link #onConfigChanged}. */
|
||||||
* Saved configuration, used to detect changes in
|
private int mDensityDpi = Configuration.DENSITY_DPI_UNDEFINED;
|
||||||
* {@link #onConfigurationChanged(Configuration)}
|
|
||||||
*/
|
|
||||||
private final Configuration mLastConfiguration = new Configuration();
|
|
||||||
|
|
||||||
/**
|
/** Saved screen bounds, used to detect screen size changes in {@link #onConfigChanged}. **/
|
||||||
* Saved screen bounds, used to detect screen size changes in
|
private Rect mScreenBounds = new Rect();
|
||||||
* {@link #onConfigurationChanged(Configuration)}.
|
|
||||||
*/
|
/** Saved font scale, used to detect font size changes in {@link #onConfigChanged}. */
|
||||||
private final Rect mScreenBounds = new Rect();
|
private float mFontScale = 0;
|
||||||
|
|
||||||
|
/** Saved direction, used to detect layout direction changes @link #onConfigChanged}. */
|
||||||
|
private int mLayoutDirection = View.LAYOUT_DIRECTION_UNDEFINED;
|
||||||
|
|
||||||
/** Saved insets, used to detect WindowInset changes. */
|
/** Saved insets, used to detect WindowInset changes. */
|
||||||
private WindowInsets mWindowInsets;
|
private WindowInsets mWindowInsets;
|
||||||
@@ -298,8 +293,7 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
TaskViewTransitions taskViewTransitions,
|
TaskViewTransitions taskViewTransitions,
|
||||||
SyncTransactionQueue syncQueue,
|
SyncTransactionQueue syncQueue,
|
||||||
IWindowManager wmService) {
|
IWindowManager wmService) {
|
||||||
mContext = context.createWindowContext(TYPE_APPLICATION_OVERLAY, null);
|
mContext = context;
|
||||||
mLastConfiguration.setTo(mContext.getResources().getConfiguration());
|
|
||||||
mShellCommandHandler = shellCommandHandler;
|
mShellCommandHandler = shellCommandHandler;
|
||||||
mShellController = shellController;
|
mShellController = shellController;
|
||||||
mLauncherApps = launcherApps;
|
mLauncherApps = launcherApps;
|
||||||
@@ -323,11 +317,11 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
mBubblePositioner = positioner;
|
mBubblePositioner = positioner;
|
||||||
mBubbleData = data;
|
mBubbleData = data;
|
||||||
mSavedUserBubbleData = new SparseArray<>();
|
mSavedUserBubbleData = new SparseArray<>();
|
||||||
mBubbleIconFactory = new BubbleIconFactory(mContext,
|
mBubbleIconFactory = new BubbleIconFactory(context,
|
||||||
mContext.getResources().getDimensionPixelSize(R.dimen.bubble_size),
|
context.getResources().getDimensionPixelSize(R.dimen.bubble_size),
|
||||||
mContext.getResources().getDimensionPixelSize(R.dimen.bubble_badge_size),
|
context.getResources().getDimensionPixelSize(R.dimen.bubble_badge_size),
|
||||||
mContext.getResources().getColor(R.color.important_conversation),
|
context.getResources().getColor(R.color.important_conversation),
|
||||||
mContext.getResources().getDimensionPixelSize(
|
context.getResources().getDimensionPixelSize(
|
||||||
com.android.internal.R.dimen.importance_ring_stroke_width));
|
com.android.internal.R.dimen.importance_ring_stroke_width));
|
||||||
mDisplayController = displayController;
|
mDisplayController = displayController;
|
||||||
mTaskViewTransitions = taskViewTransitions;
|
mTaskViewTransitions = taskViewTransitions;
|
||||||
@@ -488,6 +482,7 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
}
|
}
|
||||||
mCurrentProfiles = userProfiles;
|
mCurrentProfiles = userProfiles;
|
||||||
|
|
||||||
|
mShellController.addConfigurationChangeListener(this);
|
||||||
mShellController.addExternalInterface(KEY_EXTRA_SHELL_BUBBLES,
|
mShellController.addExternalInterface(KEY_EXTRA_SHELL_BUBBLES,
|
||||||
this::createExternalInterface, this);
|
this::createExternalInterface, this);
|
||||||
mShellCommandHandler.addDumpCallback(this::dump, this);
|
mShellCommandHandler.addDumpCallback(this::dump, this);
|
||||||
@@ -779,7 +774,6 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
try {
|
try {
|
||||||
mAddedToWindowManager = true;
|
mAddedToWindowManager = true;
|
||||||
registerBroadcastReceiver();
|
registerBroadcastReceiver();
|
||||||
mContext.registerComponentCallbacks(this);
|
|
||||||
mBubbleData.getOverflow().initialize(this);
|
mBubbleData.getOverflow().initialize(this);
|
||||||
// (TODO: b/273314541) some duplication in the inset listener
|
// (TODO: b/273314541) some duplication in the inset listener
|
||||||
if (isShowingAsBubbleBar()) {
|
if (isShowingAsBubbleBar()) {
|
||||||
@@ -837,7 +831,6 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
// Put on background for this binder call, was causing jank
|
// Put on background for this binder call, was causing jank
|
||||||
mBackgroundExecutor.execute(() -> {
|
mBackgroundExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
mContext.unregisterComponentCallbacks(this);
|
|
||||||
mContext.unregisterReceiver(mBroadcastReceiver);
|
mContext.unregisterReceiver(mBroadcastReceiver);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// Not sure if this happens in production, but was happening in tests
|
// Not sure if this happens in production, but was happening in tests
|
||||||
@@ -937,7 +930,8 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
mSavedUserBubbleData.remove(userId);
|
mSavedUserBubbleData.remove(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onThemeChanged() {
|
@Override
|
||||||
|
public void onThemeChanged() {
|
||||||
if (mStackView != null) {
|
if (mStackView != null) {
|
||||||
mStackView.onThemeChanged();
|
mStackView.onThemeChanged();
|
||||||
}
|
}
|
||||||
@@ -969,60 +963,34 @@ public class BubbleController implements ComponentCallbacks2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Component callbacks are always called on the main thread of the process
|
|
||||||
@ExternalMainThread
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
mMainExecutor.execute(() -> {
|
if (mBubblePositioner != null) {
|
||||||
final int diff = newConfig.diff(mLastConfiguration);
|
mBubblePositioner.update();
|
||||||
final boolean themeChanged = (diff & CONFIG_ASSETS_PATHS) != 0
|
}
|
||||||
|| (diff & CONFIG_UI_MODE) != 0;
|
if (mStackView != null && newConfig != null) {
|
||||||
if (themeChanged) {
|
if (newConfig.densityDpi != mDensityDpi
|
||||||
onThemeChanged();
|
|| !newConfig.windowConfiguration.getBounds().equals(mScreenBounds)) {
|
||||||
|
mDensityDpi = newConfig.densityDpi;
|
||||||
|
mScreenBounds.set(newConfig.windowConfiguration.getBounds());
|
||||||
|
mBubbleData.onMaxBubblesChanged();
|
||||||
|
mBubbleIconFactory = new BubbleIconFactory(mContext,
|
||||||
|
mContext.getResources().getDimensionPixelSize(R.dimen.bubble_size),
|
||||||
|
mContext.getResources().getDimensionPixelSize(R.dimen.bubble_badge_size),
|
||||||
|
mContext.getResources().getColor(R.color.important_conversation),
|
||||||
|
mContext.getResources().getDimensionPixelSize(
|
||||||
|
com.android.internal.R.dimen.importance_ring_stroke_width));
|
||||||
|
mStackView.onDisplaySizeChanged();
|
||||||
}
|
}
|
||||||
if (mBubblePositioner != null) {
|
if (newConfig.fontScale != mFontScale) {
|
||||||
mBubblePositioner.update();
|
mFontScale = newConfig.fontScale;
|
||||||
|
mStackView.updateFontScale();
|
||||||
}
|
}
|
||||||
if (mStackView != null) {
|
if (newConfig.getLayoutDirection() != mLayoutDirection) {
|
||||||
final boolean densityChanged = (diff & CONFIG_DENSITY) != 0;
|
mLayoutDirection = newConfig.getLayoutDirection();
|
||||||
final boolean fontScaleChanged = (diff & CONFIG_FONT_SCALE) != 0;
|
mStackView.onLayoutDirectionChanged(mLayoutDirection);
|
||||||
final boolean layoutDirectionChanged = (diff & CONFIG_LAYOUT_DIRECTION) != 0;
|
|
||||||
if (densityChanged
|
|
||||||
|| !newConfig.windowConfiguration.getBounds().equals(mScreenBounds)) {
|
|
||||||
mScreenBounds.set(newConfig.windowConfiguration.getBounds());
|
|
||||||
mBubbleData.onMaxBubblesChanged();
|
|
||||||
mBubbleIconFactory = new BubbleIconFactory(mContext,
|
|
||||||
mContext.getResources().getDimensionPixelSize(R.dimen.bubble_size),
|
|
||||||
mContext.getResources().getDimensionPixelSize(
|
|
||||||
R.dimen.bubble_badge_size),
|
|
||||||
mContext.getResources().getColor(R.color.important_conversation),
|
|
||||||
mContext.getResources().getDimensionPixelSize(
|
|
||||||
com.android.internal.R.dimen.importance_ring_stroke_width));
|
|
||||||
mStackView.onDisplaySizeChanged();
|
|
||||||
}
|
|
||||||
if (fontScaleChanged) {
|
|
||||||
mStackView.updateFontScale();
|
|
||||||
}
|
|
||||||
if (layoutDirectionChanged) {
|
|
||||||
mStackView.onLayoutDirectionChanged(newConfig.getLayoutDirection());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mLastConfiguration.setTo(newConfig);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: Component callbacks are always called on the main thread of the process
|
|
||||||
@ExternalMainThread
|
|
||||||
@Override
|
|
||||||
public void onTrimMemory(int level) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: Component callbacks are always called on the main thread of the process
|
|
||||||
@ExternalMainThread
|
|
||||||
@Override
|
|
||||||
public void onLowMemory() {
|
|
||||||
// Do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNotificationPanelExpandedChanged(boolean expanded) {
|
private void onNotificationPanelExpandedChanged(boolean expanded) {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import android.graphics.Outline;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Picture;
|
import android.graphics.Picture;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.ShapeDrawable;
|
import android.graphics.drawable.ShapeDrawable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -479,13 +480,18 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
void applyThemeAttrs() {
|
void applyThemeAttrs() {
|
||||||
final TypedArray ta = mContext.obtainStyledAttributes(new int[]{
|
final TypedArray ta = mContext.obtainStyledAttributes(new int[]{
|
||||||
android.R.attr.dialogCornerRadius,
|
android.R.attr.dialogCornerRadius,
|
||||||
com.android.internal.R.attr.materialColorSurfaceBright});
|
com.android.internal.R.attr.materialColorSurfaceBright,
|
||||||
|
com.android.internal.R.attr.materialColorSurfaceContainerHigh});
|
||||||
boolean supportsRoundedCorners = ScreenDecorationsUtils.supportsRoundedCornersOnWindows(
|
boolean supportsRoundedCorners = ScreenDecorationsUtils.supportsRoundedCornersOnWindows(
|
||||||
mContext.getResources());
|
mContext.getResources());
|
||||||
mCornerRadius = supportsRoundedCorners ? ta.getDimensionPixelSize(0, 0) : 0;
|
mCornerRadius = supportsRoundedCorners ? ta.getDimensionPixelSize(0, 0) : 0;
|
||||||
mBackgroundColorFloating = ta.getColor(1, Color.WHITE);
|
mBackgroundColorFloating = ta.getColor(1, Color.WHITE);
|
||||||
mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating);
|
mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating);
|
||||||
|
final int manageMenuBg = ta.getColor(2, Color.WHITE);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
|
if (mManageButton != null) {
|
||||||
|
mManageButton.getBackground().setColorFilter(manageMenuBg, PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
|
|
||||||
if (mTaskView != null) {
|
if (mTaskView != null) {
|
||||||
mTaskView.setCornerRadius(mCornerRadius);
|
mTaskView.setCornerRadius(mCornerRadius);
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Outline;
|
import android.graphics.Outline;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
@@ -1203,6 +1205,12 @@ public class BubbleStackView extends FrameLayout
|
|||||||
R.layout.bubble_manage_menu, this, false);
|
R.layout.bubble_manage_menu, this, false);
|
||||||
mManageMenu.setVisibility(View.INVISIBLE);
|
mManageMenu.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
final TypedArray ta = mContext.obtainStyledAttributes(new int[]{
|
||||||
|
com.android.internal.R.attr.materialColorSurfaceBright});
|
||||||
|
final int menuBackgroundColor = ta.getColor(0, Color.WHITE);
|
||||||
|
ta.recycle();
|
||||||
|
mManageMenu.getBackground().setColorFilter(menuBackgroundColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
PhysicsAnimator.getInstance(mManageMenu).setDefaultSpringConfig(mManageSpringConfig);
|
PhysicsAnimator.getInstance(mManageMenu).setDefaultSpringConfig(mManageSpringConfig);
|
||||||
|
|
||||||
mManageMenu.setOutlineProvider(new ViewOutlineProvider() {
|
mManageMenu.setOutlineProvider(new ViewOutlineProvider() {
|
||||||
|
|||||||
@@ -300,10 +300,6 @@ public class BubblesTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private UserHandle mUser0;
|
private UserHandle mUser0;
|
||||||
|
|
||||||
// The window context being used by the controller, use this to verify
|
|
||||||
// any actions on the context.
|
|
||||||
private Context mBubbleControllerContext;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
@@ -440,8 +436,6 @@ public class BubblesTest extends SysuiTestCase {
|
|||||||
// Get a reference to KeyguardStateController.Callback
|
// Get a reference to KeyguardStateController.Callback
|
||||||
verify(mKeyguardStateController, atLeastOnce())
|
verify(mKeyguardStateController, atLeastOnce())
|
||||||
.addCallback(mKeyguardStateControllerCallbackCaptor.capture());
|
.addCallback(mKeyguardStateControllerCallbackCaptor.capture());
|
||||||
|
|
||||||
mBubbleControllerContext = mBubbleController.getContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -473,6 +467,11 @@ public class BubblesTest extends SysuiTestCase {
|
|||||||
verify(mShellInit, times(1)).addInitCallback(any(), any());
|
verify(mShellInit, times(1)).addInitCallback(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void instantiateController_registerConfigChangeListener() {
|
||||||
|
verify(mShellController, times(1)).addConfigurationChangeListener(any());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddBubble() {
|
public void testAddBubble() {
|
||||||
mBubbleController.updateBubble(mBubbleEntry);
|
mBubbleController.updateBubble(mBubbleEntry);
|
||||||
@@ -1386,28 +1385,13 @@ public class BubblesTest extends SysuiTestCase {
|
|||||||
assertStackCollapsed();
|
assertStackCollapsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRegisterUnregisterComponentCallbacks() {
|
|
||||||
spyOn(mBubbleControllerContext);
|
|
||||||
mBubbleController.updateBubble(mBubbleEntry);
|
|
||||||
verify(mBubbleControllerContext).registerComponentCallbacks(eq(mBubbleController));
|
|
||||||
|
|
||||||
mBubbleData.dismissBubbleWithKey(mBubbleEntry.getKey(), REASON_APP_CANCEL);
|
|
||||||
// TODO: not certain why this isn't called normally when tests are run, perhaps because
|
|
||||||
// it's after an animation in BSV. This calls BubbleController#removeFromWindowManagerMaybe
|
|
||||||
mBubbleController.onAllBubblesAnimatedOut();
|
|
||||||
|
|
||||||
verify(mBubbleControllerContext).unregisterComponentCallbacks(eq(mBubbleController));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegisterUnregisterBroadcastListener() {
|
public void testRegisterUnregisterBroadcastListener() {
|
||||||
spyOn(mBubbleControllerContext);
|
spyOn(mContext);
|
||||||
mBubbleController.updateBubble(mBubbleEntry);
|
mBubbleController.updateBubble(mBubbleEntry);
|
||||||
verify(mBubbleControllerContext).registerReceiver(
|
verify(mContext).registerReceiver(mBroadcastReceiverArgumentCaptor.capture(),
|
||||||
mBroadcastReceiverArgumentCaptor.capture(),
|
mFilterArgumentCaptor.capture(), eq(Context.RECEIVER_EXPORTED));
|
||||||
mFilterArgumentCaptor.capture(),
|
|
||||||
eq(Context.RECEIVER_EXPORTED));
|
|
||||||
assertThat(mFilterArgumentCaptor.getValue()
|
assertThat(mFilterArgumentCaptor.getValue()
|
||||||
.hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)).isTrue();
|
.hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)).isTrue();
|
||||||
assertThat(mFilterArgumentCaptor.getValue()
|
assertThat(mFilterArgumentCaptor.getValue()
|
||||||
@@ -1418,54 +1402,47 @@ public class BubblesTest extends SysuiTestCase {
|
|||||||
// it's after an animation in BSV. This calls BubbleController#removeFromWindowManagerMaybe
|
// it's after an animation in BSV. This calls BubbleController#removeFromWindowManagerMaybe
|
||||||
mBubbleController.onAllBubblesAnimatedOut();
|
mBubbleController.onAllBubblesAnimatedOut();
|
||||||
|
|
||||||
verify(mBubbleControllerContext).unregisterReceiver(
|
verify(mContext).unregisterReceiver(eq(mBroadcastReceiverArgumentCaptor.getValue()));
|
||||||
eq(mBroadcastReceiverArgumentCaptor.getValue()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBroadcastReceiverCloseDialogs_notGestureNav() {
|
public void testBroadcastReceiverCloseDialogs_notGestureNav() {
|
||||||
spyOn(mBubbleControllerContext);
|
spyOn(mContext);
|
||||||
mBubbleController.updateBubble(mBubbleEntry);
|
mBubbleController.updateBubble(mBubbleEntry);
|
||||||
mBubbleData.setExpanded(true);
|
mBubbleData.setExpanded(true);
|
||||||
verify(mBubbleControllerContext).registerReceiver(
|
verify(mContext).registerReceiver(mBroadcastReceiverArgumentCaptor.capture(),
|
||||||
mBroadcastReceiverArgumentCaptor.capture(),
|
mFilterArgumentCaptor.capture(), eq(Context.RECEIVER_EXPORTED));
|
||||||
mFilterArgumentCaptor.capture(),
|
|
||||||
eq(Context.RECEIVER_EXPORTED));
|
|
||||||
Intent i = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
Intent i = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||||
mBroadcastReceiverArgumentCaptor.getValue().onReceive(mBubbleControllerContext, i);
|
mBroadcastReceiverArgumentCaptor.getValue().onReceive(mContext, i);
|
||||||
|
|
||||||
assertStackExpanded();
|
assertStackExpanded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBroadcastReceiverCloseDialogs_reasonGestureNav() {
|
public void testBroadcastReceiverCloseDialogs_reasonGestureNav() {
|
||||||
spyOn(mBubbleControllerContext);
|
spyOn(mContext);
|
||||||
mBubbleController.updateBubble(mBubbleEntry);
|
mBubbleController.updateBubble(mBubbleEntry);
|
||||||
mBubbleData.setExpanded(true);
|
mBubbleData.setExpanded(true);
|
||||||
|
|
||||||
verify(mBubbleControllerContext).registerReceiver(
|
verify(mContext).registerReceiver(mBroadcastReceiverArgumentCaptor.capture(),
|
||||||
mBroadcastReceiverArgumentCaptor.capture(),
|
mFilterArgumentCaptor.capture(), eq(Context.RECEIVER_EXPORTED));
|
||||||
mFilterArgumentCaptor.capture(),
|
|
||||||
eq(Context.RECEIVER_EXPORTED));
|
|
||||||
Intent i = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
Intent i = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||||
i.putExtra("reason", "gestureNav");
|
i.putExtra("reason", "gestureNav");
|
||||||
mBroadcastReceiverArgumentCaptor.getValue().onReceive(mBubbleControllerContext, i);
|
mBroadcastReceiverArgumentCaptor.getValue().onReceive(mContext, i);
|
||||||
assertStackCollapsed();
|
assertStackCollapsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBroadcastReceiver_screenOff() {
|
public void testBroadcastReceiver_screenOff() {
|
||||||
spyOn(mBubbleControllerContext);
|
spyOn(mContext);
|
||||||
mBubbleController.updateBubble(mBubbleEntry);
|
mBubbleController.updateBubble(mBubbleEntry);
|
||||||
mBubbleData.setExpanded(true);
|
mBubbleData.setExpanded(true);
|
||||||
|
|
||||||
verify(mBubbleControllerContext).registerReceiver(
|
verify(mContext).registerReceiver(mBroadcastReceiverArgumentCaptor.capture(),
|
||||||
mBroadcastReceiverArgumentCaptor.capture(),
|
mFilterArgumentCaptor.capture(), eq(Context.RECEIVER_EXPORTED));
|
||||||
mFilterArgumentCaptor.capture(),
|
|
||||||
eq(Context.RECEIVER_EXPORTED));
|
|
||||||
|
|
||||||
Intent i = new Intent(Intent.ACTION_SCREEN_OFF);
|
Intent i = new Intent(Intent.ACTION_SCREEN_OFF);
|
||||||
mBroadcastReceiverArgumentCaptor.getValue().onReceive(mBubbleControllerContext, i);
|
mBroadcastReceiverArgumentCaptor.getValue().onReceive(mContext, i);
|
||||||
assertStackCollapsed();
|
assertStackCollapsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.testing.LeakCheck;
|
import android.testing.LeakCheck;
|
||||||
@@ -63,10 +62,6 @@ public class SysuiTestableContext extends TestableContext {
|
|||||||
return (SysuiTestableContext) createDisplayContext(display);
|
return (SysuiTestableContext) createDisplayContext(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SysuiTestableContext createWindowContext(int type, Bundle bundle) {
|
|
||||||
return new SysuiTestableContext(getBaseContext().createWindowContext(type, bundle));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanUpReceivers(String testName) {
|
public void cleanUpReceivers(String testName) {
|
||||||
Set<BroadcastReceiver> copy;
|
Set<BroadcastReceiver> copy;
|
||||||
synchronized (mRegisteredReceivers) {
|
synchronized (mRegisteredReceivers) {
|
||||||
|
|||||||
Reference in New Issue
Block a user