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 com.android.systemui.wm;
18 
19 import android.annotation.NonNull;
20 import android.os.Handler;
21 import android.os.IBinder;
22 import android.view.InsetsController;
23 import android.view.InsetsState;
24 import android.view.InsetsVisibilities;
25 import android.view.SurfaceControl;
26 import android.view.SyncRtSurfaceTransactionApplier;
27 import android.view.WindowInsets;
28 import android.view.WindowInsetsAnimation;
29 import android.view.WindowInsetsController;
30 import android.view.inputmethod.InputMethodManager;
31 
32 import java.util.List;
33 import java.util.function.Consumer;
34 
35 /**
36  * Implements {@link InsetsController.Host} for usage by
37  * {@link DisplaySystemBarsController.PerDisplay} instances in {@link DisplaySystemBarsController}.
38  * @hide
39  */
40 public class DisplaySystemBarsInsetsControllerHost implements InsetsController.Host {
41 
42     private static final String TAG = DisplaySystemBarsInsetsControllerHost.class.getSimpleName();
43 
44     private final Handler mHandler;
45     private final float[] mTmpFloat9 = new float[9];
46     private final Consumer<InsetsVisibilities> mRequestedVisibilityCallback;
47 
DisplaySystemBarsInsetsControllerHost(Handler handler, Consumer<InsetsVisibilities> requestedVisibilityCallback)48     public DisplaySystemBarsInsetsControllerHost(Handler handler,
49             Consumer<InsetsVisibilities> requestedVisibilityCallback) {
50         mHandler = handler;
51         mRequestedVisibilityCallback = requestedVisibilityCallback;
52     }
53 
54     @Override
getHandler()55     public Handler getHandler() {
56         return mHandler;
57     }
58 
59     @Override
notifyInsetsChanged()60     public void notifyInsetsChanged() {
61         // no-op
62     }
63 
64     @Override
dispatchWindowInsetsAnimationPrepare(@onNull WindowInsetsAnimation animation)65     public void dispatchWindowInsetsAnimationPrepare(@NonNull WindowInsetsAnimation animation) {
66         // no-op
67     }
68 
69     @Override
dispatchWindowInsetsAnimationStart( @onNull WindowInsetsAnimation animation, @NonNull WindowInsetsAnimation.Bounds bounds)70     public WindowInsetsAnimation.Bounds dispatchWindowInsetsAnimationStart(
71             @NonNull WindowInsetsAnimation animation,
72             @NonNull WindowInsetsAnimation.Bounds bounds) {
73         return null;
74     }
75 
76     @Override
dispatchWindowInsetsAnimationProgress(@onNull WindowInsets insets, @NonNull List<WindowInsetsAnimation> runningAnimations)77     public WindowInsets dispatchWindowInsetsAnimationProgress(@NonNull WindowInsets insets,
78             @NonNull List<WindowInsetsAnimation> runningAnimations) {
79         return null;
80     }
81 
82     @Override
dispatchWindowInsetsAnimationEnd(@onNull WindowInsetsAnimation animation)83     public void dispatchWindowInsetsAnimationEnd(@NonNull WindowInsetsAnimation animation) {
84         // no-op
85     }
86 
87     @Override
applySurfaceParams(final SyncRtSurfaceTransactionApplier.SurfaceParams... params)88     public void applySurfaceParams(final SyncRtSurfaceTransactionApplier.SurfaceParams... params) {
89         for (int i = params.length - 1; i >= 0; i--) {
90             SyncRtSurfaceTransactionApplier.applyParams(
91                     new SurfaceControl.Transaction(), params[i], mTmpFloat9);
92         }
93 
94     }
95 
96     @Override
updateCompatSysUiVisibility( @nsetsState.InternalInsetsType int type, boolean visible, boolean hasControl)97     public void updateCompatSysUiVisibility(
98             @InsetsState.InternalInsetsType int type, boolean visible, boolean hasControl) {
99         // no-op
100     }
101 
102     @Override
updateRequestedVisibilities(InsetsVisibilities visibilities)103     public void updateRequestedVisibilities(InsetsVisibilities visibilities) {
104         mRequestedVisibilityCallback.accept(visibilities);
105     }
106 
107     @Override
hasAnimationCallbacks()108     public boolean hasAnimationCallbacks() {
109         return false;
110     }
111 
112     @Override
setSystemBarsAppearance( @indowInsetsController.Appearance int appearance, @WindowInsetsController.Appearance int mask)113     public void setSystemBarsAppearance(
114             @WindowInsetsController.Appearance int appearance,
115             @WindowInsetsController.Appearance int mask) {
116         // no-op
117     }
118 
119     @Override
getSystemBarsAppearance()120     public @WindowInsetsController.Appearance int getSystemBarsAppearance() {
121         return 0;
122     }
123 
124     @Override
setSystemBarsBehavior(@indowInsetsController.Behavior int behavior)125     public void setSystemBarsBehavior(@WindowInsetsController.Behavior int behavior) {
126         // no-op
127     }
128 
129     @Override
getSystemBarsBehavior()130     public @WindowInsetsController.Behavior int getSystemBarsBehavior() {
131         return 0;
132     }
133 
134     @Override
releaseSurfaceControlFromRt(SurfaceControl surfaceControl)135     public void releaseSurfaceControlFromRt(SurfaceControl surfaceControl) {
136         surfaceControl.release();
137     }
138 
139     @Override
addOnPreDrawRunnable(Runnable r)140     public void addOnPreDrawRunnable(Runnable r) {
141         mHandler.post(r);
142     }
143 
144     @Override
postInsetsAnimationCallback(Runnable r)145     public void postInsetsAnimationCallback(Runnable r) {
146         mHandler.post(r);
147     }
148 
149     @Override
getInputMethodManager()150     public InputMethodManager getInputMethodManager() {
151         return null;
152     }
153 
154     @Override
getRootViewTitle()155     public String getRootViewTitle() {
156         return null;
157     }
158 
159     @Override
dipToPx(int dips)160     public int dipToPx(int dips) {
161         return 0;
162     }
163 
164     @Override
getWindowToken()165     public IBinder getWindowToken() {
166         return null;
167     }
168 }
169