summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Josh Tsuji <tsuji@google.com> 2022-03-30 21:01:59 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-03-30 21:01:59 +0000
commit4ef511ba815fc7c189d29a45b65a6dc7a6618148 (patch)
tree874e4c825054cc963f407ffdb5218d6435619e94
parent93cbb241b0b16f193806254167e6a7203e68a7d3 (diff)
parentf1234b41eebbae69affbc3b1359fa295b47c6688 (diff)
Merge changes from topics "presubmit-am-21467bac639546abb87776fa53a3459a", "presubmit-am-91ee056e41174db39dd02eabfb9e3eac" into tm-dev
* changes: Re-enable remote occlude/unocclude animations. Add unocclude animation.
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java115
2 files changed, 82 insertions, 35 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index 88555edd1e8b..b96eee717260 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -102,7 +102,7 @@ public class KeyguardService extends Service {
"persist.wm.enable_remote_keyguard_animation";
private static final int sEnableRemoteKeyguardAnimation =
- SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 1);
+ SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 2);
/**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 0486fee4239d..890ddf0d6cac 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -47,6 +47,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
+import android.graphics.Matrix;
import android.hardware.biometrics.BiometricSourceType;
import android.media.AudioAttributes;
import android.media.AudioManager;
@@ -236,6 +237,14 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
*/
private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000;
+ private static final int UNOCCLUDE_ANIMATION_DURATION = 250;
+
+ /**
+ * How far down to animate the unoccluding activity, in terms of percent of the activity's
+ * height.
+ */
+ private static final float UNOCCLUDE_TRANSLATE_DISTANCE_PERCENT = 0.1f;
+
/**
* Boolean option for doKeyguardLocked/doKeyguardTimeout which, when set to true, forces the
* keyguard to show even if it is disabled for the current user.
@@ -883,53 +892,91 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
}
};
+ private IRemoteAnimationRunner mOccludeAnimationRunner =
+ new ActivityLaunchRemoteAnimationRunner(mOccludeAnimationController);
+
/**
- * Animation controller for activities that unocclude the keyguard. This will play the launch
- * animation in reverse.
+ * Animation controller for activities that unocclude the keyguard. This does not use the
+ * ActivityLaunchAnimator since we're just translating down, rather than emerging from a view
+ * or the power button.
*/
- private final ActivityLaunchAnimator.Controller mUnoccludeAnimationController =
- new ActivityLaunchAnimator.Controller() {
- @Override
- public void onLaunchAnimationEnd(boolean isExpandingFullyAbove) {
- setOccluded(false /* isOccluded */, false /* animate */);
- }
+ private final IRemoteAnimationRunner mUnoccludeAnimationRunner =
+ new IRemoteAnimationRunner.Stub() {
- @Override
- public void onLaunchAnimationCancelled() {
- setOccluded(false /* isOccluded */, false /* animate */);
- }
+ @Nullable private ValueAnimator mUnoccludeAnimator;
+ private final Matrix mUnoccludeMatrix = new Matrix();
- @NonNull
@Override
- public ViewGroup getLaunchContainer() {
- return ((ViewGroup) mKeyguardViewControllerLazy.get()
- .getViewRootImpl().getView());
+ public void onAnimationCancelled() {
+ if (mUnoccludeAnimator != null) {
+ mUnoccludeAnimator.cancel();
+ }
}
@Override
- public void setLaunchContainer(@NonNull ViewGroup launchContainer) {
- // No-op, launch container is always the shade.
- Log.wtf(TAG, "Someone tried to change the launch container for the "
- + "ActivityLaunchAnimator, which should never happen.");
- }
+ public void onAnimationStart(int transit, RemoteAnimationTarget[] apps,
+ RemoteAnimationTarget[] wallpapers,
+ RemoteAnimationTarget[] nonApps,
+ IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException {
+ final RemoteAnimationTarget primary = apps[0];
- @NonNull
- @Override
- public LaunchAnimator.State createAnimatorState() {
- final int width = getLaunchContainer().getWidth();
- final int height = getLaunchContainer().getHeight();
+ if (primary == null) {
+ finishedCallback.onAnimationFinished();
+ return;
+ }
- // TODO(b/207399883): Unocclude animation. This currently ends instantly.
- return new LaunchAnimator.State(
- 0, height, 0, width, mWindowCornerRadius, mWindowCornerRadius);
+ final SyncRtSurfaceTransactionApplier applier =
+ new SyncRtSurfaceTransactionApplier(
+ mKeyguardViewControllerLazy.get().getViewRootImpl().getView());
+
+
+ mContext.getMainExecutor().execute(() -> {
+ if (mUnoccludeAnimator != null) {
+ mUnoccludeAnimator.cancel();
+ }
+
+ mUnoccludeAnimator = ValueAnimator.ofFloat(1f, 0f);
+ mUnoccludeAnimator.setDuration(UNOCCLUDE_ANIMATION_DURATION);
+ mUnoccludeAnimator.setInterpolator(Interpolators.TOUCH_RESPONSE);
+ mUnoccludeAnimator.addUpdateListener(
+ animation -> {
+ final float animatedValue =
+ (float) animation.getAnimatedValue();
+
+ final float surfaceHeight = primary.screenSpaceBounds.height();
+
+ mUnoccludeMatrix.setTranslate(
+ 0f,
+ (1f - animatedValue)
+ * surfaceHeight
+ * UNOCCLUDE_TRANSLATE_DISTANCE_PERCENT);
+
+ SyncRtSurfaceTransactionApplier.SurfaceParams params =
+ new SyncRtSurfaceTransactionApplier.SurfaceParams
+ .Builder(primary.leash)
+ .withMatrix(mUnoccludeMatrix)
+ .withCornerRadius(mWindowCornerRadius)
+ .withAlpha(animatedValue)
+ .build();
+ applier.scheduleApply(params);
+ });
+ mUnoccludeAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ try {
+ finishedCallback.onAnimationFinished();
+ mUnoccludeAnimator = null;
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ mUnoccludeAnimator.start();
+ });
}
};
- private IRemoteAnimationRunner mOccludeAnimationRunner =
- new ActivityLaunchRemoteAnimationRunner(mOccludeAnimationController);
- private IRemoteAnimationRunner mUnoccludeAnimationRunner =
- new ActivityLaunchRemoteAnimationRunner(mUnoccludeAnimationController);
-
private DeviceConfigProxy mDeviceConfig;
private DozeParameters mDozeParameters;