1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view;
18 
19 import android.annotation.Nullable;
20 import android.util.SparseArray;
21 import android.util.proto.ProtoOutputStream;
22 import android.view.InsetsController.AnimationType;
23 import android.view.WindowInsets.Type.InsetsType;
24 import android.view.inputmethod.ImeTracker;
25 
26 /**
27  * Interface representing a runner for an insets animation.
28  *
29  * @hide
30  */
31 public interface InsetsAnimationControlRunner {
32 
33     /**
34      * @return The {@link InsetsType} the animation of this runner controls.
35      */
getTypes()36     @InsetsType int getTypes();
37 
38     /**
39      * @return The {@link InsetsType} the animation of this runner is controlling. This can be
40      *         changed if a control is revoked.
41      */
getControllingTypes()42     @InsetsType int getControllingTypes();
43 
44     /**
45      * Notifies {@link InsetsType types} of control are getting revoked.
46      */
notifyControlRevoked(@nsetsType int types)47     void notifyControlRevoked(@InsetsType int types);
48 
49     /**
50      * Updates the surface positions of the controls owned by this runner if there is any.
51      *
52      * @param controls An array of {@link InsetsSourceControl} that the caller newly receives.
53      */
updateSurfacePosition(SparseArray<InsetsSourceControl> controls)54     void updateSurfacePosition(SparseArray<InsetsSourceControl> controls);
55 
56     /**
57      * Cancels the animation.
58      */
cancel()59     void cancel();
60 
61     /**
62      * @return The animation this runner is running.
63      */
getAnimation()64     WindowInsetsAnimation getAnimation();
65 
66     /**
67      * @return Whether {@link #getTypes()} contains a specific {@link InsetsType}.
68      */
controlsType(@nsetsType int type)69     default boolean controlsType(@InsetsType int type) {
70         return (getTypes() & type) != 0;
71     }
72 
73     /**
74      * @return The animation type this runner is running.
75      */
getAnimationType()76     @AnimationType int getAnimationType();
77 
78     /**
79      * @return The token tracking the current IME request or {@code null} otherwise.
80      */
81     @Nullable
getStatsToken()82     ImeTracker.Token getStatsToken();
83 
84     /**
85      *
86      * Export the state of classes that implement this interface into a protocol buffer
87      * output stream.
88      *
89      * @param proto Stream to write the state to
90      * @param fieldId FieldId of the implementation class
91      */
dumpDebug(ProtoOutputStream proto, long fieldId)92     void dumpDebug(ProtoOutputStream proto, long fieldId);
93 }
94