Merge "Don't apply some custom animation cases from app in WindowStateAnimator" into qt-dev am: 5e2e01e982
am: 51a1c5905d
Change-Id: Ia2c18dbe164c371a027ed3b556374986e1c942a8
This commit is contained in:
@@ -88,6 +88,7 @@ import android.content.res.Configuration;
|
||||
import android.content.res.ResourceId;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
@@ -259,6 +260,8 @@ public class AppTransition implements Dump {
|
||||
private final boolean mGridLayoutRecentsEnabled;
|
||||
private final boolean mLowRamRecentsEnabled;
|
||||
|
||||
private final int mDefaultWindowAnimationStyleResId;
|
||||
|
||||
private RemoteAnimationController mRemoteAnimationController;
|
||||
|
||||
final Handler mHandler;
|
||||
@@ -306,6 +309,12 @@ public class AppTransition implements Dump {
|
||||
* mContext.getResources().getDisplayMetrics().density);
|
||||
mGridLayoutRecentsEnabled = SystemProperties.getBoolean("ro.recents.grid", false);
|
||||
mLowRamRecentsEnabled = ActivityManager.isLowRamDeviceStatic();
|
||||
|
||||
final TypedArray windowStyle = mContext.getTheme().obtainStyledAttributes(
|
||||
com.android.internal.R.styleable.Window);
|
||||
mDefaultWindowAnimationStyleResId = windowStyle.getResourceId(
|
||||
com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
|
||||
windowStyle.recycle();
|
||||
}
|
||||
|
||||
boolean isTransitionSet() {
|
||||
@@ -524,6 +533,25 @@ public class AppTransition implements Dump {
|
||||
return redoLayout;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getDefaultWindowAnimationStyleResId() {
|
||||
return mDefaultWindowAnimationStyleResId;
|
||||
}
|
||||
|
||||
/** Returns window animation style ID from {@link LayoutParams} or from system in some cases */
|
||||
@VisibleForTesting
|
||||
int getAnimationStyleResId(@NonNull LayoutParams lp) {
|
||||
int resId = lp.windowAnimations;
|
||||
if (lp.type == LayoutParams.TYPE_APPLICATION_STARTING) {
|
||||
// Note that we don't want application to customize starting window animation.
|
||||
// Since this window is specific for displaying while app starting,
|
||||
// application should not change its animation directly.
|
||||
// In this case, it will use system resource to get default animation.
|
||||
resId = mDefaultWindowAnimationStyleResId;
|
||||
}
|
||||
return resId;
|
||||
}
|
||||
|
||||
private AttributeCache.Entry getCachedAnimations(LayoutParams lp) {
|
||||
if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
|
||||
+ (lp != null ? lp.packageName : null)
|
||||
@@ -533,7 +561,7 @@ public class AppTransition implements Dump {
|
||||
// application resources. It is nice to avoid loading application
|
||||
// resources if we can.
|
||||
String packageName = lp.packageName != null ? lp.packageName : "android";
|
||||
int resId = lp.windowAnimations;
|
||||
int resId = getAnimationStyleResId(lp);
|
||||
if ((resId&0xFF000000) == 0x01000000) {
|
||||
packageName = "android";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
|
||||
import static android.view.WindowManager.TRANSIT_NONE;
|
||||
@@ -1294,6 +1295,13 @@ class WindowStateAnimator {
|
||||
if (mWin.mSkipEnterAnimationForSeamlessReplacement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't apply animation for application main window here since this window type
|
||||
// should be controlled by AppWindowToken in general.
|
||||
if (mAttrType == TYPE_BASE_APPLICATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int transit;
|
||||
if (mEnterAnimationPending) {
|
||||
mEnterAnimationPending = false;
|
||||
@@ -1365,6 +1373,7 @@ class WindowStateAnimator {
|
||||
+ " anim=" + anim + " attr=0x" + Integer.toHexString(attr)
|
||||
+ " a=" + a
|
||||
+ " transit=" + transit
|
||||
+ " type=" + mAttrType
|
||||
+ " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3));
|
||||
if (a != null) {
|
||||
if (DEBUG_ANIM) logWithStack(TAG, "Loaded animation " + a + " for " + this);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
|
||||
import static android.view.WindowManager.TRANSIT_ACTIVITY_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN;
|
||||
@@ -45,6 +46,7 @@ import android.view.IRemoteAnimationFinishedCallback;
|
||||
import android.view.IRemoteAnimationRunner;
|
||||
import android.view.RemoteAnimationAdapter;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.test.filters.FlakyTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
@@ -224,6 +226,21 @@ public class AppTransitionTests extends WindowTestsBase {
|
||||
assertTrue(runner.mCancelled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAnimationStyleResId() {
|
||||
// Verify getAnimationStyleResId will return as LayoutParams.windowAnimations when without
|
||||
// specifying window type.
|
||||
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams();
|
||||
attrs.windowAnimations = 0x12345678;
|
||||
assertEquals(attrs.windowAnimations, mDc.mAppTransition.getAnimationStyleResId(attrs));
|
||||
|
||||
// Verify getAnimationStyleResId will return system resource Id when the window type is
|
||||
// starting window.
|
||||
attrs.type = TYPE_APPLICATION_STARTING;
|
||||
assertEquals(mDc.mAppTransition.getDefaultWindowAnimationStyleResId(),
|
||||
mDc.mAppTransition.getAnimationStyleResId(attrs));
|
||||
}
|
||||
|
||||
private class TestRemoteAnimationRunner implements IRemoteAnimationRunner {
|
||||
boolean mCancelled = false;
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user