diff options
10 files changed, 413 insertions, 1 deletions
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java index a5d19639580e..7cc1cd63c1d5 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java @@ -33,6 +33,7 @@ import android.util.ArraySet; import android.util.IntProperty; import android.util.Property; import android.util.TypedValue; +import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; @@ -291,6 +292,20 @@ public class Utilities { } /** + * @return The next frame name for the specified surface. + */ + public static long getNextFrameNumber(Surface s) { + return s.getNextFrameNumber(); + } + + /** + * @return The surface for the specified view. + */ + public static Surface getSurface(View v) { + return v.getViewRootImpl().mSurface; + } + + /** * Returns a lightweight dump of a rect. */ public static String dumpRect(Rect r) { diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityCompat.java new file mode 100644 index 000000000000..0d8ce58d55fd --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityCompat.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +import android.app.Activity; + +public class ActivityCompat { + private final Activity mWrapped; + + public ActivityCompat(Activity activity) { + mWrapped = activity; + } + + /** + * @see Activity#registerRemoteAnimations + */ + public void registerRemoteAnimations(RemoteAnimationDefinitionCompat definition) { + mWrapped.registerRemoteAnimations(definition.getWrapped()); + } +} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java index 705a21522b0a..712cca67c5d6 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java @@ -38,4 +38,9 @@ public abstract class ActivityOptionsCompat { : SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT); return options; } + + public static ActivityOptions makeRemoteAnimation( + RemoteAnimationAdapterCompat remoteAnimationAdapter) { + return ActivityOptions.makeRemoteAnimation(remoteAnimationAdapter.getWrapped()); + } } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java new file mode 100644 index 000000000000..625b1de74290 --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +import android.os.RemoteException; +import android.util.Log; +import android.view.IRemoteAnimationFinishedCallback; +import android.view.IRemoteAnimationRunner; +import android.view.RemoteAnimationAdapter; +import android.view.RemoteAnimationTarget; + +/** + * @see RemoteAnimationAdapter + */ +public class RemoteAnimationAdapterCompat { + + private final RemoteAnimationAdapter mWrapped; + + public RemoteAnimationAdapterCompat(RemoteAnimationRunnerCompat runner, long duration, + long statusBarTransitionDelay) { + mWrapped = new RemoteAnimationAdapter(wrapRemoteAnimationRunner(runner), duration, + statusBarTransitionDelay); + } + + RemoteAnimationAdapter getWrapped() { + return mWrapped; + } + + private static IRemoteAnimationRunner.Stub wrapRemoteAnimationRunner( + RemoteAnimationRunnerCompat remoteAnimationAdapter) { + return new IRemoteAnimationRunner.Stub() { + @Override + public void onAnimationStart(RemoteAnimationTarget[] apps, + IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException { + final RemoteAnimationTargetCompat[] appsCompat = + RemoteAnimationTargetCompat.wrap(apps); + final Runnable animationFinishedCallback = new Runnable() { + @Override + public void run() { + try { + finishedCallback.onAnimationFinished(); + } catch (RemoteException e) { + Log.e("ActivityOptionsCompat", "Failed to call app controlled animation" + + " finished callback", e); + } + } + }; + remoteAnimationAdapter.onAnimationStart(appsCompat, animationFinishedCallback); + } + + @Override + public void onAnimationCancelled() throws RemoteException { + remoteAnimationAdapter.onAnimationCancelled(); + } + }; + } +} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationDefinitionCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationDefinitionCompat.java new file mode 100644 index 000000000000..5fff5febec85 --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationDefinitionCompat.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +import android.view.RemoteAnimationDefinition; + +/** + * @see RemoteAnimationDefinition + */ +public class RemoteAnimationDefinitionCompat { + + private final RemoteAnimationDefinition mWrapped = new RemoteAnimationDefinition(); + + public void addRemoteAnimation(int transition, RemoteAnimationAdapterCompat adapter) { + mWrapped.addRemoteAnimation(transition, adapter.getWrapped()); + } + + RemoteAnimationDefinition getWrapped() { + return mWrapped; + } +} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java new file mode 100644 index 000000000000..5a85df967197 --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +public interface RemoteAnimationRunnerCompat { + void onAnimationStart(RemoteAnimationTargetCompat[] apps, Runnable finishedCallback); + void onAnimationCancelled(); +}
\ No newline at end of file diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java new file mode 100644 index 000000000000..3871980a5b17 --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +import android.graphics.Point; +import android.graphics.Rect; +import android.view.RemoteAnimationTarget; + +/** + * @see RemoteAnimationTarget + */ +public class RemoteAnimationTargetCompat { + + public static final int MODE_OPENING = RemoteAnimationTarget.MODE_OPENING; + public static final int MODE_CLOSING = RemoteAnimationTarget.MODE_CLOSING; + + public final int taskId; + public final int mode; + public final SurfaceControlCompat leash; + public final boolean isTranslucent; + public final Rect clipRect; + public final int prefixOrderIndex; + public final Point position; + public final Rect sourceContainerBounds; + + public RemoteAnimationTargetCompat(RemoteAnimationTarget app) { + taskId = app.taskId; + mode = app.mode; + leash = new SurfaceControlCompat(app.leash); + isTranslucent = app.isTranslucent; + clipRect = app.clipRect; + position = app.position; + sourceContainerBounds = app.sourceContainerBounds; + prefixOrderIndex = app.prefixOrderIndex; + } + + public static RemoteAnimationTargetCompat[] wrap(RemoteAnimationTarget[] apps) { + final RemoteAnimationTargetCompat[] appsCompat = + new RemoteAnimationTargetCompat[apps.length]; + for (int i = 0; i < apps.length; i++) { + appsCompat[i] = new RemoteAnimationTargetCompat(apps[i]); + } + return appsCompat; + } +}
\ No newline at end of file diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceControlCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceControlCompat.java new file mode 100644 index 000000000000..cd12141c3268 --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceControlCompat.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +import android.view.SurfaceControl; + +public class SurfaceControlCompat { + SurfaceControl mSurfaceControl; + + public SurfaceControlCompat(SurfaceControl surfaceControl) { + mSurfaceControl = surfaceControl; + } +} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TransactionCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TransactionCompat.java new file mode 100644 index 000000000000..c82c5191b127 --- /dev/null +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TransactionCompat.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.shared.system; + +import android.graphics.Matrix; +import android.graphics.Rect; +import android.os.IBinder; +import android.view.Surface; +import android.view.SurfaceControl; +import android.view.SurfaceControl.Transaction; + +public class TransactionCompat { + + private final Transaction mTransaction; + + private final float[] mTmpValues = new float[9]; + + public TransactionCompat() { + mTransaction = new Transaction(); + } + + public void apply() { + mTransaction.apply(); + } + + public TransactionCompat show(SurfaceControlCompat surfaceControl) { + mTransaction.show(surfaceControl.mSurfaceControl); + return this; + } + + public TransactionCompat hide(SurfaceControlCompat surfaceControl) { + mTransaction.hide(surfaceControl.mSurfaceControl); + return this; + } + + public TransactionCompat setPosition(SurfaceControlCompat surfaceControl, float x, float y) { + mTransaction.setPosition(surfaceControl.mSurfaceControl, x, y); + return this; + } + + public TransactionCompat setSize(SurfaceControlCompat surfaceControl, int w, int h) { + mTransaction.setSize(surfaceControl.mSurfaceControl, w, h); + return this; + } + + public TransactionCompat setLayer(SurfaceControlCompat surfaceControl, int z) { + mTransaction.setLayer(surfaceControl.mSurfaceControl, z); + return this; + } + + public TransactionCompat setAlpha(SurfaceControlCompat surfaceControl, float alpha) { + mTransaction.setAlpha(surfaceControl.mSurfaceControl, alpha); + return this; + } + + public TransactionCompat setMatrix(SurfaceControlCompat surfaceControl, float dsdx, float dtdx, + float dtdy, float dsdy) { + mTransaction.setMatrix(surfaceControl.mSurfaceControl, dsdx, dtdx, dtdy, dsdy); + return this; + } + + public TransactionCompat setMatrix(SurfaceControlCompat surfaceControl, Matrix matrix) { + mTransaction.setMatrix(surfaceControl.mSurfaceControl, matrix, mTmpValues); + return this; + } + + public TransactionCompat setWindowCrop(SurfaceControlCompat surfaceControl, Rect crop) { + mTransaction.setWindowCrop(surfaceControl.mSurfaceControl, crop); + return this; + } + + public TransactionCompat setFinalCrop(SurfaceControlCompat surfaceControl, Rect crop) { + mTransaction.setFinalCrop(surfaceControl.mSurfaceControl, crop); + return this; + } + + public TransactionCompat deferTransactionUntil(SurfaceControlCompat surfaceControl, + IBinder handle, long frameNumber) { + mTransaction.deferTransactionUntil(surfaceControl.mSurfaceControl, handle, frameNumber); + return this; + } + + public TransactionCompat deferTransactionUntil(SurfaceControlCompat surfaceControl, + Surface barrier, long frameNumber) { + mTransaction.deferTransactionUntilSurface(surfaceControl.mSurfaceControl, barrier, + frameNumber); + return this; + } + + public TransactionCompat setColor(SurfaceControlCompat surfaceControl, float[] color) { + mTransaction.setColor(surfaceControl.mSurfaceControl, color); + return this; + } +}
\ No newline at end of file diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java index 225dbb4aafbe..68400fc977df 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java @@ -20,9 +20,10 @@ import static android.view.Display.DEFAULT_DISPLAY; import android.graphics.Rect; import android.os.Handler; -import android.os.IRemoteCallback; import android.os.RemoteException; import android.util.Log; +import android.view.RemoteAnimationAdapter; +import android.view.WindowManager; import android.view.WindowManagerGlobal; import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecsFuture; @@ -32,6 +33,31 @@ public class WindowManagerWrapper { private static final String TAG = "WindowManagerWrapper"; + public static final int TRANSIT_UNSET = WindowManager.TRANSIT_UNSET; + public static final int TRANSIT_NONE = WindowManager.TRANSIT_NONE; + public static final int TRANSIT_ACTIVITY_OPEN = WindowManager.TRANSIT_ACTIVITY_OPEN; + public static final int TRANSIT_ACTIVITY_CLOSE = WindowManager.TRANSIT_ACTIVITY_CLOSE; + public static final int TRANSIT_TASK_OPEN = WindowManager.TRANSIT_TASK_OPEN; + public static final int TRANSIT_TASK_CLOSE = WindowManager.TRANSIT_TASK_CLOSE; + public static final int TRANSIT_TASK_TO_FRONT = WindowManager.TRANSIT_TASK_TO_FRONT; + public static final int TRANSIT_TASK_TO_BACK = WindowManager.TRANSIT_TASK_TO_BACK; + public static final int TRANSIT_WALLPAPER_CLOSE = WindowManager.TRANSIT_WALLPAPER_CLOSE; + public static final int TRANSIT_WALLPAPER_OPEN = WindowManager.TRANSIT_WALLPAPER_OPEN; + public static final int TRANSIT_WALLPAPER_INTRA_OPEN = + WindowManager.TRANSIT_WALLPAPER_INTRA_OPEN; + public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = + WindowManager.TRANSIT_WALLPAPER_INTRA_CLOSE; + public static final int TRANSIT_TASK_OPEN_BEHIND = WindowManager.TRANSIT_TASK_OPEN_BEHIND; + public static final int TRANSIT_TASK_IN_PLACE = WindowManager.TRANSIT_TASK_IN_PLACE; + public static final int TRANSIT_ACTIVITY_RELAUNCH = WindowManager.TRANSIT_ACTIVITY_RELAUNCH; + public static final int TRANSIT_DOCK_TASK_FROM_RECENTS = + WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS; + public static final int TRANSIT_KEYGUARD_GOING_AWAY = WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; + public static final int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = + WindowManager.TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER; + public static final int TRANSIT_KEYGUARD_OCCLUDE = WindowManager.TRANSIT_KEYGUARD_OCCLUDE; + public static final int TRANSIT_KEYGUARD_UNOCCLUDE = WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; + private static final WindowManagerWrapper sInstance = new WindowManagerWrapper(); public static WindowManagerWrapper getInstance() { @@ -65,4 +91,14 @@ public class WindowManagerWrapper { Log.w(TAG, "Failed to override pending app transition (multi-thumbnail future): ", e); } } + + public void overridePendingAppTransitionRemote( + RemoteAnimationAdapterCompat remoteAnimationAdapter) { + try { + WindowManagerGlobal.getWindowManagerService().overridePendingAppTransitionRemote( + remoteAnimationAdapter.getWrapped()); + } catch (RemoteException e) { + Log.w(TAG, "Failed to override pending app transition (remote): ", e); + } + } } |