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

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

Merge "Skip creating config context if it is the same as current" into sc-dev am: 81e85863

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

Change-Id: I1a93c2271b9cd26040e7a87960d1e51db5278bb2
parents 3db473fb 81e85863
Loading
Loading
Loading
Loading
+18 −39
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.wm.shell.startingsurface;
package com.android.wm.shell.startingsurface;


import static android.content.Context.CONTEXT_RESTRICTED;
import static android.content.Context.CONTEXT_RESTRICTED;
import static android.content.res.Configuration.EMPTY;
import static android.view.Choreographer.CALLBACK_INSETS_ANIMATION;
import static android.view.Choreographer.CALLBACK_INSETS_ANIMATION;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;


@@ -54,7 +53,6 @@ import com.android.internal.policy.PhoneWindow;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.common.TransactionPool;


import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.function.Supplier;


/**
/**
@@ -92,8 +90,6 @@ import java.util.function.Supplier;
 * => makeSplashScreenContentView -> cachePaint(=AdaptiveIconDrawable#draw)
 * => makeSplashScreenContentView -> cachePaint(=AdaptiveIconDrawable#draw)
 * => WM#addView -> .. waiting for Choreographer#doFrame -> relayout -> draw -> (draw the Paint
 * => WM#addView -> .. waiting for Choreographer#doFrame -> relayout -> draw -> (draw the Paint
 * directly).
 * directly).
 *
 * @hide
 */
 */
public class StartingSurfaceDrawer {
public class StartingSurfaceDrawer {
    static final String TAG = StartingSurfaceDrawer.class.getSimpleName();
    static final String TAG = StartingSurfaceDrawer.class.getSimpleName();
@@ -197,7 +193,7 @@ public class StartingSurfaceDrawer {
        }
        }


        final Configuration taskConfig = taskInfo.getConfiguration();
        final Configuration taskConfig = taskInfo.getConfiguration();
        if (taskConfig != null && !taskConfig.equals(EMPTY)) {
        if (taskConfig.diffPublicOnly(context.getResources().getConfiguration()) != 0) {
            if (DEBUG_SPLASH_SCREEN) {
            if (DEBUG_SPLASH_SCREEN) {
                Slog.d(TAG, "addSplashScreen: creating context based"
                Slog.d(TAG, "addSplashScreen: creating context based"
                        + " on task Configuration " + taskConfig + " for splash screen");
                        + " on task Configuration " + taskConfig + " for splash screen");
@@ -226,20 +222,11 @@ public class StartingSurfaceDrawer {
            typedArray.recycle();
            typedArray.recycle();
        }
        }


        int windowFlags = 0;
        windowFlags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;

        final boolean[] showWallpaper = new boolean[1];
        getWindowResFromContext(context, a ->
                showWallpaper[0] = a.getBoolean(R.styleable.Window_windowShowWallpaper, false));
        if (showWallpaper[0]) {
            windowFlags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
        }

        final PhoneWindow win = new PhoneWindow(context);
        final PhoneWindow win = new PhoneWindow(context);
        win.setIsStartingWindow(true);
        win.setIsStartingWindow(true);


        CharSequence label = context.getResources().getText(labelRes, null);
        final Resources res = context.getResources();
        final CharSequence label = res.getText(labelRes, null);
        // Only change the accessibility title if the label is localized
        // Only change the accessibility title if the label is localized
        if (label != null) {
        if (label != null) {
            win.setTitle(label, true);
            win.setTitle(label, true);
@@ -247,7 +234,12 @@ public class StartingSurfaceDrawer {
            win.setTitle(nonLocalizedLabel, false);
            win.setTitle(nonLocalizedLabel, false);
        }
        }


        win.setType(WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
        int windowFlags = WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
        final TypedArray a = context.obtainStyledAttributes(R.styleable.Window);
        if (a.getBoolean(R.styleable.Window_windowShowWallpaper, false)) {
            windowFlags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
        }
        a.recycle();


        // Assumes it's safe to show starting windows of launched apps while
        // Assumes it's safe to show starting windows of launched apps while
        // the keyguard is being hidden. This is okay because starting windows never show
        // the keyguard is being hidden. This is okay because starting windows never show
@@ -261,24 +253,20 @@ public class StartingSurfaceDrawer {
        // touchable or focusable by the user.  We also add in the ALT_FOCUSABLE_IM
        // touchable or focusable by the user.  We also add in the ALT_FOCUSABLE_IM
        // flag because we do know that the next window will take input
        // flag because we do know that the next window will take input
        // focus, so we want to get the IME window up on top of us right away.
        // focus, so we want to get the IME window up on top of us right away.
        win.setFlags(windowFlags
        windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                windowFlags
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
                | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        win.setFlags(windowFlags, windowFlags);


        final int iconRes = activityInfo.getIconResource();
        final int iconRes = activityInfo.getIconResource();
        final int logoRes = activityInfo.getLogoResource();
        final int logoRes = activityInfo.getLogoResource();
        win.setDefaultIcon(iconRes);
        win.setDefaultIcon(iconRes);
        win.setDefaultLogo(logoRes);
        win.setDefaultLogo(logoRes);


        win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT);

        final WindowManager.LayoutParams params = win.getAttributes();
        final WindowManager.LayoutParams params = win.getAttributes();
        params.type = WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.MATCH_PARENT;
        params.token = appToken;
        params.token = appToken;
        params.packageName = activityInfo.packageName;
        params.packageName = activityInfo.packageName;
        params.windowAnimations = win.getWindowStyle().getResourceId(
        params.windowAnimations = win.getWindowStyle().getResourceId(
@@ -289,10 +277,7 @@ public class StartingSurfaceDrawer {
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
        params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
        params.format = PixelFormat.RGBA_8888;
        params.format = PixelFormat.RGBA_8888;


        final Resources res = context.getResources();
        if (!res.getCompatibilityInfo().supportsScreen()) {
        final boolean supportsScreen = res != null && (res.getCompatibilityInfo() != null
                && res.getCompatibilityInfo().supportsScreen());
        if (!supportsScreen) {
            params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
            params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
        }
        }


@@ -337,7 +322,7 @@ public class StartingSurfaceDrawer {


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


            // We use the splash screen worker thread to create SplashScreenView while adding the
            // We use the splash screen worker thread to create SplashScreenView while adding the
@@ -505,12 +490,6 @@ public class StartingSurfaceDrawer {
        }
        }
    }
    }


    private void getWindowResFromContext(Context ctx, Consumer<TypedArray> consumer) {
        final TypedArray a = ctx.obtainStyledAttributes(R.styleable.Window);
        consumer.accept(a);
        a.recycle();
    }

    /**
    /**
     * Record the view or surface for a starting window.
     * Record the view or surface for a starting window.
     */
     */