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

Commit d95ade7f authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Allow AppHandles to report screen positions to interested parties

* Added a new class which takes updates to AppHandle positions and
forwards them to interested listeners.
* SystemUI components can access and add a listener via WMComponent

Bug: 397506207
Flag: EXEMPT bug fix
Test: Tested via logs to see both ends of listener are working

Change-Id: Ie0cb5b4915fdd44437bd4e578b3b0af99bbb5485
parent f8f213e1
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -36,12 +36,13 @@ import com.android.wm.shell.splitscreen.SplitScreen;
import com.android.wm.shell.startingsurface.StartingSurface;
import com.android.wm.shell.sysui.ShellInterface;
import com.android.wm.shell.taskview.TaskViewFactory;
import com.android.wm.shell.windowdecor.viewholder.AppHandles;

import java.util.Optional;

import dagger.BindsInstance;
import dagger.Subcomponent;

import java.util.Optional;

/**
 * Dagger Subcomponent for WindowManager.  This class explicitly describes the interfaces exported
 * from the WM component into the SysUI component, and references the specific dependencies
@@ -120,6 +121,9 @@ public interface WMComponent {
    @WMSingleton
    Optional<AppZoomOut> getAppZoomOut();

    @WMSingleton
    Optional<AppHandles> getAppHandles();

    // Injector methods to support field injection

    /** Injector method for {@link BubbleBarExpandedView}. */
+16 −0
Original line number Diff line number Diff line
@@ -144,6 +144,8 @@ import com.android.wm.shell.unfold.ShellUnfoldProgressProvider;
import com.android.wm.shell.unfold.UnfoldAnimationController;
import com.android.wm.shell.unfold.UnfoldTransitionHandler;
import com.android.wm.shell.windowdecor.WindowDecorViewModel;
import com.android.wm.shell.windowdecor.viewholder.AppHandleNotifier;
import com.android.wm.shell.windowdecor.viewholder.AppHandles;

import dagger.BindsOptionalOf;
import dagger.Lazy;
@@ -1111,6 +1113,19 @@ public abstract class WMShellBaseModule {
                transitions);
    }

    //
    // AppHandle
    //

    @WMSingleton
    @Provides
    static Optional<AppHandles> provideAppHandles(Optional<AppHandleNotifier> appHandleNotifier) {
        return appHandleNotifier.map(AppHandleNotifier::asAppHandleImpl);
    }

    @BindsOptionalOf
    abstract AppHandleNotifier getAppHandleNotifier();

    //
    // Misc
    //
@@ -1140,6 +1155,7 @@ public abstract class WMShellBaseModule {
            Optional<RecentsTransitionHandler> recentsTransitionHandlerOptional,
            Optional<OneHandedController> oneHandedControllerOptional,
            Optional<AppZoomOutController> appZoomOutControllerOptional,
            Optional<AppHandles> appHandlesOptional,
            Optional<HideDisplayCutoutController> hideDisplayCutoutControllerOptional,
            Optional<ActivityEmbeddingController> activityEmbeddingOptional,
            Optional<MixedTransitionHandler> mixedTransitionHandler,
+15 −7
Original line number Diff line number Diff line
@@ -189,20 +189,20 @@ import com.android.wm.shell.windowdecor.common.viewhost.WindowDecorViewHostSuppl
import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationPromoController;
import com.android.wm.shell.windowdecor.education.DesktopWindowingEducationTooltipController;
import com.android.wm.shell.windowdecor.tiling.DesktopTilingDecorViewModel;
import com.android.wm.shell.windowdecor.viewholder.AppHandleNotifier;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import dagger.Binds;
import dagger.Lazy;
import dagger.Module;
import dagger.Provides;

import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.ExperimentalCoroutinesApi;
import kotlinx.coroutines.MainCoroutineDispatcher;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * Provides dependencies from {@link com.android.wm.shell}, these dependencies are only accessible
 * from components within the WM subcomponent (can be explicitly exposed to the SysUIComponent, see
@@ -1127,7 +1127,8 @@ public abstract class WMShellModule {
            Optional<CompatUIHandler> compatUI,
            DesksOrganizer desksOrganizer,
            DesktopState desktopState,
            DesktopConfig desktopConfig
            DesktopConfig desktopConfig,
            AppHandleNotifier appHandleNotifier
    ) {
        if (!desktopState.canEnterDesktopModeOrShowAppHandle()) {
            return Optional.empty();
@@ -1146,7 +1147,7 @@ public abstract class WMShellModule {
                desktopModeUiEventLogger, taskResourceLoader, recentsTransitionHandler,
                desktopModeCompatPolicy, desktopTilingDecorViewModel,
                multiDisplayDragMoveIndicatorController, compatUI.orElse(null),
                desksOrganizer, desktopState, desktopConfig));
                desksOrganizer, desktopState, desktopConfig, appHandleNotifier));
    }

    @WMSingleton
