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

Commit 72ac5bdb authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge changes Idb4f9a92,I8d8a926d,I8e30e87e into rvc-dev am: fc48f7e5

Change-Id: I49bb7186d4b4152cc25153867895c7a30f77ed13
parents 5f6997a9 fc48f7e5
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -1705,7 +1705,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    boolean addStartingWindow(String pkg, int theme, CompatibilityInfo compatInfo,
            CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags,
            IBinder transferFrom, boolean newTask, boolean taskSwitch, boolean processRunning,
            boolean allowTaskSnapshot, boolean activityCreated, boolean fromRecents) {
            boolean allowTaskSnapshot, boolean activityCreated) {
        // If the display is frozen, we won't do anything until the actual window is
        // displayed so there is no reason to put in the starting window.
        if (!okToDisplay()) {
@@ -1726,7 +1726,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mWmService.mTaskSnapshotController.getSnapshot(task.mTaskId, task.mUserId,
                        false /* restoreFromDisk */, false /* isLowResolution */);
        final int type = getStartingWindowType(newTask, taskSwitch, processRunning,
                allowTaskSnapshot, activityCreated, fromRecents, snapshot);
                allowTaskSnapshot, activityCreated, snapshot);

        if (type == STARTING_WINDOW_TYPE_SNAPSHOT) {
            if (isActivityTypeHome()) {
@@ -1888,12 +1888,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    private final AddStartingWindow mAddStartingWindow = new AddStartingWindow();

    private int getStartingWindowType(boolean newTask, boolean taskSwitch, boolean processRunning,
            boolean allowTaskSnapshot, boolean activityCreated, boolean fromRecents,
            boolean allowTaskSnapshot, boolean activityCreated,
            ActivityManager.TaskSnapshot snapshot) {
        if (newTask || !processRunning || (taskSwitch && !activityCreated)) {
            return STARTING_WINDOW_TYPE_SPLASH_SCREEN;
        } else if (taskSwitch && allowTaskSnapshot) {
            if (snapshotOrientationSameAsTask(snapshot) || (snapshot != null && fromRecents)) {
            if (isSnapshotCompatible(snapshot)) {
                return STARTING_WINDOW_TYPE_SNAPSHOT;
            }
            if (!isActivityTypeHome()) {
@@ -1905,11 +1905,22 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
    }

    private boolean snapshotOrientationSameAsTask(ActivityManager.TaskSnapshot snapshot) {
    /**
     * Returns {@code true} if the task snapshot is compatible with this activity (at least the
     * rotation must be the same).
     */
    @VisibleForTesting
    boolean isSnapshotCompatible(ActivityManager.TaskSnapshot snapshot) {
        if (snapshot == null) {
            return false;
        }
        return task.getConfiguration().orientation == snapshot.getOrientation();
        final int rotation = mDisplayContent.rotationForActivityInDifferentOrientation(this);
        final int targetRotation = rotation != ROTATION_UNDEFINED
                // The display may rotate according to the orientation of this activity.
                ? rotation
                // The activity won't change display orientation.
                : task.getWindowConfiguration().getRotation();
        return snapshot.getRotation() == targetRotation;
    }

    void removeStartingWindow() {
@@ -5662,11 +5673,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch) {
        showStartingWindow(prev, newTask, taskSwitch, false /* fromRecents */);
    }

    void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch,
            boolean fromRecents) {
        if (mTaskOverlay) {
            // We don't show starting window for overlay activities.
            return;
@@ -5683,8 +5689,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
                prev != null ? prev.appToken : null, newTask, taskSwitch, isProcessRunning(),
                allowTaskSnapshot(),
                mState.ordinal() >= STARTED.ordinal() && mState.ordinal() <= STOPPED.ordinal(),
                fromRecents);
                mState.ordinal() >= STARTED.ordinal() && mState.ordinal() <= STOPPED.ordinal());
        if (shown) {
            mStartingWindowState = STARTING_WINDOW_SHOWN;
        }
+1 −1
Original line number Diff line number Diff line
@@ -2498,7 +2498,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                        mActivityMetricsLogger.notifyActivityLaunching(task.intent);
                try {
                    mService.moveTaskToFrontLocked(null /* appThread */, null /* callingPackage */,
                            task.mTaskId, 0, options, true /* fromRecents */);
                            task.mTaskId, 0, options);
                    // Apply options to prevent pendingOptions be taken by client to make sure
                    // the override pending app transition will be applied immediately.
                    targetActivity.applyOptionsLocked();
+3 −4
Original line number Diff line number Diff line
@@ -2476,13 +2476,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToFront: moving taskId=" + taskId);
        synchronized (mGlobalLock) {
            moveTaskToFrontLocked(appThread, callingPackage, taskId, flags,
                    SafeActivityOptions.fromBundle(bOptions), false /* fromRecents */);
                    SafeActivityOptions.fromBundle(bOptions));
        }
    }

    void moveTaskToFrontLocked(@Nullable IApplicationThread appThread,
            @Nullable String callingPackage, int taskId, int flags, SafeActivityOptions options,
            boolean fromRecents) {
            @Nullable String callingPackage, int taskId, int flags, SafeActivityOptions options) {
        final int callingPid = Binder.getCallingPid();
        final int callingUid = Binder.getCallingUid();
        assertPackageMatchesCallingUid(callingPackage);
@@ -2527,7 +2526,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                // We are reshowing a task, use a starting window to hide the initial draw delay
                // so the transition can start earlier.
                topActivity.showStartingWindow(null /* prev */, false /* newTask */,
                        true /* taskSwitch */, fromRecents);
                        true /* taskSwitch */);
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
+38 −28
Original line number Diff line number Diff line
@@ -235,7 +235,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        implements WindowManagerPolicy.DisplayContentInfo {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayContent" : TAG_WM;
    private static final String TAG_STACK = TAG + POSTFIX_STACK;
    private static final int NO_ROTATION = -1;

    /** The default scaling mode that scales content automatically. */
    static final int FORCE_SCALING_MODE_AUTO = 0;
@@ -1394,36 +1393,40 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        final WindowContainer orientationSource = getLastOrientationSource();
        final ActivityRecord r =
                orientationSource != null ? orientationSource.asActivityRecord() : null;
        if (r != null && r.getTask() != null
                && orientation != r.getTask().mLastReportedRequestedOrientation) {
        if (r != null) {
            final Task task = r.getTask();
            if (task != null && orientation != task.mLastReportedRequestedOrientation) {
                task.mLastReportedRequestedOrientation = orientation;
                mAtmService.getTaskChangeNotificationController()
                        .notifyTaskRequestedOrientationChanged(task.mTaskId, orientation);
            }
            // Currently there is no use case from non-activity.
        if (r != null && handleTopActivityLaunchingInDifferentOrientation(r)) {
            if (handleTopActivityLaunchingInDifferentOrientation(r, true /* checkOpening */)) {
                // Display orientation should be deferred until the top fixed rotation is finished.
                return false;
            }
        }
        return mDisplayRotation.updateOrientation(orientation, forceUpdate);
    }

    /** @return a valid rotation if the activity can use different orientation than the display. */
    /**
     * Returns a valid rotation if the activity can use different orientation than the display.
     * Otherwise {@link #ROTATION_UNDEFINED}.
     */
    @Surface.Rotation
    private int rotationForActivityInDifferentOrientation(@NonNull ActivityRecord r) {
    int rotationForActivityInDifferentOrientation(@NonNull ActivityRecord r) {
        if (!mWmService.mIsFixedRotationTransformEnabled) {
            return NO_ROTATION;
            return ROTATION_UNDEFINED;
        }
        if (r.inMultiWindowMode()
                || r.getRequestedConfigurationOrientation() == getConfiguration().orientation) {
            return NO_ROTATION;
            return ROTATION_UNDEFINED;
        }
        final int currentRotation = getRotation();
        final int rotation = mDisplayRotation.rotationForOrientation(r.getRequestedOrientation(),
                currentRotation);
        if (rotation == currentRotation) {
            return NO_ROTATION;
            return ROTATION_UNDEFINED;
        }
        return rotation;
    }
@@ -1433,9 +1436,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     * is launching until the launch animation is done to avoid showing the previous activity
     * inadvertently in a wrong orientation.
     *
     * @param r The launching activity which may change display orientation.
     * @param checkOpening Whether to check if the activity is animating by transition. Set to
     *                     {@code true} if the caller is not sure whether the activity is launching.
     * @return {@code true} if the fixed rotation is started.
     */
    private boolean handleTopActivityLaunchingInDifferentOrientation(@NonNull ActivityRecord r) {
    boolean handleTopActivityLaunchingInDifferentOrientation(@NonNull ActivityRecord r,
            boolean checkOpening) {
        if (!mWmService.mIsFixedRotationTransformEnabled) {
            return false;
        }
@@ -1446,19 +1453,18 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            // It has been set and not yet finished.
            return true;
        }
        if (!mAppTransition.isTransitionSet()) {
        if (checkOpening) {
            if (!mAppTransition.isTransitionSet() && !mOpeningApps.contains(r)) {
                // Apply normal rotation animation in case of the activity set different requested
                // orientation without activity switch.
                return false;
            }
        if (!mOpeningApps.contains(r)
                // Without screen rotation, the rotation behavior of non-top visible activities is
                // undefined. So the fixed rotated activity needs to cover the screen.
                && r.findMainWindow() != mDisplayPolicy.getTopFullscreenOpaqueWindow()) {
        } else if (r != topRunningActivity()) {
            // If the transition has not started yet, the activity must be the top.
            return false;
        }
        final int rotation = rotationForActivityInDifferentOrientation(r);
        if (rotation == NO_ROTATION) {
        if (rotation == ROTATION_UNDEFINED) {
            return false;
        }
        if (!r.getParent().matchParentBounds()) {
@@ -1511,6 +1517,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            sendNewConfiguration();
            return;
        }
        if (mDisplayRotation.isWaitingForRemoteRotation()) {
            // There is pending rotation change to apply.
            return;
        }
        // The orientation of display is not changed.
        clearFixedRotationLaunchingApp();
    }
@@ -1551,7 +1561,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     */
    void rotateInDifferentOrientationIfNeeded(ActivityRecord activityRecord) {
        int rotation = rotationForActivityInDifferentOrientation(activityRecord);
        if (rotation != NO_ROTATION) {
        if (rotation != ROTATION_UNDEFINED) {
            startFixedRotationTransform(activityRecord, rotation);
        }
    }
+7 −0
Original line number Diff line number Diff line
@@ -297,6 +297,13 @@ class TaskSnapshotController {
            Slog.w(TAG_WM, "Failed to take screenshot. No main window for " + task);
            return false;
        }
        if (activity.hasFixedRotationTransform()) {
            if (DEBUG_SCREENSHOT) {
                Slog.i(TAG_WM, "Skip taking screenshot. App has fixed rotation " + activity);
            }
            // The activity is in a temporal state that it has different rotation than the task.
            return false;
        }

        builder.setIsRealSnapshot(true);
        builder.setId(System.currentTimeMillis());
Loading