Merge "Add WM transit types for dream activity." into tm-qpr-dev

This commit is contained in:
Xiaowen Lei
2022-05-04 22:45:17 +00:00
committed by Android (Google) Code Review
9 changed files with 116 additions and 24 deletions

View File

@@ -21,8 +21,6 @@ import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import com.android.internal.R;
/**
* The Activity used by the {@link DreamService} to draw screensaver content
* on the screen. This activity runs in dream application's process, but is started by a
@@ -65,17 +63,4 @@ public class DreamActivity extends Activity {
callback.onActivityCreated(this);
}
}
@Override
public void onResume() {
super.onResume();
overridePendingTransition(R.anim.dream_activity_open_enter,
R.anim.dream_activity_open_exit);
}
@Override
public void finishAndRemoveTask() {
super.finishAndRemoveTask();
overridePendingTransition(0, R.anim.dream_activity_close_exit);
}
}

View File

@@ -340,6 +340,18 @@ public interface WindowManager extends ViewManager {
*/
int TRANSIT_OLD_TASK_FRAGMENT_CHANGE = 30;
/**
* A dream activity is being opened.
* @hide
*/
int TRANSIT_OLD_DREAM_ACTIVITY_OPEN = 31;
/**
* A dream activity is being closed.
* @hide
*/
int TRANSIT_OLD_DREAM_ACTIVITY_CLOSE = 32;
/**
* @hide
*/
@@ -368,7 +380,9 @@ public interface WindowManager extends ViewManager {
TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE,
TRANSIT_OLD_TASK_FRAGMENT_OPEN,
TRANSIT_OLD_TASK_FRAGMENT_CLOSE,
TRANSIT_OLD_TASK_FRAGMENT_CHANGE
TRANSIT_OLD_TASK_FRAGMENT_CHANGE,
TRANSIT_OLD_DREAM_ACTIVITY_OPEN,
TRANSIT_OLD_DREAM_ACTIVITY_CLOSE
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionOldType {}

View File

@@ -16,6 +16,8 @@
package android.window;
import static android.view.WindowManager.transitTypeToString;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.WindowConfiguration;
@@ -366,7 +368,7 @@ public final class TransitionRequestInfo implements Parcelable {
// String fieldNameToString() { ... }
return "TransitionRequestInfo { " +
"type = " + mType + ", " +
"type = " + transitTypeToString(mType) + ", " +
"triggerTask = " + mTriggerTask + ", " +
"remoteTransition = " + mRemoteTransition + ", " +
"displayChange = " + mDisplayChange +

View File

@@ -2422,6 +2422,15 @@
<!-- When closing the current activity, this is the animation that is
run on the current activity (which is exiting the screen). -->
<attr name="activityCloseExitAnimation" format="reference" />
<!-- When closing a dream activity, this is the animation that is
run on the dream activity (which is exiting the screen). -->
<attr name="dreamActivityCloseExitAnimation" format="reference" />
<!-- When opening a dream activity, this is the animation that is
run on the dream activity (which is entering the screen). -->
<attr name="dreamActivityOpenEnterAnimation" format="reference" />
<!-- When opening a dream activity, this is the animation that is
run on the old activity (which is exiting the screen). -->
<attr name="dreamActivityOpenExitAnimation" format="reference" />
<!-- When opening an activity in a new task, this is the animation that is
run on the activity of the new task (which is entering the screen). -->
<attr name="taskOpenEnterAnimation" format="reference" />

View File

@@ -85,6 +85,9 @@ please see styles_device_defaults.xml.
<item name="activityOpenExitAnimation">@anim/activity_open_exit</item>
<item name="activityCloseEnterAnimation">@anim/activity_close_enter</item>
<item name="activityCloseExitAnimation">@anim/activity_close_exit</item>
<item name="dreamActivityCloseExitAnimation">@anim/dream_activity_close_exit</item>
<item name="dreamActivityOpenEnterAnimation">@anim/dream_activity_open_enter</item>
<item name="dreamActivityOpenExitAnimation">@anim/dream_activity_open_exit</item>
<item name="taskOpenEnterAnimation">@anim/task_open_enter</item>
<item name="taskOpenExitAnimation">@anim/task_open_exit</item>
<item name="launchTaskBehindTargetAnimation">@anim/launch_task_behind_target</item>

View File

@@ -24,6 +24,7 @@ import static android.app.ActivityOptions.ANIM_OPEN_CROSS_PROFILE_APPS;
import static android.app.ActivityOptions.ANIM_SCALE_UP;
import static android.app.ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN;
import static android.app.ActivityOptions.ANIM_THUMBNAIL_SCALE_UP;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE;
@@ -42,6 +43,7 @@ import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_RELAUNCH;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManager.transitTypeToString;
import static android.window.TransitionInfo.FLAG_DISPLAY_HAS_ALERT_WINDOWS;
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
import static android.window.TransitionInfo.FLAG_IS_VOICE_INTERACTION;
@@ -684,6 +686,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
final Rect endBounds = Transitions.isClosingType(changeMode)
? mRotator.getEndBoundsInStartRotation(change)
: change.getEndAbsBounds();
final boolean isDream =
isTask && change.getTaskInfo().topActivityType == ACTIVITY_TYPE_DREAM;
if (info.isKeyguardGoingAway()) {
a = mTransitionAnimation.loadKeyguardExitAnimation(flags,
@@ -726,7 +730,17 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
} else {
int animAttr = 0;
boolean translucent = false;
if (wallpaperTransit == WALLPAPER_TRANSITION_INTRA_OPEN) {
if (isDream) {
if (type == TRANSIT_OPEN) {
animAttr = enter
? R.styleable.WindowAnimation_dreamActivityOpenEnterAnimation
: R.styleable.WindowAnimation_dreamActivityOpenExitAnimation;
} else if (type == TRANSIT_CLOSE) {
animAttr = enter
? 0
: R.styleable.WindowAnimation_dreamActivityCloseExitAnimation;
}
} else if (wallpaperTransit == WALLPAPER_TRANSITION_INTRA_OPEN) {
animAttr = enter
? R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation
: R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
@@ -790,6 +804,11 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
a = mTransitionAnimation.loadDefaultAnimationAttr(animAttr, translucent);
}
}
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
"loadAnimation: anim=%s animAttr=0x%x type=%s isEntrance=%b", a, animAttr,
transitTypeToString(type),
enter);
}
if (a != null) {

View File

@@ -34,6 +34,8 @@ import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_RELAUNCH;
import static android.view.WindowManager.TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_DREAM_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_DREAM_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_OCCLUDE;
@@ -64,6 +66,9 @@ import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnte
import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation;
import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
import static com.android.internal.R.styleable.WindowAnimation_dreamActivityCloseExitAnimation;
import static com.android.internal.R.styleable.WindowAnimation_dreamActivityOpenEnterAnimation;
import static com.android.internal.R.styleable.WindowAnimation_dreamActivityOpenExitAnimation;
import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation;
import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation;
import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation;
@@ -835,6 +840,16 @@ public class AppTransition implements Dump {
? WindowAnimation_activityCloseEnterAnimation
: WindowAnimation_activityCloseExitAnimation;
break;
case TRANSIT_OLD_DREAM_ACTIVITY_OPEN:
animAttr = enter
? WindowAnimation_dreamActivityOpenEnterAnimation
: WindowAnimation_dreamActivityOpenExitAnimation;
break;
case TRANSIT_OLD_DREAM_ACTIVITY_CLOSE:
animAttr = enter
? 0
: WindowAnimation_dreamActivityCloseExitAnimation;
break;
}
a = animAttr != 0 ? loadAnimationAttr(lp, animAttr, transit) : null;
@@ -1157,6 +1172,12 @@ public class AppTransition implements Dump {
case TRANSIT_OLD_TASK_FRAGMENT_CHANGE: {
return "TRANSIT_OLD_TASK_FRAGMENT_CHANGE";
}
case TRANSIT_OLD_DREAM_ACTIVITY_OPEN: {
return "TRANSIT_OLD_DREAM_ACTIVITY_OPEN";
}
case TRANSIT_OLD_DREAM_ACTIVITY_CLOSE: {
return "TRANSIT_OLD_DREAM_ACTIVITY_CLOSE";
}
default: {
return "<UNKNOWN: " + transition + ">";
}

View File

@@ -16,6 +16,7 @@
package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
@@ -32,6 +33,8 @@ import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_RELAUNCH;
import static android.view.WindowManager.TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_DREAM_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_DREAM_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_OCCLUDE;
@@ -314,6 +317,9 @@ public class AppTransitionController {
ArraySet<WindowContainer> changingContainers, @Nullable WindowState wallpaperTarget,
@Nullable WindowState oldWallpaper, boolean skipAppTransitionAnimation) {
final ActivityRecord topOpeningApp = getTopApp(openingApps, false /* ignoreHidden */);
final ActivityRecord topClosingApp = getTopApp(closingApps, true /* ignoreHidden */);
// Determine if closing and opening app token sets are wallpaper targets, in which case
// special animations are needed.
final boolean openingAppHasWallpaper = canBeWallpaperTarget(openingApps)
@@ -321,7 +327,7 @@ public class AppTransitionController {
final boolean closingAppHasWallpaper = canBeWallpaperTarget(closingApps)
&& wallpaperTarget != null;
// Keyguard transit has highest priority.
// Keyguard transit has high priority.
switch (appTransition.getKeyguardTransition()) {
case TRANSIT_KEYGUARD_GOING_AWAY:
return openingAppHasWallpaper ? TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER
@@ -336,6 +342,15 @@ public class AppTransitionController {
return TRANSIT_OLD_KEYGUARD_UNOCCLUDE;
}
// Determine whether the top opening and closing activity is a dream activity. If so, this
// has higher priority than others except keyguard transit.
if (topOpeningApp != null && topOpeningApp.getActivityType() == ACTIVITY_TYPE_DREAM) {
return TRANSIT_OLD_DREAM_ACTIVITY_OPEN;
} else if (topClosingApp != null
&& topClosingApp.getActivityType() == ACTIVITY_TYPE_DREAM) {
return TRANSIT_OLD_DREAM_ACTIVITY_CLOSE;
}
// This is not keyguard transition and one of the app has request to skip app transition.
if (skipAppTransitionAnimation) {
return WindowManager.TRANSIT_OLD_UNSET;
@@ -399,11 +414,6 @@ public class AppTransitionController {
}
}
final ActivityRecord topOpeningApp = getTopApp(openingApps,
false /* ignoreHidden */);
final ActivityRecord topClosingApp = getTopApp(closingApps,
true /* ignoreHidden */);
if (closingAppHasWallpaper && openingAppHasWallpaper) {
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "Wallpaper animation!");
switch (firstTransit) {

View File

@@ -16,6 +16,7 @@
package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
@@ -25,6 +26,8 @@ import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_DREAM_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_DREAM_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
@@ -154,6 +157,32 @@ public class AppTransitionControllerTest extends WindowTestsBase {
mDisplayContent.mChangingContainers, null, null, false));
}
@Test
public void testDreamActivityOpenTransition() {
final ActivityRecord dreamActivity = createActivityRecord(mDisplayContent,
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_DREAM);
mDisplayContent.prepareAppTransition(TRANSIT_OPEN);
mDisplayContent.mOpeningApps.add(dreamActivity);
assertEquals(TRANSIT_OLD_DREAM_ACTIVITY_OPEN,
AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition,
mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps,
mDisplayContent.mChangingContainers, null, null, false));
}
@Test
public void testDreamActivityCloseTransition() {
final ActivityRecord dreamActivity = createActivityRecord(mDisplayContent,
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_DREAM);
mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);
mDisplayContent.mClosingApps.add(dreamActivity);
assertEquals(TRANSIT_OLD_DREAM_ACTIVITY_CLOSE,
AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition,
mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps,
mDisplayContent.mChangingContainers, null, null, false));
}
@Test
public void testChangeIsNotOverwritten() {
final ActivityRecord behind = createActivityRecord(mDisplayContent,