Provides OneHandedController for wm shell features
Provides OneHandedController singleton instance through dagger. Then Bubble can register OneHandedTransitionCallback to monitor - onStartFinished(Rect bounds) - onStopFinished(Rect bounds) and use the bounds.top to offset dismiss view in one handed mode Test: Manual, enable and check onStateChanged() callbacks Test: atest WMShellUnitTests Bug: 208926540 Change-Id: I2c3f70ce6344a4445049ee6d8be2d4965ea9d11d
This commit is contained in:
@@ -89,6 +89,8 @@ import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.TaskStackListenerCallback;
|
||||
import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||
import com.android.wm.shell.onehanded.OneHandedController;
|
||||
import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
|
||||
import com.android.wm.shell.pip.PinnedStackListenerForwarder;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -98,6 +100,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
@@ -198,6 +201,9 @@ public class BubbleController {
|
||||
/** True when user is in status bar unlock shade. */
|
||||
private boolean mIsStatusBarShade = true;
|
||||
|
||||
/** One handed mode controller to register transition listener. */
|
||||
private Optional<OneHandedController> mOneHandedOptional;
|
||||
|
||||
/**
|
||||
* Creates an instance of the BubbleController.
|
||||
*/
|
||||
@@ -212,6 +218,7 @@ public class BubbleController {
|
||||
UiEventLogger uiEventLogger,
|
||||
ShellTaskOrganizer organizer,
|
||||
DisplayController displayController,
|
||||
Optional<OneHandedController> oneHandedOptional,
|
||||
ShellExecutor mainExecutor,
|
||||
Handler mainHandler,
|
||||
TaskViewTransitions taskViewTransitions,
|
||||
@@ -222,8 +229,9 @@ public class BubbleController {
|
||||
return new BubbleController(context, data, synchronizer, floatingContentCoordinator,
|
||||
new BubbleDataRepository(context, launcherApps, mainExecutor),
|
||||
statusBarService, windowManager, windowManagerShellWrapper, launcherApps,
|
||||
logger, taskStackListener, organizer, positioner, displayController, mainExecutor,
|
||||
mainHandler, taskViewTransitions, syncQueue);
|
||||
logger, taskStackListener, organizer, positioner, displayController,
|
||||
oneHandedOptional, mainExecutor, mainHandler, taskViewTransitions,
|
||||
syncQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,6 +252,7 @@ public class BubbleController {
|
||||
ShellTaskOrganizer organizer,
|
||||
BubblePositioner positioner,
|
||||
DisplayController displayController,
|
||||
Optional<OneHandedController> oneHandedOptional,
|
||||
ShellExecutor mainExecutor,
|
||||
Handler mainHandler,
|
||||
TaskViewTransitions taskViewTransitions,
|
||||
@@ -271,9 +280,25 @@ public class BubbleController {
|
||||
mBubbleIconFactory = new BubbleIconFactory(context);
|
||||
mDisplayController = displayController;
|
||||
mTaskViewTransitions = taskViewTransitions;
|
||||
mOneHandedOptional = oneHandedOptional;
|
||||
mSyncQueue = syncQueue;
|
||||
}
|
||||
|
||||
private static void registerOneHandedState(OneHandedController oneHanded) {
|
||||
oneHanded.registerTransitionCallback(
|
||||
new OneHandedTransitionCallback() {
|
||||
@Override
|
||||
public void onStartFinished(Rect bounds) {
|
||||
// TODO(b/198403767) mStackView.offSetY(int bounds.top)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopFinished(Rect bounds) {
|
||||
// TODO(b/198403767) mStackView.offSetY(int bounds.top)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
mBubbleData.setListener(mBubbleDataListener);
|
||||
mBubbleData.setSuppressionChangedListener(this::onBubbleNotificationSuppressionChanged);
|
||||
@@ -397,6 +422,8 @@ public class BubbleController {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mOneHandedOptional.ifPresent(BubbleController::registerOneHandedState);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -362,7 +362,6 @@ public abstract class WMShellBaseModule {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Task to Surface communication
|
||||
//
|
||||
|
||||
@@ -107,6 +107,7 @@ public class WMShellModule {
|
||||
UiEventLogger uiEventLogger,
|
||||
ShellTaskOrganizer organizer,
|
||||
DisplayController displayController,
|
||||
@DynamicOverride Optional<OneHandedController> oneHandedOptional,
|
||||
@ShellMainThread ShellExecutor mainExecutor,
|
||||
@ShellMainThread Handler mainHandler,
|
||||
TaskViewTransitions taskViewTransitions,
|
||||
@@ -114,8 +115,8 @@ public class WMShellModule {
|
||||
return BubbleController.create(context, null /* synchronizer */,
|
||||
floatingContentCoordinator, statusBarService, windowManager,
|
||||
windowManagerShellWrapper, launcherApps, taskStackListener,
|
||||
uiEventLogger, organizer, displayController, mainExecutor, mainHandler,
|
||||
taskViewTransitions, syncQueue);
|
||||
uiEventLogger, organizer, displayController, oneHandedOptional,
|
||||
mainExecutor, mainHandler, taskViewTransitions, syncQueue);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -142,12 +143,10 @@ public class WMShellModule {
|
||||
static OneHandedController provideOneHandedController(Context context,
|
||||
WindowManager windowManager, DisplayController displayController,
|
||||
DisplayLayout displayLayout, TaskStackListenerImpl taskStackListener,
|
||||
UiEventLogger uiEventLogger,
|
||||
@ShellMainThread ShellExecutor mainExecutor,
|
||||
UiEventLogger uiEventLogger, @ShellMainThread ShellExecutor mainExecutor,
|
||||
@ShellMainThread Handler mainHandler) {
|
||||
return OneHandedController.create(context, windowManager,
|
||||
displayController, displayLayout, taskStackListener, uiEventLogger, mainExecutor,
|
||||
mainHandler);
|
||||
return OneHandedController.create(context, windowManager, displayController, displayLayout,
|
||||
taskStackListener, uiEventLogger, mainExecutor, mainHandler);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -198,7 +198,7 @@ public class OneHandedController implements RemoteCallable<OneHandedController>,
|
||||
OneHandedSettingsUtil settingsUtil = new OneHandedSettingsUtil();
|
||||
OneHandedAccessibilityUtil accessibilityUtil = new OneHandedAccessibilityUtil(context);
|
||||
OneHandedTimeoutHandler timeoutHandler = new OneHandedTimeoutHandler(mainExecutor);
|
||||
OneHandedState transitionState = new OneHandedState();
|
||||
OneHandedState oneHandedState = new OneHandedState();
|
||||
OneHandedTutorialHandler tutorialHandler = new OneHandedTutorialHandler(context,
|
||||
settingsUtil, windowManager);
|
||||
OneHandedAnimationController animationController =
|
||||
@@ -216,7 +216,7 @@ public class OneHandedController implements RemoteCallable<OneHandedController>,
|
||||
ServiceManager.getService(Context.OVERLAY_SERVICE));
|
||||
return new OneHandedController(context, displayController,
|
||||
oneHandedBackgroundPanelOrganizer, organizer, touchHandler, tutorialHandler,
|
||||
settingsUtil, accessibilityUtil, timeoutHandler, transitionState,
|
||||
settingsUtil, accessibilityUtil, timeoutHandler, oneHandedState,
|
||||
oneHandedUiEventsLogger, overlayManager, taskStackListener, mainExecutor,
|
||||
mainHandler);
|
||||
}
|
||||
@@ -392,8 +392,10 @@ public class OneHandedController implements RemoteCallable<OneHandedController>,
|
||||
mEventCallback = callback;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void registerTransitionCallback(OneHandedTransitionCallback callback) {
|
||||
/**
|
||||
* Registers {@link OneHandedTransitionCallback} to monitor the transition status
|
||||
*/
|
||||
public void registerTransitionCallback(OneHandedTransitionCallback callback) {
|
||||
mDisplayAreaOrganizer.registerTransitionCallback(callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||
import com.android.wm.shell.onehanded.OneHandedController;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -138,6 +139,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Tests the NotificationEntryManager setup with BubbleController.
|
||||
@@ -249,6 +251,8 @@ public class BubblesTest extends SysuiTestCase {
|
||||
private AuthController mAuthController;
|
||||
@Mock
|
||||
private TaskViewTransitions mTaskViewTransitions;
|
||||
@Mock
|
||||
private Optional<OneHandedController> mOneHandedOptional;
|
||||
|
||||
private TestableBubblePositioner mPositioner;
|
||||
|
||||
@@ -345,6 +349,7 @@ public class BubblesTest extends SysuiTestCase {
|
||||
mShellTaskOrganizer,
|
||||
mPositioner,
|
||||
mock(DisplayController.class),
|
||||
mOneHandedOptional,
|
||||
syncExecutor,
|
||||
mock(Handler.class),
|
||||
mTaskViewTransitions,
|
||||
|
||||
@@ -19,8 +19,11 @@ package com.android.systemui.wmshell;
|
||||
import static android.app.Notification.FLAG_BUBBLE;
|
||||
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
|
||||
import static android.service.notification.NotificationListenerService.REASON_GROUP_SUMMARY_CANCELED;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -105,6 +108,7 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||
import com.android.wm.shell.onehanded.OneHandedController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
@@ -116,6 +120,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Tests the NotifPipeline setup with BubbleController.
|
||||
@@ -220,6 +225,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
|
||||
private ScreenOffAnimationController mScreenOffAnimationController;
|
||||
@Mock
|
||||
private TaskViewTransitions mTaskViewTransitions;
|
||||
@Mock
|
||||
private Optional<OneHandedController> mOneHandedOptional;
|
||||
|
||||
private TestableBubblePositioner mPositioner;
|
||||
|
||||
@@ -307,6 +314,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
|
||||
mShellTaskOrganizer,
|
||||
mPositioner,
|
||||
mock(DisplayController.class),
|
||||
mOneHandedOptional,
|
||||
syncExecutor,
|
||||
mock(Handler.class),
|
||||
mTaskViewTransitions,
|
||||
|
||||
@@ -35,6 +35,9 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||
import com.android.wm.shell.onehanded.OneHandedController;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Testable BubbleController subclass that immediately synchronizes surfaces.
|
||||
@@ -55,6 +58,7 @@ public class TestableBubbleController extends BubbleController {
|
||||
ShellTaskOrganizer shellTaskOrganizer,
|
||||
BubblePositioner positioner,
|
||||
DisplayController displayController,
|
||||
Optional<OneHandedController> oneHandedOptional,
|
||||
ShellExecutor shellMainExecutor,
|
||||
Handler shellMainHandler,
|
||||
TaskViewTransitions taskViewTransitions,
|
||||
@@ -62,7 +66,8 @@ public class TestableBubbleController extends BubbleController {
|
||||
super(context, data, Runnable::run, floatingContentCoordinator, dataRepository,
|
||||
statusBarService, windowManager, windowManagerShellWrapper, launcherApps,
|
||||
bubbleLogger, taskStackListener, shellTaskOrganizer, positioner, displayController,
|
||||
shellMainExecutor, shellMainHandler, taskViewTransitions, syncQueue);
|
||||
oneHandedOptional, shellMainExecutor, shellMainHandler, taskViewTransitions,
|
||||
syncQueue);
|
||||
setInflateSynchronously(true);
|
||||
initialize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user