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

Commit 67394e78 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Pass ActivityOptions when endDeferAddStartingWindow"

parents a7ba26fb 009cfc17
Loading
Loading
Loading
Loading
+18 −12
Original line number Original line Diff line number Diff line
@@ -6568,7 +6568,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return null;
        return null;
    }
    }


    private boolean shouldUseEmptySplashScreen(ActivityRecord sourceRecord, boolean startActivity) {
    private boolean shouldUseEmptySplashScreen(ActivityRecord sourceRecord, boolean startActivity,
            ActivityOptions options) {
        if (sourceRecord == null && !startActivity) {
        if (sourceRecord == null && !startActivity) {
            // Use empty style if this activity is not top activity. This could happen when adding
            // Use empty style if this activity is not top activity. This could happen when adding
            // a splash screen window to the warm start activity which is re-create because top is
            // a splash screen window to the warm start activity which is re-create because top is
@@ -6578,8 +6579,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                return true;
                return true;
            }
            }
        }
        }
        if (mPendingOptions != null) {
        if (options != null) {
            final int optionsStyle = mPendingOptions.getSplashScreenStyle();
            final int optionsStyle = options.getSplashScreenStyle();
            if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_EMPTY) {
            if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_EMPTY) {
                return true;
                return true;
            } else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON) {
            } else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON) {
@@ -6608,11 +6609,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                || mLaunchSourceType == LAUNCH_SOURCE_TYPE_HOME);
                || mLaunchSourceType == LAUNCH_SOURCE_TYPE_HOME);
    }
    }


    private int getSplashscreenTheme() {
    private int getSplashscreenTheme(ActivityOptions options) {
        // Find the splash screen theme. User can override the persisted theme by
        // Find the splash screen theme. User can override the persisted theme by
        // ActivityOptions.
        // ActivityOptions.
        String splashScreenThemeResName = mPendingOptions != null
        String splashScreenThemeResName = options != null
                ? mPendingOptions.getSplashScreenThemeResName() : null;
                ? options.getSplashScreenThemeResName() : null;
        if (splashScreenThemeResName == null || splashScreenThemeResName.isEmpty()) {
        if (splashScreenThemeResName == null || splashScreenThemeResName.isEmpty()) {
            try {
            try {
                splashScreenThemeResName = mAtmService.getPackageManager()
                splashScreenThemeResName = mAtmService.getPackageManager()
@@ -6639,7 +6640,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch,
    void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch,
            boolean startActivity, ActivityRecord sourceRecord) {
            boolean startActivity, ActivityRecord sourceRecord) {
        showStartingWindow(prev, newTask, taskSwitch, isProcessRunning(), startActivity,
        showStartingWindow(prev, newTask, taskSwitch, isProcessRunning(), startActivity,
                sourceRecord);
                sourceRecord, null /* candidateOptions */);
    }
    }


    /**
    /**
@@ -6647,22 +6648,27 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * @param processRunning Whether the client process is running.
     * @param processRunning Whether the client process is running.
     * @param startActivity Whether this activity is just created from starter.
     * @param startActivity Whether this activity is just created from starter.
     * @param sourceRecord The source activity which start this activity.
     * @param sourceRecord The source activity which start this activity.
     * @param candidateOptions The options for the style of starting window.
     */
     */
    void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch,
    void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch,
            boolean processRunning, boolean startActivity, ActivityRecord sourceRecord) {
            boolean processRunning, boolean startActivity, ActivityRecord sourceRecord,
            ActivityOptions candidateOptions) {
        if (mTaskOverlay) {
        if (mTaskOverlay) {
            // We don't show starting window for overlay activities.
            // We don't show starting window for overlay activities.
            return;
            return;
        }
        }
        if (mPendingOptions != null
        final ActivityOptions startOptions = candidateOptions != null
                && mPendingOptions.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
                ? candidateOptions : mPendingOptions;
        if (startOptions != null
                && startOptions.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
            // Don't show starting window when using shared element transition.
            // Don't show starting window when using shared element transition.
            return;
            return;
        }
        }


        mSplashScreenStyleEmpty = shouldUseEmptySplashScreen(sourceRecord, startActivity);
        mSplashScreenStyleEmpty = shouldUseEmptySplashScreen(
                sourceRecord, startActivity, startOptions);


        final int splashScreenTheme = startActivity ? getSplashscreenTheme() : 0;
        final int splashScreenTheme = startActivity ? getSplashscreenTheme(startOptions) : 0;
        final int resolvedTheme = evaluateStartingWindowTheme(prev, packageName, theme,
        final int resolvedTheme = evaluateStartingWindowTheme(prev, packageName, theme,
                splashScreenTheme);
                splashScreenTheme);


+2 −1
Original line number Original line Diff line number Diff line
@@ -484,7 +484,8 @@ public class ActivityStartController {
                        }
                        }
                    }
                    }
                } finally {
                } finally {
                    mService.mWindowManager.mStartingSurfaceController.endDeferAddStartingWindow();
                    mService.mWindowManager.mStartingSurfaceController.endDeferAddStartingWindow(
                            options != null ? options.getOriginalOptions() : null);
                    mService.continueWindowLayout();
                    mService.continueWindowLayout();
                }
                }
            }
            }
+5 −4
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.compat.CompatChanges;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.EnabledSince;
@@ -215,12 +216,12 @@ public class StartingSurfaceController {
                deferring, prev, source));
                deferring, prev, source));
    }
    }


    private void showStartingWindowFromDeferringActivities() {
    private void showStartingWindowFromDeferringActivities(ActivityOptions topOptions) {
        // Attempt to add starting window from the top-most activity.
        // Attempt to add starting window from the top-most activity.
        for (int i = mDeferringAddStartActivities.size() - 1; i >= 0; --i) {
        for (int i = mDeferringAddStartActivities.size() - 1; i >= 0; --i) {
            final DeferringStartingWindowRecord next = mDeferringAddStartActivities.get(i);
            final DeferringStartingWindowRecord next = mDeferringAddStartActivities.get(i);
            next.mDeferring.showStartingWindow(next.mPrev, mInitNewTask, mInitTaskSwitch,
            next.mDeferring.showStartingWindow(next.mPrev, mInitNewTask, mInitTaskSwitch,
                    mInitProcessRunning, true /* startActivity */, next.mSource);
                    mInitProcessRunning, true /* startActivity */, next.mSource, topOptions);
            // If one succeeds, it is done.
            // If one succeeds, it is done.
            if (next.mDeferring.mStartingData != null) {
            if (next.mDeferring.mStartingData != null) {
                break;
                break;
@@ -243,9 +244,9 @@ public class StartingSurfaceController {
    /**
    /**
     * End deferring add starting window.
     * End deferring add starting window.
     */
     */
    void endDeferAddStartingWindow() {
    void endDeferAddStartingWindow(ActivityOptions topOptions) {
        mDeferringAddStartingWindow = false;
        mDeferringAddStartingWindow = false;
        showStartingWindowFromDeferringActivities();
        showStartingWindowFromDeferringActivities(topOptions);
    }
    }


    final class StartingSurface {
    final class StartingSurface {