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

Commit e1fe7fa2 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Added TaskWindowContainerController

For linking TaskRecord in AMS to Task window container in WMS.

Bug: 30060889
Test: bit FrameworksServicesTests:com.android.server.wm.AppWindowContainerControllerTests
Test: bit FrameworksServicesTests:com.android.server.wm.TaskWindowContainerControllerTests
Test: Existing test pass and manual testing.
Change-Id: I16248f3e96e5087ba24198a48a3bd10a12ae76a6
parent 74bf3501
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -590,6 +590,12 @@ interface IActivityManager {
    void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback);
    int restartUserInBackground(int userId);

    /** Cancels the window transitions for the given task. */
    void cancelTaskWindowTransition(int taskId);

    /** Cancels the thumbnail transitions for the given task. */
    void cancelTaskThumbnailTransition(int taskId);

    // WARNING: when these transactions are updated, check if they are any callers on the native
    // side. If so, make sure they are using the correct transaction ids and arguments.
    // If a transaction which will also be used on the native side is being inserted, add it
+0 −10
Original line number Diff line number Diff line
@@ -190,16 +190,6 @@ interface IWindowManager
    void enableSurfaceTrace(in ParcelFileDescriptor fd);
    void disableSurfaceTrace();

    /**
     * Cancels the window transitions for the given task.
     */
    void cancelTaskWindowTransition(int taskId);

    /**
     * Cancels the thumbnail transitions for the given task.
     */
    void cancelTaskThumbnailTransition(int taskId);

    // These can only be called with the SET_ORIENTATION permission.
    /**
     * Update the current screen rotation based on the current state of
+4 −4
Original line number Diff line number Diff line
@@ -561,10 +561,10 @@ public class SystemServicesProxy {
     * Cancels the current window transtion to/from Recents for the given task id.
     */
    public void cancelWindowTransition(int taskId) {
        if (mWm == null) return;
        if (mIam == null) return;

        try {
            WindowManagerGlobal.getWindowManagerService().cancelTaskWindowTransition(taskId);
            mIam.cancelTaskWindowTransition(taskId);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
@@ -574,10 +574,10 @@ public class SystemServicesProxy {
     * Cancels the current thumbnail transtion to/from Recents for the given task id.
     */
    public void cancelThumbnailTransition(int taskId) {
        if (mWm == null) return;
        if (mIam == null) return;

        try {
            WindowManagerGlobal.getWindowManagerService().cancelTaskThumbnailTransition(taskId);
            mIam.cancelTaskThumbnailTransition(taskId);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
+54 −18
Original line number Diff line number Diff line
@@ -367,6 +367,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBLE_B
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.am.ActivityStackSupervisor.ActivityContainer.FORCE_NEW_TASK_FLAGS;
import static com.android.server.am.ActivityStackSupervisor.CREATE_IF_NEEDED;
import static com.android.server.am.ActivityStackSupervisor.DEFER_RESUME;
import static com.android.server.am.ActivityStackSupervisor.FORCE_FOCUS;
import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
@@ -9527,12 +9528,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                Slog.w(TAG, "setTaskResizeable: taskId=" + taskId + " not found");
                return;
            }
            if (task.mResizeMode != resizeableMode) {
                task.mResizeMode = resizeableMode;
                mWindowManager.setTaskResizeable(taskId, resizeableMode);
                mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
                mStackSupervisor.resumeFocusedStackTopActivityLocked();
            }
            task.setResizeMode(resizeableMode);
        }
    }
@@ -9565,13 +9561,12 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
                boolean preserveWindow = (resizeMode & RESIZE_MODE_PRESERVE_WINDOW) != 0;
                if (stackId != task.getStackId()) {
                    mStackSupervisor.moveTaskToStackUncheckedLocked(
                            task, stackId, ON_TOP, !FORCE_FOCUS, "resizeTask");
                    mStackSupervisor.moveTaskToStackUncheckedLocked(task, stackId, ON_TOP,
                            !FORCE_FOCUS, "resizeTask", true /* allowStackOnTop */);
                    preserveWindow = false;
                }
                mStackSupervisor.resizeTaskLocked(task, bounds, resizeMode, preserveWindow,
                        false /* deferResume */);
                task.resize(bounds, resizeMode, preserveWindow, false /* deferResume */);
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
@@ -9594,7 +9589,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (task.getStack() != null) {
                    // Return the bounds from window manager since it will be adjusted for various
                    // things like the presense of a docked stack for tasks that aren't resizeable.
                    mWindowManager.getTaskBounds(task.taskId, rect);
                    task.getWindowContainerBounds(rect);
                } else {
                    // Task isn't in window manager yet since it isn't associated with a stack.
                    // Return the persist value from activity manager
@@ -9611,6 +9606,44 @@ public class ActivityManagerService extends IActivityManager.Stub
        return rect;
    }
    @Override
    public void cancelTaskWindowTransition(int taskId) {
        enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "cancelTaskWindowTransition()");
        final long ident = Binder.clearCallingIdentity();
        try {
            synchronized (this) {
                final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(
                        taskId, !RESTORE_FROM_RECENTS, INVALID_STACK_ID);
                if (task == null) {
                    Slog.w(TAG, "cancelTaskWindowTransition: taskId=" + taskId + " not found");
                    return;
                }
                task.cancelWindowTransition();
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
    @Override
    public void cancelTaskThumbnailTransition(int taskId) {
        enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "cancelTaskThumbnailTransition()");
        final long ident = Binder.clearCallingIdentity();
        try {
            synchronized (this) {
                final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(
                        taskId, !RESTORE_FROM_RECENTS, INVALID_STACK_ID);
                if (task == null) {
                    Slog.w(TAG, "cancelTaskThumbnailTransition: taskId=" + taskId + " not found");
                    return;
                }
                task.cancelThumbnailTransition();
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
    @Override
    public Bitmap getTaskDescriptionIcon(String filePath, int userId) {
        if (userId != UserHandle.getCallingUserId()) {
@@ -9949,7 +9982,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                // Defer the resume so resume/pausing while moving stacks is dangerous.
                mStackSupervisor.moveTaskToStackLocked(topTask.taskId, DOCKED_STACK_ID,
                        false /* toTop */, !FORCE_FOCUS, "swapDockedAndFullscreenStack",
                        ANIMATE, true /* deferResume */);
                        ANIMATE, true /* deferResume */, true /* allowStackOnTop */);
                final int size = tasks.size();
                for (int i = 0; i < size; i++) {
                    final int id = tasks.get(i).taskId;
@@ -9958,7 +9991,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                    mStackSupervisor.moveTaskToStackLocked(id,
                            FULLSCREEN_WORKSPACE_STACK_ID, true /* toTop */, !FORCE_FOCUS,
                            "swapDockedAndFullscreenStack", ANIMATE, true /* deferResume */);
                            "swapDockedAndFullscreenStack", ANIMATE, true /* deferResume */,
                            true /* allowStackOnTop */);
                }
                // Because we deferred the resume, to avoid conflicts with stack switches while
@@ -9999,7 +10033,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                mWindowManager.setDockedStackCreateState(createMode, initialBounds);
                final boolean moved = mStackSupervisor.moveTaskToStackLocked(
                        taskId, DOCKED_STACK_ID, toTop, !FORCE_FOCUS, "moveTaskToDockedStack",
                        animate, DEFER_RESUME);
                        animate, DEFER_RESUME, true /* allowStackOnTop */);
                if (moved) {
                    if (moveHomeStackFront) {
                        mStackSupervisor.moveHomeStackToFront("moveTaskToDockedStack");
@@ -10113,10 +10147,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        synchronized (this) {
            long ident = Binder.clearCallingIdentity();
            try {
                if (DEBUG_STACK) Slog.d(TAG_STACK,
                        "positionTaskInStack: positioning task=" + taskId
                        + " in stackId=" + stackId + " at position=" + position);
                mStackSupervisor.positionTaskInStackLocked(taskId, stackId, position);
                if (DEBUG_STACK) Slog.d(TAG_STACK, "positionTaskInStack: positioning task="
                        + taskId + " in stackId=" + stackId + " at position=" + position);
                final ActivityStack stack = mStackSupervisor.getStack(stackId, CREATE_IF_NEEDED,
                        !ON_TOP);
                stack.positionChildAt(taskId, position);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
+9 −10
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VER
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.os.Build.VERSION_CODES.HONEYCOMB;
import static android.os.Process.SYSTEM_UID;
import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_CONFIGURATION;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SAVED_STATE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SCREENSHOTS;
@@ -75,7 +74,6 @@ import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.IBinder;
@@ -103,6 +101,7 @@ import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
import com.android.server.wm.AppWindowContainerController;
import com.android.server.wm.AppWindowContainerListener;
import com.android.server.wm.TaskWindowContainerController;

import java.io.File;
import java.io.IOException;
@@ -724,6 +723,10 @@ final class ActivityRecord implements AppWindowContainerListener {
                null : ComponentName.unflattenFromString(aInfo.requestedVrComponent);
    }

    AppWindowContainerController getWindowContainerController() {
        return mWindowContainerController;
    }

    void createWindowContainer() {
        if (mWindowContainerController != null) {
            throw new IllegalArgumentException("Window container=" + mWindowContainerController
@@ -734,9 +737,10 @@ final class ActivityRecord implements AppWindowContainerListener {
        inHistory = true;

        task.updateOverrideConfigurationFromLaunchBounds();
        final TaskWindowContainerController taskController = task.getWindowContainerController();

        mWindowContainerController = new AppWindowContainerController(appToken, this, task.taskId,
                Integer.MAX_VALUE /* add on top */, info.screenOrientation, fullscreen,
        mWindowContainerController = new AppWindowContainerController(taskController, appToken,
                this, Integer.MAX_VALUE /* add on top */, info.screenOrientation, fullscreen,
                (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, info.configChanges,
                task.voiceSession != null, mLaunchTaskBehind, isAlwaysFocusable(),
                appInfo.targetSdkVersion, mRotationAnimationHint,
@@ -749,12 +753,7 @@ final class ActivityRecord implements AppWindowContainerListener {

    void removeWindowContainer() {
        mWindowContainerController.removeContainer(getDisplayId());
    }

    // TODO: Remove once task record is converted to use controller in which case we can use
    // positionChildAt()
    void positionWindowContainerAt(int index) {
        mWindowContainerController.positionAt(task.taskId, index);
        mWindowContainerController = null;
    }

    private boolean isHomeIntent(Intent intent) {
Loading