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