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

Commit 6183a494 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Automerger Merge Worker
Browse files

Merge "Let windowSplashScreenBackground work independent from icon." into sc-dev am: 8fdd1d87

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14161088

Change-Id: Ia7eb4347398d841f37e83d76e5d3bad13ff98ea5
parents 45a8df19 8fdd1d87
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -109,11 +109,12 @@ public class SplashscreenContentDrawer {
     * view on background thread so the view and the drawable can be create and pre-draw in
     * parallel.
     *
     * @param emptyView Create a splash screen view without icon on it.
     * @param consumer Receiving the SplashScreenView object, which will also be executed
     *                 on splash screen thread. Note that the view can be null if failed.
     */
    void createContentView(Context context, int splashScreenResId, ActivityInfo info,
            int taskId, Consumer<SplashScreenView> consumer) {
    void createContentView(Context context, boolean emptyView, int splashScreenResId,
            ActivityInfo info, int taskId, Consumer<SplashScreenView> consumer) {
        mSplashscreenWorkerHandler.post(() -> {
            SplashScreenView contentView;
            try {
@@ -121,7 +122,11 @@ public class SplashscreenContentDrawer {
                        context, splashScreenResId);
                if (contentView == null) {
                    Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "makeSplashScreenContentView");
                    if (emptyView) {
                        contentView = makeEmptySplashScreenContentView(context);
                    } else {
                        contentView = makeSplashScreenContentView(context, info);
                    }
                    Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                }
            } catch (RuntimeException e) {
@@ -190,6 +195,18 @@ public class SplashscreenContentDrawer {
        }
    }

    private SplashScreenView makeEmptySplashScreenContentView(Context context) {
        getWindowAttrs(context, mTmpAttrs);
        final StartingWindowViewBuilder builder = new StartingWindowViewBuilder();
        final int themeBGColor = peekWindowBGColor(context);
        final SplashScreenView view =  builder
                .setContext(context)
                .setWindowBGColor(themeBGColor)
                .build();
        view.setNotCopyable();
        return view;
    }

    private SplashScreenView makeSplashScreenContentView(Context context, ActivityInfo ai) {
        updateDensity();

+24 −32
Original line number Diff line number Diff line
@@ -317,12 +317,11 @@ public class StartingSurfaceDrawer {
        // 3. Pre-draw the BitmapShader if the icon is immobile on splash screen worker thread, at
        // the same time the splash screen thread should be executing Session#relayout. Blocking the
        // traversal -> draw on splash screen thread until the BitmapShader of the icon is ready.
        final Runnable setViewSynchronized;
        if (!emptyView) {

        // Record whether create splash screen view success, notify to current thread after
        // create splash screen view finished.
        final SplashScreenViewSupplier viewSupplier = new SplashScreenViewSupplier();
            setViewSynchronized = () -> {
        final Runnable setViewSynchronized = () -> {
            // waiting for setContentView before relayoutWindow
            SplashScreenView contentView = viewSupplier.get();
            final StartingWindowRecord record = mStartingWindowRecords.get(taskId);
@@ -342,21 +341,14 @@ public class StartingSurfaceDrawer {
                record.setSplashScreenView(contentView);
            }
        };
            mSplashscreenContentDrawer.createContentView(context,
        mSplashscreenContentDrawer.createContentView(context, emptyView,
                splashscreenContentResId[0], activityInfo, taskId, viewSupplier::setView);
        } else {
            setViewSynchronized = null;
        }

        try {
            final View view = win.getDecorView();
            final WindowManager wm = mContext.getSystemService(WindowManager.class);
            postAddWindow(taskId, appToken, view, wm, params);

            // all done
            if (emptyView) {
                return;
            }
            // We use the splash screen worker thread to create SplashScreenView while adding the
            // window, as otherwise Choreographer#doFrame might be delayed on this thread.
            // And since Choreographer#doFrame won't happen immediately after adding the window, if