From 4ba9fc6168f42f02cd46e710ab5a78b1bba76882 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Fri, 3 Sep 2021 04:24:34 +0800 Subject: [PATCH] Prevent adding methods in WindowInsetsAnimationController It is a public interface which should not have different versions sharing the same API level. This CL moves the methods to an @hide interface. Fix: 198614722 Test: atest android.signature.cts.api.current.SignatureTest Change-Id: Ib02708aeb1ec960bda20b6b60d4df6f0c9b4d9d6 --- .../view/InsetsAnimationControlCallbacks.java | 2 +- .../view/InsetsAnimationControlImpl.java | 2 +- .../InsetsAnimationThreadControlRunner.java | 2 +- core/java/android/view/InsetsController.java | 4 +- .../view/InsetsResizeAnimationRunner.java | 2 +- .../InternalInsetsAnimationController.java | 41 +++++++++++++++++++ .../view/WindowInsetsAnimationController.java | 16 -------- .../com/android/server/wm/InsetsPolicy.java | 3 +- 8 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 core/java/android/view/InternalInsetsAnimationController.java diff --git a/core/java/android/view/InsetsAnimationControlCallbacks.java b/core/java/android/view/InsetsAnimationControlCallbacks.java index 7696bbbb2d5a7..04bb6091672b3 100644 --- a/core/java/android/view/InsetsAnimationControlCallbacks.java +++ b/core/java/android/view/InsetsAnimationControlCallbacks.java @@ -35,7 +35,7 @@ public interface InsetsAnimationControlCallbacks { *
  • Dispatch {@link WindowInsetsAnimationControlListener#onReady}
  • * */ - + void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds); diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java index b92d24f134aa4..7d8d653f5ab3b 100644 --- a/core/java/android/view/InsetsAnimationControlImpl.java +++ b/core/java/android/view/InsetsAnimationControlImpl.java @@ -69,7 +69,7 @@ import java.util.Objects; * @hide */ @VisibleForTesting -public class InsetsAnimationControlImpl implements WindowInsetsAnimationController, +public class InsetsAnimationControlImpl implements InternalInsetsAnimationController, InsetsAnimationControlRunner { private static final String TAG = "InsetsAnimationCtrlImpl"; diff --git a/core/java/android/view/InsetsAnimationThreadControlRunner.java b/core/java/android/view/InsetsAnimationThreadControlRunner.java index c11bde89d966b..fc97541bd34d4 100644 --- a/core/java/android/view/InsetsAnimationThreadControlRunner.java +++ b/core/java/android/view/InsetsAnimationThreadControlRunner.java @@ -54,7 +54,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread - public + public void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds) { // Animation will be started in constructor already. diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index c0a1419872d3d..adda721e00a4f 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -632,7 +632,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation runningAnimations.add(runner.getAnimation()); } - if (((WindowInsetsAnimationController) runner).applyChangeInsets(state)) { + if (((InternalInsetsAnimationController) runner).applyChangeInsets(state)) { finishedAnimations.add(runner.getAnimation()); } } @@ -1513,7 +1513,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting @Override - public + public void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds) { mHost.dispatchWindowInsetsAnimationPrepare(animation); diff --git a/core/java/android/view/InsetsResizeAnimationRunner.java b/core/java/android/view/InsetsResizeAnimationRunner.java index 83f51aa92d98e..e1352dd8dd4f7 100644 --- a/core/java/android/view/InsetsResizeAnimationRunner.java +++ b/core/java/android/view/InsetsResizeAnimationRunner.java @@ -43,7 +43,7 @@ import android.view.animation.Interpolator; * @hide */ public class InsetsResizeAnimationRunner implements InsetsAnimationControlRunner, - WindowInsetsAnimationController, WindowInsetsAnimationControlListener { + InternalInsetsAnimationController, WindowInsetsAnimationControlListener { private final InsetsState mFromState; private final InsetsState mToState; diff --git a/core/java/android/view/InternalInsetsAnimationController.java b/core/java/android/view/InternalInsetsAnimationController.java new file mode 100644 index 0000000000000..d7f3e20b80c54 --- /dev/null +++ b/core/java/android/view/InternalInsetsAnimationController.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2021 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 android.view; + +/** + * An internal interface which provides methods that will be only used by the framework. + * @hide + */ +public interface InternalInsetsAnimationController extends WindowInsetsAnimationController { + + /** + * Flags whether {@link WindowInsetsAnimationControlListener#onReady( + * WindowInsetsAnimationController, int)} has been invoked. + * @hide + */ + void setReadyDispatched(boolean dispatched); + + /** + * Returns the {@link InsetsState} based on the current animation progress. + * + * @param outState the insets state which matches the current animation progress. + * @return {@code true} if the animation has been finished; {@code false} otherwise. + * @hide + */ + boolean applyChangeInsets(InsetsState outState); +} + diff --git a/core/java/android/view/WindowInsetsAnimationController.java b/core/java/android/view/WindowInsetsAnimationController.java index bdfeb748fb992..6578e9b6c20ca 100644 --- a/core/java/android/view/WindowInsetsAnimationController.java +++ b/core/java/android/view/WindowInsetsAnimationController.java @@ -188,20 +188,4 @@ public interface WindowInsetsAnimationController { * fullscreen or non-overlapping). */ boolean hasZeroInsetsIme(); - - /** - * Flags whether {@link WindowInsetsAnimationControlListener#onReady( - * WindowInsetsAnimationController, int)} has been invoked. - * @hide - */ - void setReadyDispatched(boolean dispatched); - - /** - * Returns the {@link InsetsState} based on the current animation progress. - * - * @param outState the insets state which matches the current animation progress. - * @return {@code true} if the animation has been finished; {@code false} otherwise. - * @hide - */ - boolean applyChangeInsets(InsetsState outState); } diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index e932fc32c861d..b7d69a3eaa4a6 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -43,6 +43,7 @@ import android.view.InsetsSource; import android.view.InsetsSourceControl; import android.view.InsetsState; import android.view.InsetsState.InternalInsetsType; +import android.view.InternalInsetsAnimationController; import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; import android.view.WindowInsetsAnimation; @@ -571,7 +572,7 @@ class InsetsPolicy { } @Override - public + public void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds) {