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

Commit 83a8a3bc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add task snapshot for home task"

parents ac5d38ec 440f88b4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -404,6 +404,14 @@ interface IActivityTaskManager {
     */
    void setDisablePreviewScreenshots(IBinder token, boolean disable);

    /**
     * It should only be called from home activity to remove its outdated snapshot. The home
     * snapshot is used to speed up entering home from screen off. If the content of home activity
     * is significantly different from before taking the snapshot, then the home activity can use
     * this method to avoid inconsistent transition.
     */
    void invalidateHomeTaskSnapshot(IBinder homeToken);

    /**
     * Return the user id of last resumed activity.
     */
+18 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECOND
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import android.annotation.NonNull;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
@@ -160,6 +161,23 @@ public class ActivityManagerWrapper {
        }
    }

    /**
     * Removes the outdated snapshot of home task.
     */
    public void invalidateHomeTaskSnapshot(final Activity homeActivity) {
        mBackgroundExecutor.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    ActivityTaskManager.getService().invalidateHomeTaskSnapshot(
                            homeActivity.getActivityToken());
                } catch (RemoteException e) {
                    Log.w(TAG, "Failed to invalidate home snapshot", e);
                }
            }
        });
    }

    /**
     * @return the activity label, badging if necessary.
     */
+3 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UEventObserver;
import android.os.UserHandle;
import android.os.VibrationEffect;
@@ -4603,6 +4604,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    public void screenTurningOn(final ScreenOnListener screenOnListener) {
        if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...");

        Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */);
        updateScreenOffSleepToken(false);
        mDefaultDisplayPolicy.screenTurnedOn(screenOnListener);

@@ -4665,6 +4667,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (!mDefaultDisplayPolicy.finishScreenTurningOn()) {
            return; // Spurious or not ready yet.
        }
        Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */);

        final boolean enableScreen;
        final boolean awake = mDefaultDisplayPolicy.isAwake();
+11 −0
Original line number Diff line number Diff line
@@ -1640,6 +1640,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                allowTaskSnapshot, activityCreated, fromRecents, snapshot);

        if (type == STARTING_WINDOW_TYPE_SNAPSHOT) {
            if (isActivityTypeHome()) {
                // The snapshot of home is only used once because it won't be updated while screen
                // is on (see {@link TaskSnapshotController#screenTurningOff}).
                mWmService.mTaskSnapshotController.removeSnapshotCache(task.mTaskId);
                // TODO(b/9684093): Use more general condition to specify the case.
                if (mDisplayContent.mAppTransition
                        .getAppTransition() != WindowManager.TRANSIT_KEYGUARD_GOING_AWAY) {
                    // Only use snapshot of home as starting window when unlocking.
                    return false;
                }
            }
            return createSnapshot(snapshot);
        }

+11 −0
Original line number Diff line number Diff line
@@ -4572,6 +4572,17 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
    }

    @Override
    public void invalidateHomeTaskSnapshot(IBinder token) {
        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.isInStackLocked(token);
            if (r == null || !r.isActivityTypeHome()) {
                return;
            }
            mWindowManager.mTaskSnapshotController.removeSnapshotCache(r.getTask().mTaskId);
        }
    }

    /** Return the user id of the last resumed activity. */
    @Override
    public @UserIdInt
Loading