| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.wm.shell.transition; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.os.RemoteException; |
| 21 |
import android.view.IRemoteAnimationFinishedCallback; |
| 22 |
import android.view.IRemoteAnimationRunner; |
| 23 |
import android.view.RemoteAnimationAdapter; |
| 24 |
import android.view.RemoteAnimationTarget; |
| 25 |
import android.view.SurfaceControl; |
| 26 |
import android.view.WindowManager; |
| 27 |
import android.window.IWindowContainerTransactionCallback; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class LegacyTransitions { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public interface ILegacyTransition { |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
void onAnimationStart(int transit, RemoteAnimationTarget[] apps, |
| 45 |
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps, |
| 46 |
IRemoteAnimationFinishedCallback finishedCallback, SurfaceControl.Transaction t); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public static class LegacyTransition { |
| 55 |
private final ILegacyTransition mLegacyTransition; |
| 56 |
private int mSyncId = -1; |
| 57 |
private SurfaceControl.Transaction mTransaction; |
| 58 |
private int mTransit; |
| 59 |
private RemoteAnimationTarget[] mApps; |
| 60 |
private RemoteAnimationTarget[] mWallpapers; |
| 61 |
private RemoteAnimationTarget[] mNonApps; |
| 62 |
private IRemoteAnimationFinishedCallback mFinishCallback = null; |
| 63 |
private boolean mCancelled = false; |
| 64 |
private final SyncCallback mSyncCallback = new SyncCallback(); |
| 65 |
private final RemoteAnimationAdapter mAdapter = |
| 66 |
new RemoteAnimationAdapter(new RemoteAnimationWrapper(), 0, 0); |
| 67 |
|
| 68 |
public LegacyTransition(@WindowManager.TransitionType int type, |
| 69 |
@NonNull ILegacyTransition legacyTransition) { |
| 70 |
mLegacyTransition = legacyTransition; |
| 71 |
mTransit = type; |
| 72 |
} |
| 73 |
|
| 74 |
public @WindowManager.TransitionType int getType() { |
| 75 |
return mTransit; |
| 76 |
} |
| 77 |
|
| 78 |
public IWindowContainerTransactionCallback getSyncCallback() { |
| 79 |
return mSyncCallback; |
| 80 |
} |
| 81 |
|
| 82 |
public RemoteAnimationAdapter getAdapter() { |
| 83 |
return mAdapter; |
| 84 |
} |
| 85 |
|
| 86 |
private class SyncCallback extends IWindowContainerTransactionCallback.Stub { |
| 87 |
@Override |
| 88 |
public void onTransactionReady(int id, SurfaceControl.Transaction t) |
| 89 |
throws RemoteException { |
| 90 |
mSyncId = id; |
| 91 |
mTransaction = t; |
| 92 |
checkApply(); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
private class RemoteAnimationWrapper extends IRemoteAnimationRunner.Stub { |
| 97 |
@Override |
| 98 |
public void onAnimationStart(int transit, RemoteAnimationTarget[] apps, |
| 99 |
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps, |
| 100 |
IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException { |
| 101 |
mTransit = transit; |
| 102 |
mApps = apps; |
| 103 |
mWallpapers = wallpapers; |
| 104 |
mNonApps = nonApps; |
| 105 |
mFinishCallback = finishedCallback; |
| 106 |
checkApply(); |
| 107 |
} |
| 108 |
|
| 109 |
@Override |
| 110 |
public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException { |
| 111 |
mCancelled = true; |
| 112 |
mApps = mWallpapers = mNonApps = null; |
| 113 |
checkApply(); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
private void checkApply() throws RemoteException { |
| 119 |
if (mSyncId < 0 || (mFinishCallback == null && !mCancelled)) return; |
| 120 |
mLegacyTransition.onAnimationStart(mTransit, mApps, mWallpapers, |
| 121 |
mNonApps, mFinishCallback, mTransaction); |
| 122 |
} |
| 123 |
} |
| 124 |
} |