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

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

Merge "Only check uiMode while creating context of splash screen" into main

parents 62253d6f 777efe0a
Loading
Loading
Loading
Loading
+5 −20
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.startingsurface;

import static android.content.Context.CONTEXT_RESTRICTED;
import static android.content.res.Configuration.UI_MODE_NIGHT_MASK;
import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -191,32 +192,16 @@ public class SplashscreenContentDrawer {
        }

        final Configuration taskConfig = taskInfo.getConfiguration();
        if (taskConfig.diffPublicOnly(context.getResources().getConfiguration()) != 0) {
        final Configuration contextConfig = context.getResources().getConfiguration();
        if ((taskConfig.uiMode & UI_MODE_NIGHT_MASK)
                != (contextConfig.uiMode & UI_MODE_NIGHT_MASK)) {
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_STARTING_WINDOW,
                    "addSplashScreen: creating context based on task Configuration %s",
                    taskConfig);
            final Context overrideContext = context.createConfigurationContext(taskConfig);
            overrideContext.setTheme(theme);
            final TypedArray typedArray = overrideContext.obtainStyledAttributes(
                    com.android.internal.R.styleable.Window);
            final int resId = typedArray.getResourceId(R.styleable.Window_windowBackground, 0);
            try {
                if (resId != 0 && overrideContext.getDrawable(resId) != null) {
                    // We want to use the windowBackground for the override context if it is
                    // available, otherwise we use the default one to make sure a themed starting
                    // window is displayed for the app.
                    ProtoLog.v(ShellProtoLogGroup.WM_SHELL_STARTING_WINDOW,
                            "addSplashScreen: apply overrideConfig %s",
                            taskConfig);
            context = overrideContext;
        }
            } catch (Resources.NotFoundException e) {
                Slog.w(TAG, "failed creating starting window for overrideConfig at taskId: "
                        + taskId, e);
                return null;
            }
            typedArray.recycle();
        }
        return context;
    }