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 static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE; 20 21 import android.annotation.NonNull; 22 import android.os.Handler; 23 import android.os.IBinder; 24 import android.view.InsetsController; 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<Integer> mRequestedVisibleTypesCallback; 47 private final InputMethodManager mInputMethodManager; 48 DisplaySystemBarsInsetsControllerHost(Handler handler, Consumer<Integer> requestedVisibleTypesCallback, InputMethodManager inputMethodManager)49 public DisplaySystemBarsInsetsControllerHost(Handler handler, 50 Consumer<Integer> requestedVisibleTypesCallback, 51 InputMethodManager inputMethodManager) { 52 mHandler = handler; 53 mRequestedVisibleTypesCallback = requestedVisibleTypesCallback; 54 mInputMethodManager = inputMethodManager; 55 } 56 57 @Override getHandler()58 public Handler getHandler() { 59 return mHandler; 60 } 61 62 @Override notifyInsetsChanged()63 public void notifyInsetsChanged() { 64 // no-op 65 } 66 67 @Override dispatchWindowInsetsAnimationPrepare(@onNull WindowInsetsAnimation animation)68 public void dispatchWindowInsetsAnimationPrepare(@NonNull WindowInsetsAnimation animation) { 69 // no-op 70 } 71 72 @Override dispatchWindowInsetsAnimationStart( @onNull WindowInsetsAnimation animation, @NonNull WindowInsetsAnimation.Bounds bounds)73 public WindowInsetsAnimation.Bounds dispatchWindowInsetsAnimationStart( 74 @NonNull WindowInsetsAnimation animation, 75 @NonNull WindowInsetsAnimation.Bounds bounds) { 76 return null; 77 } 78 79 @Override dispatchWindowInsetsAnimationProgress(@onNull WindowInsets insets, @NonNull List<WindowInsetsAnimation> runningAnimations)80 public WindowInsets dispatchWindowInsetsAnimationProgress(@NonNull WindowInsets insets, 81 @NonNull List<WindowInsetsAnimation> runningAnimations) { 82 return null; 83 } 84 85 @Override dispatchWindowInsetsAnimationEnd(@onNull WindowInsetsAnimation animation)86 public void dispatchWindowInsetsAnimationEnd(@NonNull WindowInsetsAnimation animation) { 87 // no-op 88 } 89 90 @Override applySurfaceParams(final SyncRtSurfaceTransactionApplier.SurfaceParams... params)91 public void applySurfaceParams(final SyncRtSurfaceTransactionApplier.SurfaceParams... params) { 92 for (int i = params.length - 1; i >= 0; i--) { 93 SyncRtSurfaceTransactionApplier.applyParams( 94 new SurfaceControl.Transaction(), params[i], mTmpFloat9); 95 } 96 97 } 98 99 @Override updateRequestedVisibleTypes(@indowInsets.Type.InsetsType int types)100 public void updateRequestedVisibleTypes(@WindowInsets.Type.InsetsType int types) { 101 mRequestedVisibleTypesCallback.accept(types); 102 } 103 104 @Override hasAnimationCallbacks()105 public boolean hasAnimationCallbacks() { 106 return false; 107 } 108 109 @Override setSystemBarsAppearance( @indowInsetsController.Appearance int appearance, @WindowInsetsController.Appearance int mask)110 public void setSystemBarsAppearance( 111 @WindowInsetsController.Appearance int appearance, 112 @WindowInsetsController.Appearance int mask) { 113 // no-op 114 } 115 116 @Override getSystemBarsAppearance()117 public @WindowInsetsController.Appearance int getSystemBarsAppearance() { 118 return 0; 119 } 120 121 @Override setSystemBarsBehavior(@indowInsetsController.Behavior int behavior)122 public void setSystemBarsBehavior(@WindowInsetsController.Behavior int behavior) { 123 // no-op 124 } 125 126 @Override getSystemBarsBehavior()127 public @WindowInsetsController.Behavior int getSystemBarsBehavior() { 128 return BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE; 129 } 130 131 @Override releaseSurfaceControlFromRt(SurfaceControl surfaceControl)132 public void releaseSurfaceControlFromRt(SurfaceControl surfaceControl) { 133 surfaceControl.release(); 134 } 135 136 @Override addOnPreDrawRunnable(Runnable r)137 public void addOnPreDrawRunnable(Runnable r) { 138 mHandler.post(r); 139 } 140 141 @Override postInsetsAnimationCallback(Runnable r)142 public void postInsetsAnimationCallback(Runnable r) { 143 mHandler.post(r); 144 } 145 146 @Override getInputMethodManager()147 public InputMethodManager getInputMethodManager() { 148 return mInputMethodManager; 149 } 150 151 @Override getRootViewTitle()152 public String getRootViewTitle() { 153 return null; 154 } 155 156 @Override dipToPx(int dips)157 public int dipToPx(int dips) { 158 return 0; 159 } 160 161 @Override getWindowToken()162 public IBinder getWindowToken() { 163 return null; 164 } 165 } 166