Merge "Wrapping remote app animations"

This commit is contained in:
Jorim Jaggi
2018-01-18 00:19:02 +00:00
committed by Android (Google) Code Review
10 changed files with 413 additions and 1 deletions

View File

@@ -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;
@@ -290,6 +291,20 @@ public class Utilities {
return context.getApplicationContext().getResources().getConfiguration();
}
/**
* @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.
*/

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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();
}
};
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}