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