/********************************************************************************
** Copyright (C), 2023-2123, Oplus Mobile Comm Corp., Ltd
** All rights reserved.
**
** File: - OplusTransitionController.java
** Description:
** Connector of oplus transition and shell transtion
**
** Version: 1.0
** Date: 2023-02-02
** Author: LiYichen@ANDROID.WMS
** TAG: OPLUS_FEATURE_SHELL_TRANSITION
** ------------------------------- Revision History: ----------------------------
** <author> <data> <version> <desc>
** ------------------------------------------------------------------------------
** LiYichen@ANDROID.WMS 2023-03-13 1.0 Create this module
********************************************************************************/
package com.android.wm.shell.transition;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.ArrayMap;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.window.RemoteTransition;
import android.window.TransitionInfo;
import android.window.WindowContainerTransaction;
import android.window.WindowOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.flexibletask.FlexibleTaskTransitionHandler;
import com.android.wm.shell.flexiblewindow.FlexibleWindowTransitionHandler;
import com.android.wm.shell.putt.OnePuttTransitionHandler;
import com.android.wm.shell.recents.RecentsTransitionHandler;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.shared.TransitionUtil;
import com.oplus.flexiblewindow.FlexibleWindowManager;
import com.oplus.flexibleactivity.FlexibleActivityTransitionHandler;
import com.oplus.foldswitch.OplusFoldingSwitchAnimationManager;
import com.oplus.splitscreen.SplitToggleHelper;
import com.oplus.transition.FlexibleSubDisplayTransition;
import com.oplus.transition.OplusInterruptTransitionManager;
import com.oplus.transition.OplusShellLightOSTransition;
import com.oplus.transition.OplusRemoteInterruptManager;
import com.oplus.transition.OplusRotationAnimationManager;
import com.oplus.transition.OplusTransitionAnimationManager;
import com.oplus.transition.OplusCompatModeAnimationManager;
import com.oplus.view.inputmethod.OplusInputMethodManager;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
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.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;
import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;
import static android.window.TransitionInfo.FLAG_FILLS_TASK;
import static com.oplus.transition.FlexibleTransitionUtils.LAUNCH_SCENARIO_SUB_DISPLAY;
import static com.oplus.transition.OplusTransitionAnimationManager.NO_BACKCOLOR_PACKAGE_IN_SCREEN_ROTATION;
import static com.oplus.wrapper.window.TransitionInfo.FLAG_IS_BEHIND_STARTING_WINDOW;
import java.util.ArrayList;
public class OplusTransitionController {
/**
** delay one second releaseSurfaces while finish-for-sync track
**/
static final int DELAY_RELEASE_TIME = 1000;
//#ifndef OPLUS_FEATURE_SHELL_TRANSITION
//Guofu.Yang@ANDROID.WMS 2023/9/19, Add for bug 6251064,too many Offscreen Layers
/** Same as OplusTransitionAnimationManager FLAG_TRANSITION_FINISH_RELEASE,no duplication with TransitionInfo#ChangeFlags **/
private static final int FLAG_TRANSITION_FINISH_RELEASE = 1 << 30;
//#endif /*OPLUS_FEATURE_SHELL_TRANSITION*/
private static volatile OplusTransitionController sInstance;
/* transition features */
private OplusTransitionAnimationManager mTransitionAnimation;
private OplusRotationAnimationManager mRotationAnimation;
private OplusShellLightOSTransition mLightOSTransition;
private OplusFoldingSwitchAnimationManager mFoldSwitchAnimation;
private OplusRemoteInterruptManager mRemoteInterrupt;
private FlexibleSubDisplayTransition mFlexibleSubDisplayTransition;
private OplusCompatModeAnimationManager mOplusCompatModeAnimationManager;
private Context mContext;
private Handler mHandler;
private DisplayController mDisplayController;
private TransactionPool mTransactionPool;
private Transitions mTransitions;
private boolean mLoadLightScreenRotation = false;
private ShellExecutor mMainExecutor;
//#ifdef OPLUS_FEATURE_FLEXIBLEWINDOW
//Fuhai.Tan@ANDROID.WMS, 2023/8/4, add for ps shell transition(alm5954198)
// add for ps display change
private FlexibleWindowTransitionHandler mFlexibleWindowTransitionHandler;
//#endif /* OPLUS_FEATURE_FLEXIBLEWINDOW */
private FlexibleTaskTransitionHandler mFlexibleTaskTransitionHandler;
/* need to adapter dagger inject? */
public static OplusTransitionController getInstance() {
if (sInstance == null) {
synchronized (OplusTransitionController.class) {
if (sInstance == null) {
sInstance = new OplusTransitionController();
}
}
}
return sInstance;
}
public void setTransitions(Transitions transitions) {
this.mTransitions = transitions;
}
public void init(Context context, Handler mainHandler, DisplayController displayController,
ShellExecutor mainExecutor, ShellExecutor animExecutor, TransactionPool pool) {
mContext = context;
mHandler = mainHandler;
mDisplayController = displayController;
mTransactionPool = pool;
initDisplayListener();
mTransitionAnimation = new OplusTransitionAnimationManager(context);
mRotationAnimation = new OplusRotationAnimationManager(context, mainExecutor, animExecutor);
if (OplusShellLightOSTransition.IS_LIGHTOS) {
mLightOSTransition = new OplusShellLightOSTransition(context);
}
mRemoteInterrupt = new OplusRemoteInterruptManager();
//#endif /* OPLUS_FEATURE_FLEXIBLEWINDOW */
//songchunlong@ANDROID.WMS, 2023/10/09, add for flexibleTask shell transition
mFlexibleTaskTransitionHandler = new FlexibleTaskTransitionHandler(mainExecutor, animExecutor, pool, context, mTransitions);
//#endif /* OPLUS_FEATURE_FLEXIBLETask */
//#ifdef OPLUS_FEATURE_FOLDABLE_DISPLAY_SWITCH
//LiangHan@ANDROID.WMS, 2023/06/06, Add for folded switching
mFoldSwitchAnimation = new OplusFoldingSwitchAnimationManager(context, mainExecutor);
mFoldSwitchAnimation.registerOplusFoldSwitchStateObserver();
//#endif /* OPLUS_FEATURE_FOLDABLE_DISPLAY_SWITCH */
//#ifdef OPLUS_FEATUR_ONEPUTT
//luochuang@ANDROID.WMS, 2023/07/08, Add for putt
OnePuttTransitionHandler onePuttTransitionHandler = new OnePuttTransitionHandler(mainExecutor, animExecutor, pool, displayController);
mTransitions.addHandler(onePuttTransitionHandler);
//#endif /* OPLUS_FEATUR_ONEPUTT */
//#ifdef OPLUS_FEATURE_FLEXIBLEWINDOW
//Fuhai.Tan@ANDROID.WMS, 2023/8/4, add for ps shell transition(alm5954198)
if (FlexibleWindowManager.getInstance().isSupportPocketStudio(context)) {
mFlexibleWindowTransitionHandler = new FlexibleWindowTransitionHandler(mainExecutor, animExecutor, pool, context, mTransitions);
}
//#endif /* OPLUS_FEATURE_FLEXIBLEWINDOW */
//#ifdef OPLUS_FEATURE_FLEXIBLEACTIVITY
//Li.Wang@ANDROID.WMS, 2023/09/26, Add for putt
FlexibleActivityTransitionHandler flexibleActivityTransitionHandler = new FlexibleActivityTransitionHandler(
mainExecutor, animExecutor, pool, displayController, context);
mTransitions.addHandler(flexibleActivityTransitionHandler);
//#endif /* OPLUS_FEATURE_FLEXIBLEACTIVITY */
mFlexibleSubDisplayTransition = new FlexibleSubDisplayTransition(context);
mOplusCompatModeAnimationManager = new OplusCompatModeAnimationManager(context);
OplusInterruptTransitionManager.getInstance().init(mTransitions);
}
private void initDisplayListener() {
mDisplayController.addDisplayWindowListener(new DisplayController.OnDisplaysChangedListener() {
@Override
public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
mRotationAnimation.onConfigurationChanged(newConfig);
if (mLightOSTransition != null) {
mLightOSTransition.onConfigurationChanged(newConfig);
}
if (mTransitionAnimation != null) {
mTransitionAnimation.onConfigurationChanged(displayId, mDisplayController);
}
}
});
}
/**
* skip default transition if need
*/
public boolean skipDefaultTransition(TransitionInfo info, TransitionInfo.Change change) {
TransitionLog.debug("load DefaultTransition, info.getType = " + WindowManager.transitTypeToString(info.getType())
+ ", info.flag = " + Integer.toHexString(info.getFlags())
+ ", isTask = " + (change.getTaskInfo() != null)
+ "\n-- change = " + change + " " + change.getFlags()
+ "\n-- animationoptions = " + info.getAnimationOptions());
if (change.getLeash() == null || !change.getLeash().isValid()) {
TransitionLog.w("skipDefaultTransition, leash has been released");
return true;
}
// #ifdef OPLUS_FEATURE_ANIMATION
// Qin.Ding@ANDROID.WMS 2024/08/08, Modify for almid:7684438
if (mTransitionAnimation.skipDefaultTransitionIfNeed(info, change)) {
return true;
}
// #endif /* OPLUS_FEATURE_ANIMATION */
//#ifdef OPLUS_FEATURE_FOLDABLE_DISPLAY_SWITCH
//LiangHan@ANDROID.WMS, 2023/09/08, Add for folded switching
if (mFoldSwitchAnimation.skipDefaultTransitionIfNeed(info, change)) {
return true;
}
//#endif /* OPLUS_FEATURE_FOLDABLE_DISPLAY_SWITCH */
//#ifdef OPLUS_FEATURE_FLEXIBLEWINDOW
//Fuhai.Tan@ANDROID.WMS, 2023/8/4, add for ps shell transition(alm5954198)
// add for ps display change
if (mFlexibleWindowTransitionHandler != null) {
return mFlexibleWindowTransitionHandler.skipDefaultTransition(info, change);
}
//#endif /* OPLUS_FEATURE_FLEXIBLEWINDOW */
return false;
}
/**
* hook for default activity/task transition
*/
public Animation hookTransitionAnimation(TransitionInfo info, @NonNull TransitionInfo.Change change,
boolean translucent, int wallpaperTransit, int animArrt) {
//#ifdef OPLUS_FEATURE_SHELL_TRANSITION
//WeiJianjun@ANDROID.WMS, 2024/01/30, Add for feature 6789761
boolean isTask = change.getTaskInfo() != null;
final int changeMode = change.getMode();
final boolean enter = TransitionUtil.isOpeningType(changeMode);
//#endif /*OPLUS_FEATURE_SHELL_TRANSITION*/
//#ifdef OPLUS_FEATURE_SHELL_TRANSITION
//JiangYi@ANDROID.WMS 2023/10/20, Add for bug:6134388
Animation a = null;
if (mTransitionAnimation.isWsnSwitch(info.getType(), change)
&& !mTransitionAnimation.isLargeScreenTaskSwitch(info.getType(), change)) {
a = mTransitionAnimation.loadWsnTaskSwitchAnimation(info.getType(), enter);
if (a != null) {
return a;
}
}
//#endif /* OPLUS_FEATURE_SHELL_TRANSITIONH */
//#ifndef OPLUS_FEATURE_LARGESCREEN_TASK_SWITCH
//Changzhi.Wu@ANDROID.WMS, 2023/9/4 : Add for task switch in large screen
Animation animation = null;
if (mTransitionAnimation.isLargeScreenTaskSwitch(info.getType(), change)) {
animation = mTransitionAnimation.loadLargeScreenTaskSwitchAnimation(info.getType(), enter);
if (animation != null) {
return animation;
}
}
////#endif /* OPLUS_FEATURE_LARGESCREEN_TASK_SWITCH */
if (mLightOSTransition != null) {
Animation lightOSTransition =
mLightOSTransition.loadLightCompactWindowAnimation(info.getAnimationOptions(), enter);
if (lightOSTransition != null) {
return lightOSTransition;
}
}
if (mOplusCompatModeAnimationManager != null) {
Animation oplusCompatModeAnimation = mOplusCompatModeAnimationManager
.getOplusCompatModeAnimation(info, enter, isTask, translucent, wallpaperTransit);
if (oplusCompatModeAnimation != null) {
return oplusCompatModeAnimation;
}
}
return mTransitionAnimation.getOplusDefaultTransition(info, change, enter,
translucent, wallpaperTransit, animArrt);
}
/**
* hook for default custom transition
*/
public Animation hookCustomAnimation(TransitionInfo.AnimationOptions options, int transit,
boolean enter) {
return mTransitionAnimation.checkAndLoadCustomAnimation(options, transit, enter);
}
/**
* adjust layer
*
* @param position
* @param info
* @param transaction
*/
public void adjustZBoostForLayer(int index, @NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction transaction) {
mTransitionAnimation.adjustZBoostForLayer(index, info, transaction);
}
/**
* hook for screen rotation animation
*/
public Animation[] hookRotationAnimation(int delta, int originWidth, int originHeight,
int finalWidth, int finalHeight, SurfaceControl surface, TransitionInfo info) {
//#ifdef OPLUS_FEATURE_SHELL_TRANSITION
//Nana.Pang@ANDROID.WMS,2024/02/23, add for dark mode transition
Animation[] oplusAnimation = null;
// LightOS rotation animation
if (loadLightScreenRotationAnimations()) {
oplusAnimation = mRotationAnimation.getLightScreenRotationAnimations(delta,
originWidth, originHeight, finalWidth, finalHeight);
mLoadLightScreenRotation = false;
} else { // normal rotation animation
oplusAnimation = mRotationAnimation.getDefaultRotationAnimations(delta,
originWidth, originHeight, finalWidth, finalHeight);
}
//#endif /*OPLUS_FEATURE_SHELL_TRANSITION*/
// device fold rotation animation
if (TransitionAnimationUtil.isFoldDevice() && !TransitionAnimationUtil.isFlipDevice()
&& isFoldChangeOpen(info)) {
oplusAnimation = mFoldSwitchAnimation.getDeviceFoldingRotationAnimations(delta, originWidth, originHeight,
finalWidth, finalHeight);
}
// BracketModeAnimations
return oplusAnimation;
}
/**
* hook for screen rotation back color.
*/
public boolean hookScreenRotateBackColor(TransitionInfo info, TransitionInfo.Change change) {
if ((TransitionAnimationUtil.isFoldDevice() && !TransitionAnimationUtil.isFlipDevice())
|| TransitionAnimationUtil.isTabletDevice()) {
return !(change.hasFlags(TransitionInfo.FLAG_SHOW_WALLPAPER)
&& mRotationAnimation.isLauncherRotateScene(info));
}
return true;
}
public boolean hookScreenRotateBackColorAnimation(float[] backColorRGBFloats,
Animation animation,
SurfaceControl leash, TransactionPool pool) {
return mRotationAnimation.startScreenRotateBackColorAnimation(backColorRGBFloats,
animation, leash, pool);
}
public SurfaceControl.Transaction hookTransitionFinish(TransitionInfo activeInfo,
SurfaceControl.Transaction fullFinish,
TransitionInfo readyInfo, WindowContainerTransaction wct,
WindowOrganizer windowOrganizer) {
SurfaceControl.Transaction result = null;
//#ifdef OPLUS_FEATURE_SPLITSCREEN
//Chenzhe@ANDROID.WMS, 2023/06/23, add for android U shell_transition
if (windowOrganizer != null && ((ShellTaskOrganizer) windowOrganizer).getStageCoordinator() != null) {
((ShellTaskOrganizer) windowOrganizer).getStageCoordinator().hookFinishTransactionOnFinish(activeInfo, fullFinish);
}
//#endif /* OPLUS_FEATURE_SPLITSCREEN */
result = mRemoteInterrupt.fixFinishTransaction(activeInfo, fullFinish, readyInfo, wct);
return (result != null) ? result : fullFinish;
}
public void hookRecentStart(TransitionInfo info,
ArrayMap<SurfaceControl, SurfaceControl> leashMap,
SurfaceControl.Transaction startT,
SurfaceControl.Transaction finishT) {
boolean isFinishHideIme = false;
for (int i = 0; i < info.getChanges().size(); ++i) {
final TransitionInfo.Change change = info.getChanges().get(i);
mRemoteInterrupt.fixAlphaInRecentStart(change, leashMap, startT);
if (!isFinishHideIme && change.getTaskInfo() != null && TransitionAnimationUtil.getScenario(change.getTaskInfo().getConfiguration())
== LAUNCH_SCENARIO_SUB_DISPLAY) {
OplusInputMethodManager.getInstance().hideCurrentInputMethod();
isFinishHideIme = true;
}
}
if (mOplusCompatModeAnimationManager != null) {
mOplusCompatModeAnimationManager.onRecentAnimationStart();
}
//#ifdef OPLUS_FEATURE_INTERRUPT_TRANSITION
//LiYichen@ANDROID.WMS 2023//, Add for oplus shell transition
OplusInterruptTransitionManager.getInstance().resetRemoteInterrupt();
//#endif /*OPLUS_FEATURE_INTERRUPT_TRANSITION*/
}
public void hookRecentFinish() {
if (mOplusCompatModeAnimationManager != null) {
mOplusCompatModeAnimationManager.onRecentAnimationEnd();
}
}
public void hookProcessReady() {
mRemoteInterrupt.reset();
}
/**
* add for global rounded corner
*/
public float getRoundedCornersIfNeed(int transit, int wallpaperTransit, boolean enter,
Animation animation,
TransitionInfo.AnimationOptions options) {
return mTransitionAnimation.getRoundedCornersIfNeed(transit, wallpaperTransit, enter,
animation, options);
}
public boolean isRemoteInterrupt() {
return mRemoteInterrupt != null && mRemoteInterrupt.isRemoteInterrupt();
}
public boolean skipFinishForSync(Transitions.TransitionHandler activeHandler,
TransitionInfo readyInfo) {
// L-A-L-B , B can start
if (readyInfo.getTrack() == OplusInterruptTransitionManager.INTERRUPT_TRACK) {
TransitionLog.always("skipFinishForSync when interrupt track");
return true;
}
// bugid: 6323681/6703089/6989073
if (activeHandler != null && activeHandler instanceof RecentsTransitionHandler
&& (readyInfo.getType() == TRANSIT_TO_FRONT || readyInfo.getType() == TRANSIT_OPEN)) {
TransitionLog.w("skipFinishForSync readyInfo.getType:" + readyInfo.getType());
return true;
}
return false;
}
/**
* get extra bundle params for animation
*/
public Bundle getAnimExtraBundle(TransitionInfo info, TransitionInfo.Change change) {
//#ifdef OPLUS_FEATURE_ADFR_V32_SUPPORT
//chendongqi@oppo.com, 2024/08/10, change parameter for setFrameRate
return (mFlexibleSubDisplayTransition != null) ? mFlexibleSubDisplayTransition.getAnimExtraBundle(change) : null;
//#endif /* OPLUS_FEATURE_ADFR_V32_SUPPORT */
}
public boolean canCustomizeAppTransition(TransitionInfo.AnimationOptions options, int type, TransitionInfo.Change change) {
boolean isTranslucentCloseTransition = (type == TRANSIT_CLOSE || type == TRANSIT_TO_BACK)
&& (change.getFlags() & FLAG_TRANSLUCENT) != 0;
return options.getOverrideTaskTransition()
|| TransitionAnimationUtil.isSystemApp(options.getPackageName())
|| isTranslucentCloseTransition;
}
public void adjustDefaultTransitionStartState(int index, Animation a, TransitionInfo.Change change,
TransitionInfo info, SurfaceControl.Transaction startTransaction) {
mTransitionAnimation.adjustAnimHierarchyLayer(index, a, change, info, startTransaction);
mTransitionAnimation.adjustAnimStartAlpha(info, change, startTransaction);
}
public void setAlphaForCustom(@NonNull TransitionInfo info,
@NonNull TransitionInfo.Change change,
SurfaceControl.Transaction startT, Animation a) {
mTransitionAnimation.setAlphaForCustom(info, change, startT, a);
}
// #ifdef OPLUS_FEATURE_ANIMATION
// Qin.Ding@ANDROID.WMS 2023/10/14, Modify for almid:6271944
public boolean matchRemoteFilter(@NonNull TransitionInfo info) {
return mTransitionAnimation.matchRemoteFilter(info);
}
// Qin.Ding@ANDROID.WMS 2024/05/23, add for almid:6990651
/**
* isWallpaperTransitionIntraClose
*
* @param info TransitionInfo
* @return True if hasOpenWallpaper and hasCloseWallpaper and TRANSIT_CLOSE.
*/
public boolean isWallpaperTransitionIntraClose(@NonNull TransitionInfo info) {
return mTransitionAnimation.isWallpaperTransitionIntraClose(info);
}
// #endif /* OPLUS_FEATURE_ANIMATION */
// #ifdef OPLUS_FEATURE_ANIMATION
// zhengdongtao@ANDROID.WMS 2024/05/28, Modify for almid:6271944
public boolean matchCustomFilter(@NonNull TransitionInfo info) {
return mTransitionAnimation.isCustomFilter(info);
}
public void adjustWsnHierarchyLayer(TransitionInfo info, SurfaceControl.Transaction startTransaction) {
mTransitionAnimation.adjustWsnHierarchyLayer(info, startTransaction);
}
// #endif /* OPLUS_FEATURE_ANIMATION */
// #ifdef OPLUS_FEATURE_ANIMATION
// Qin.Ding@ANDROID.WMS 2023/10/17, Modify for almid:6347638
public void registerReceiverForPkgRemoved() {
mTransitionAnimation.registerReceiverForPkgRemoved();
}
// #endif /* OPLUS_FEATURE_ANIMATION */
// #ifdef OPLUS_FEATURE_REMOTE_INTERRUPT_ANIMATION
// Qin.Ding@ANDROID.WMS 2023/11/20, Modify for almid:6448325
public boolean ignoreAbort(@NonNull TransitionInfo info) {
return mTransitionAnimation.ignoreAbort(info);
}
// #endif /* OPLUS_FEATURE_REMOTE_INTERRUPT_ANIMATION */
public Bundle getTaskAnimExtraBundle(TransitionInfo info) {
return mFlexibleSubDisplayTransition.getTaskAnimExtraBundle(info);
}
public boolean disableTaskBackgroundColor() {
TransitionLog.debug("disable task background color");
return true;
}
public boolean shouldHideSurface(@NonNull TransitionInfo.Change change) {
return mTransitionAnimation.shouldHideSurface(change);
}
public boolean loadLightScreenRotationAnimations() {
return OplusShellLightOSTransition.IS_LIGHTOS || mLoadLightScreenRotation;
}
public void loadLightScreenRotationForApp(@NonNull TransitionInfo info) {
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
final TransitionInfo.Change change = info.getChanges().get(i);
boolean isChangeType = (change.getMode() == TRANSIT_CHANGE) && (info.getType() == TRANSIT_CHANGE);
boolean rotationChange = change.getStartRotation() != change.getEndRotation();
boolean lightOSAppType = isLightOSAppType(change);
if (isChangeType && rotationChange && lightOSAppType) {
mLoadLightScreenRotation = true;
return;
}
}
}
public boolean isLightOSAppType(@NonNull TransitionInfo.Change change) {
ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
ComponentName realActivity = (taskInfo != null) ? taskInfo.realActivity : null;
if (realActivity != null) {
String targetPackage = realActivity.getPackageName();
for (String packageName : NO_BACKCOLOR_PACKAGE_IN_SCREEN_ROTATION) {
if (packageName.equals(targetPackage)) {
return true;
}
}
}
return false;
}
//#ifdef OPLUS_FEATURE_SHELL_TRANSITION
//WeiJianjun@ANDROID.WMS, 2024/01/30, Add for feature 6789761
public boolean shouldLoadCustomAnimation(TransitionInfo.AnimationOptions options, int animAttr) {
return TransitionAnimationUtil.shouldLoadCustomAnimation(options, animAttr);
}
//#endif /*OPLUS_FEATURE_SHELL_TRANSITION*/
//#ifdef OPLUS_FEATURE_FLEXIBLEWINDOW
//#LiuXuefeng@ANDROID.WMS, 2023/10/08, Add for 6280618
public void hookTransitionFinishForFlexibleMinimize(Transitions.ActiveTransition active, SurfaceControl.Transaction fullFinish) {
ArrayList<TransitionInfo> animatingInfo = new ArrayList<>();
TransitionInfo info = active.mInfo;
if (info != null) {
animatingInfo.add(info);
}
if (active.mMerged != null) {
for (Transitions.ActiveTransition at : active.mMerged) {
if (at != null && at.mInfo != null && (at.mInfo.getType() == TRANSIT_OPEN || at.mInfo.getType() == TRANSIT_TO_FRONT)) {
animatingInfo.add(at.mInfo);
}
}
}
SplitScreenController controller = SplitToggleHelper.getInstance().peekDivider();
if (controller != null && !animatingInfo.isEmpty()) {
controller.adjustChangeForFlexibleMinimizeIfNeed(active.mHandler, animatingInfo, fullFinish);
}
}
//#endif /* OPLUS_FEATURE_FLEXIBLEWINDOW */
public boolean disableForceSyncIfNeed(int tolerance, IBinder reasonTransition, IBinder playingTransition,
Transitions.TransitionHandler reasonHandler, Transitions.TransitionHandler playingHandler,
TransitionInfo reasonInfo, TransitionInfo playingInfo) {
SplitScreenController controller = SplitToggleHelper.getInstance().peekDivider();
if (controller != null && controller.getExtImpl() != null) {
return controller.getExtImpl().disableForceSyncIfNeed(tolerance, reasonTransition,
playingTransition, reasonHandler, playingHandler, reasonInfo, playingInfo);
}
return false;
}
public boolean abortTransitionIfNeeded(Transitions.ActiveTransition ready, Transitions.ActiveTransition playing) {
if (ready.mInfo.getType() == TRANSIT_RELAUNCH
&& playing != null && playing.mHandler instanceof RecentsTransitionHandler) {
TransitionLog.always("Abort transition " + ready + " when recent " + playing + " is playing");
return true;
}
if (ready.mInfo.getType() == TRANSIT_OPEN) {
final int changeSize = ready.mInfo.getChanges().size();
for (int i = changeSize - 1; i >= 0; --i) {
final TransitionInfo.Change change = ready.mInfo.getChanges().get(i);
if (change.hasAllFlags(FLAG_TRANSLUCENT
| FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY
| FLAG_FILLS_TASK | FLAG_IS_BEHIND_STARTING_WINDOW)) {
TransitionLog.always("Abort transition " + ready + " when translucent embed activities transit.");
return true;
}
}
}
return false;
}
//#ifndef OPLUS_FEATURE_SHELL_TRANSITION
//Guofu.Yang@ANDROID.WMS 2023/9/19, Add for bug 6251064,too many Offscreen Layers bugid:7240816
public void releaseSurfaces(TransitionInfo info) {
if (info == null) {
return;
}
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
final TransitionInfo.Change change = info.getChanges().get(i);
if (change.hasFlags(FLAG_TRANSITION_FINISH_RELEASE)) {
if ((change.getLeash() != null) && change.getLeash().isValid()
&& (info.getType() < TRANSIT_FIRST_CUSTOM)
&& ((change.getTaskInfo() == null) || (change.getTaskInfo().getWindowingMode() == WINDOWING_MODE_FULLSCREEN))) {
change.getLeash().release();
}
}
}
}
//#endif /*OPLUS_FEATURE_SHELL_TRANSITION*/
public boolean hasSameUserId(RemoteTransition pendingRemote, TransitionInfo info) {
return mTransitionAnimation.hasSameUserId(pendingRemote, info);
}
public void markUserIdTransition(@NonNull RemoteTransition remoteTransition) {
mTransitionAnimation.markUserIdTransition(remoteTransition);
}
public boolean hookStartRecentsTransiton(RecentsTransitionHandler.RecentsController controller,
WindowContainerTransaction wct) {
if (mTransitionAnimation.cancelStartRecentsTransition(controller, mTransitions)) {
return false;
}
//#ifdef OPLUS_FEATURE_SHELL_TRANSITION
//Li.Wang@ANDROID.WMS, 2023/09/23, Add for oplus shell transition(aimid 6254609)
OplusRemoteInterruptManager.ReflectionHelper.setRecentTransition(wct, true);
//#endif /*OPLUS_FEATURE_SHELL_TRANSITION*/
return true;
}
public boolean isDeviceFolded() {
return mFoldSwitchAnimation.getDeviceFolded();
}
public boolean ifMergeIntoRemote(TransitionInfo info, SurfaceControl.Transaction t,
Transitions.TransitionFinishCallback finishCallback,
boolean mergedIsNotRemote) {
return !OplusInterruptTransitionManager.getInstance().ifMergeIntoRemote(info, t, finishCallback, mergedIsNotRemote)
&& !mTransitionAnimation.shouldMergeToRemote(info, mTransitions);
}
public void initAnimLayerWhenFolding(SurfaceControl.Transaction t, SurfaceControl animLeash, TransitionInfo info,
int startWidth, int startHeight) {
mFoldSwitchAnimation.initAnimLayerWhenFolding(t, animLeash, info, startWidth, startHeight);
}
public boolean cancelAnimationIfNeedWhenFolding(TransitionInfo info) {
return mFoldSwitchAnimation.cancelAnimationIfNeedWhenFolding(info);
}
public boolean isFoldChangeOpen(TransitionInfo info) {
return mFoldSwitchAnimation.getFoldChangeType(info) == OplusFoldingSwitchAnimationManager.FOLD_SWITCHING_TRANSITION_OPEN;
}
}
解析以上该类和该类的所有方法的作用和含义