Merge "Skip creating config context if it is the same as current" into sc-dev
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package com.android.wm.shell.startingsurface;
|
||||
|
||||
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.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.TransactionPool;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -92,8 +90,6 @@ import java.util.function.Supplier;
|
||||
* => makeSplashScreenContentView -> cachePaint(=AdaptiveIconDrawable#draw)
|
||||
* => WM#addView -> .. waiting for Choreographer#doFrame -> relayout -> draw -> (draw the Paint
|
||||
* directly).
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class StartingSurfaceDrawer {
|
||||
static final String TAG = StartingSurfaceDrawer.class.getSimpleName();
|
||||
@@ -197,7 +193,7 @@ public class StartingSurfaceDrawer {
|
||||
}
|
||||
|
||||
final Configuration taskConfig = taskInfo.getConfiguration();
|
||||
if (taskConfig != null && !taskConfig.equals(EMPTY)) {
|
||||
if (taskConfig.diffPublicOnly(context.getResources().getConfiguration()) != 0) {
|
||||
if (DEBUG_SPLASH_SCREEN) {
|
||||
Slog.d(TAG, "addSplashScreen: creating context based"
|
||||
+ " on task Configuration " + taskConfig + " for splash screen");
|
||||
@@ -226,20 +222,11 @@ public class StartingSurfaceDrawer {
|
||||
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);
|
||||
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
|
||||
if (label != null) {
|
||||
win.setTitle(label, true);
|
||||
@@ -247,7 +234,12 @@ public class StartingSurfaceDrawer {
|
||||
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
|
||||
// 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
|
||||
// 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.
|
||||
win.setFlags(windowFlags
|
||||
| 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_ALT_FOCUSABLE_IM);
|
||||
windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
||||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
win.setFlags(windowFlags, windowFlags);
|
||||
|
||||
final int iconRes = activityInfo.getIconResource();
|
||||
final int logoRes = activityInfo.getLogoResource();
|
||||
win.setDefaultIcon(iconRes);
|
||||
win.setDefaultLogo(logoRes);
|
||||
|
||||
win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT);
|
||||
|
||||
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.packageName = activityInfo.packageName;
|
||||
params.windowAnimations = win.getWindowStyle().getResourceId(
|
||||
@@ -289,10 +277,7 @@ public class StartingSurfaceDrawer {
|
||||
params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
||||
params.format = PixelFormat.RGBA_8888;
|
||||
|
||||
final Resources res = context.getResources();
|
||||
final boolean supportsScreen = res != null && (res.getCompatibilityInfo() != null
|
||||
&& res.getCompatibilityInfo().supportsScreen());
|
||||
if (!supportsScreen) {
|
||||
if (!res.getCompatibilityInfo().supportsScreen()) {
|
||||
params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
|
||||
}
|
||||
|
||||
@@ -337,7 +322,7 @@ public class StartingSurfaceDrawer {
|
||||
|
||||
try {
|
||||
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);
|
||||
|
||||
// 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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user