@@ -1459,6 +1460,13 @@ public abstract class WMShellModule {
                        desktopState));
    }

    @WMSingleton
    @Provides
    static AppHandleNotifier provideAppHandleNotifier(
            @ShellMainThread ShellExecutor shellExecutor) {
        return new AppHandleNotifier(shellExecutor);
    }

    @WMSingleton
    @Provides
    static AppHandleEducationDatastoreRepository provideAppHandleEducationDatastoreRepository(
+3 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ public enum ShellProtoLogGroup implements IProtoLogGroup {
            Consts.TAG_WM_COMPAT_UI),
    WM_SHELL_APP_COMPAT(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
            Consts.TAG_WM_APP_COMPAT),
    WM_SHELL_APP_HANDLES(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
            Consts.TAG_WM_APP_HANDLES),
    TEST_GROUP(true, true, false, "WindowManagerShellProtoLogTest");

    private final boolean mEnabled;
@@ -139,6 +141,7 @@ public enum ShellProtoLogGroup implements IProtoLogGroup {
        private static final String TAG_WM_COMPAT_UI = "CompatUi";
        private static final String TAG_WM_APP_COMPAT = "AppCompat";
        private static final String TAG_WM_BUBBLES = "Bubbles";
        private static final String TAG_WM_APP_HANDLES = "AppHandles";

        private static final boolean ENABLE_DEBUG = true;
        private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true;
+7 −3
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ import com.android.wm.shell.windowdecor.extension.InsetsStateKt;
import com.android.wm.shell.windowdecor.extension.TaskInfoKt;
import com.android.wm.shell.windowdecor.tiling.DesktopTilingDecorViewModel;
import com.android.wm.shell.windowdecor.tiling.SnapEventHandler;
import com.android.wm.shell.windowdecor.viewholder.AppHandleNotifier;
import com.android.wm.shell.windowdecor.viewholder.AppHandleViewHolder;
import com.android.wm.shell.windowdecor.viewholder.AppHeaderViewHolder;

@@ -317,7 +318,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            CompatUIHandler compatUI,
            DesksOrganizer desksOrganizer,
            DesktopState desktopState,
            DesktopConfig desktopConfig) {
            DesktopConfig desktopConfig,
            AppHandleNotifier appHandleNotifier) {
        this(
                context,
                shellExecutor,
@@ -368,7 +370,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                compatUI,
                desksOrganizer,
                desktopState,
                desktopConfig);
                desktopConfig,
                appHandleNotifier);
    }

    @VisibleForTesting
@@ -422,7 +425,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            CompatUIHandler compatUI,
            DesksOrganizer desksOrganizer,
            DesktopState desktopState,
            DesktopConfig desktopConfig) {
            DesktopConfig desktopConfig,
            AppHandleNotifier appHandleNotifier) {
        mContext = context;
        mMainExecutor = shellExecutor;
        mMainHandler = mainHandler;
Loading