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

Commit e3e90bd0 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge changes from topic "revert-13608835-shell_feature_interfaces-HRAUSTBFGW" into sc-dev

* changes:
  Revert "1/ Add mechanism to expose shell feature directly (for Pip)"
  Revert "2/ Add mechanism to expose other features directly"
parents e85b1a6c 64b8381c
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -38,14 +38,6 @@ filegroup {
    path: "src",
}

filegroup {
    name: "wm_shell-aidls",
    srcs: [
        "src/**/*.aidl",
    ],
    path: "src",
}

// TODO(b/168581922) protologtool do not support kotlin(*.kt)
filegroup {
    name: "wm_shell-sources-kt",
@@ -106,7 +98,7 @@ android_library {
        ":wm_shell_protolog_src",
        // TODO(b/168581922) protologtool do not support kotlin(*.kt)
        ":wm_shell-sources-kt",
        ":wm_shell-aidls",
        "src/**/I*.aidl",
    ],
    resource_dirs: [
        "res",
+15 −5
Original line number Diff line number Diff line
@@ -47,7 +47,21 @@ public final class ShellCommandHandlerImpl {
    private final ShellExecutor mMainExecutor;
    private final HandlerImpl mImpl = new HandlerImpl();

    public ShellCommandHandlerImpl(
    public static ShellCommandHandler create(
            ShellTaskOrganizer shellTaskOrganizer,
            Optional<LegacySplitScreenController> legacySplitScreenOptional,
            Optional<SplitScreenController> splitScreenOptional,
            Optional<Pip> pipOptional,
            Optional<OneHandedController> oneHandedOptional,
            Optional<HideDisplayCutoutController> hideDisplayCutout,
            Optional<AppPairsController> appPairsOptional,
            ShellExecutor mainExecutor) {
        return new ShellCommandHandlerImpl(shellTaskOrganizer, legacySplitScreenOptional,
                splitScreenOptional, pipOptional, oneHandedOptional, hideDisplayCutout,
                appPairsOptional, mainExecutor).mImpl;
    }

    private ShellCommandHandlerImpl(
            ShellTaskOrganizer shellTaskOrganizer,
            Optional<LegacySplitScreenController> legacySplitScreenOptional,
            Optional<SplitScreenController> splitScreenOptional,
@@ -66,10 +80,6 @@ public final class ShellCommandHandlerImpl {
        mMainExecutor = mainExecutor;
    }

    public ShellCommandHandler asShellCommandHandler() {
        return mImpl;
    }

    /** Dumps WM Shell internal state. */
    private void dump(PrintWriter pw) {
        mShellTaskOrganizer.dump(pw, "");
+31 −11
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreenController;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.startingsurface.StartingWindowController;
import com.android.wm.shell.startingsurface.StartingSurface;
import com.android.wm.shell.transition.Transitions;

import java.util.Optional;
@@ -47,20 +47,44 @@ public class ShellInitImpl {
    private final FullscreenTaskListener mFullscreenTaskListener;
    private final ShellExecutor mMainExecutor;
    private final Transitions mTransitions;
    private final StartingWindowController mStartingWindow;
    private final Optional<StartingSurface> mStartingSurfaceOptional;

    private final InitImpl mImpl = new InitImpl();

    public ShellInitImpl(DisplayImeController displayImeController,
    public static ShellInit create(DisplayImeController displayImeController,
            DragAndDropController dragAndDropController,
            ShellTaskOrganizer shellTaskOrganizer,
            Optional<LegacySplitScreenController> legacySplitScreenOptional,
            Optional<SplitScreenController> splitScreenOptional,
            Optional<AppPairsController> appPairsOptional,
            Optional<StartingSurface> startingSurfaceOptional,
            Optional<PipTouchHandler> pipTouchHandlerOptional,
            FullscreenTaskListener fullscreenTaskListener,
            Transitions transitions,
            ShellExecutor mainExecutor) {
        return new ShellInitImpl(displayImeController,
                dragAndDropController,
                shellTaskOrganizer,
                legacySplitScreenOptional,
                splitScreenOptional,
                appPairsOptional,
                startingSurfaceOptional,
                pipTouchHandlerOptional,
                fullscreenTaskListener,
                transitions,
                mainExecutor).mImpl;
    }

    private ShellInitImpl(DisplayImeController displayImeController,
            DragAndDropController dragAndDropController,
            ShellTaskOrganizer shellTaskOrganizer,
            Optional<LegacySplitScreenController> legacySplitScreenOptional,
            Optional<SplitScreenController> splitScreenOptional,
            Optional<AppPairsController> appPairsOptional,
            Optional<StartingSurface> startingSurfaceOptional,
            Optional<PipTouchHandler> pipTouchHandlerOptional,
            FullscreenTaskListener fullscreenTaskListener,
            Transitions transitions,
            StartingWindowController startingWindow,
            ShellExecutor mainExecutor) {
        mDisplayImeController = displayImeController;
        mDragAndDropController = dragAndDropController;
@@ -72,21 +96,17 @@ public class ShellInitImpl {
        mPipTouchHandlerOptional = pipTouchHandlerOptional;
        mTransitions = transitions;
        mMainExecutor = mainExecutor;
        mStartingWindow = startingWindow;
    }

    public ShellInit asShellInit() {
        return mImpl;
        mStartingSurfaceOptional = startingSurfaceOptional;
    }

    private void init() {
        // Start listening for display changes
        mDisplayImeController.startMonitorDisplays();

        // Setup the shell organizer
        mShellTaskOrganizer.addListenerForType(
                mFullscreenTaskListener, TASK_LISTENER_TYPE_FULLSCREEN);
        mShellTaskOrganizer.initStartingWindow(mStartingWindow);
        mStartingSurfaceOptional.ifPresent(mShellTaskOrganizer::initStartingSurface);
        // Register the shell organizer
        mShellTaskOrganizer.registerOrganizer();

        mAppPairsOptional.ifPresent(AppPairsController::onOrganizerRegistered);
+10 −10
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.sizecompatui.SizeCompatUIController;
import com.android.wm.shell.startingsurface.StartingWindowController;
import com.android.wm.shell.startingsurface.StartingSurface;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -133,7 +133,7 @@ public class ShellTaskOrganizer extends TaskOrganizer {
    private final ArraySet<LocusIdListener> mLocusIdListeners = new ArraySet<>();

    private final Object mLock = new Object();
    private StartingWindowController mStartingWindow;
    private StartingSurface mStartingSurface;

    /**
     * In charge of showing size compat UI. Can be {@code null} if device doesn't support size
@@ -184,8 +184,8 @@ public class ShellTaskOrganizer extends TaskOrganizer {
    /**
     * @hide
     */
    public void initStartingWindow(StartingWindowController startingWindow) {
        mStartingWindow = startingWindow;
    public void initStartingSurface(StartingSurface startingSurface) {
        mStartingSurface = startingSurface;
    }

    /**
@@ -302,23 +302,23 @@ public class ShellTaskOrganizer extends TaskOrganizer {

    @Override
    public void addStartingWindow(StartingWindowInfo info, IBinder appToken) {
        if (mStartingWindow != null) {
            mStartingWindow.addStartingWindow(info, appToken);
        if (mStartingSurface != null) {
            mStartingSurface.addStartingWindow(info, appToken);
        }
    }

    @Override
    public void removeStartingWindow(int taskId, SurfaceControl leash, Rect frame,
            boolean playRevealAnimation) {
        if (mStartingWindow != null) {
            mStartingWindow.removeStartingWindow(taskId, leash, frame, playRevealAnimation);
        if (mStartingSurface != null) {
            mStartingSurface.removeStartingWindow(taskId, leash, frame, playRevealAnimation);
        }
    }

    @Override
    public void copySplashScreenView(int taskId) {
        if (mStartingWindow != null) {
            mStartingWindow.copySplashScreenView(taskId);
        if (mStartingSurface != null) {
            mStartingSurface.copySplashScreenView(taskId);
        }
    }

+0 −64
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.wm.shell.common;

import android.Manifest;
import android.util.Slog;

import java.util.function.Consumer;

/**
 * Helpers for working with executors
 */
public class ExecutorUtils {

    /**
     * Checks that the caller has the MANAGE_ACTIVITY_TASKS permission and executes the given
     * callback.
     */
    public static <T> void executeRemoteCallWithTaskPermission(RemoteCallable<T> controllerInstance,
            String log, Consumer<T> callback) {
        executeRemoteCallWithTaskPermission(controllerInstance, log, callback,
                false /* blocking */);
    }

    /**
     * Checks that the caller has the MANAGE_ACTIVITY_TASKS permission and executes the given
     * callback.
     */
    public static <T> void executeRemoteCallWithTaskPermission(RemoteCallable<T> controllerInstance,
            String log, Consumer<T> callback, boolean blocking) {
        if (controllerInstance == null) return;

        final RemoteCallable<T> controller = controllerInstance;
        controllerInstance.getContext().enforceCallingPermission(
                Manifest.permission.MANAGE_ACTIVITY_TASKS, log);
        if (blocking) {
            try {
                controllerInstance.getRemoteCallExecutor().executeBlocking(() -> {
                    callback.accept((T) controller);
                });
            } catch (InterruptedException e) {
                Slog.e("ExecutorUtils", "Remote call failed", e);
            }
        } else {
            controllerInstance.getRemoteCallExecutor().execute(() -> {
                callback.accept((T) controller);
            });
        }
    }
}
Loading