WindowManagerWrapper.java revision 66b48dfb9e051026bb696f5b43f9b06e0905b92c
1/* 2 * Copyright (C) 2017 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 17package com.android.systemui.shared.system; 18 19import static android.view.Display.DEFAULT_DISPLAY; 20 21import android.app.WindowConfiguration; 22import android.graphics.Rect; 23import android.os.Handler; 24import android.os.RemoteException; 25import android.util.Log; 26import android.view.WindowManager; 27import android.view.WindowManagerGlobal; 28 29import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecsFuture; 30import com.android.systemui.shared.recents.view.RecentsTransition; 31 32public class WindowManagerWrapper { 33 34 private static final String TAG = "WindowManagerWrapper"; 35 36 public static final int TRANSIT_UNSET = WindowManager.TRANSIT_UNSET; 37 public static final int TRANSIT_NONE = WindowManager.TRANSIT_NONE; 38 public static final int TRANSIT_ACTIVITY_OPEN = WindowManager.TRANSIT_ACTIVITY_OPEN; 39 public static final int TRANSIT_ACTIVITY_CLOSE = WindowManager.TRANSIT_ACTIVITY_CLOSE; 40 public static final int TRANSIT_TASK_OPEN = WindowManager.TRANSIT_TASK_OPEN; 41 public static final int TRANSIT_TASK_CLOSE = WindowManager.TRANSIT_TASK_CLOSE; 42 public static final int TRANSIT_TASK_TO_FRONT = WindowManager.TRANSIT_TASK_TO_FRONT; 43 public static final int TRANSIT_TASK_TO_BACK = WindowManager.TRANSIT_TASK_TO_BACK; 44 public static final int TRANSIT_WALLPAPER_CLOSE = WindowManager.TRANSIT_WALLPAPER_CLOSE; 45 public static final int TRANSIT_WALLPAPER_OPEN = WindowManager.TRANSIT_WALLPAPER_OPEN; 46 public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 47 WindowManager.TRANSIT_WALLPAPER_INTRA_OPEN; 48 public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 49 WindowManager.TRANSIT_WALLPAPER_INTRA_CLOSE; 50 public static final int TRANSIT_TASK_OPEN_BEHIND = WindowManager.TRANSIT_TASK_OPEN_BEHIND; 51 public static final int TRANSIT_TASK_IN_PLACE = WindowManager.TRANSIT_TASK_IN_PLACE; 52 public static final int TRANSIT_ACTIVITY_RELAUNCH = WindowManager.TRANSIT_ACTIVITY_RELAUNCH; 53 public static final int TRANSIT_DOCK_TASK_FROM_RECENTS = 54 WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS; 55 public static final int TRANSIT_KEYGUARD_GOING_AWAY = WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; 56 public static final int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 57 WindowManager.TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER; 58 public static final int TRANSIT_KEYGUARD_OCCLUDE = WindowManager.TRANSIT_KEYGUARD_OCCLUDE; 59 public static final int TRANSIT_KEYGUARD_UNOCCLUDE = WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; 60 61 public static final int ACTIVITY_TYPE_STANDARD = WindowConfiguration.ACTIVITY_TYPE_STANDARD; 62 63 private static final WindowManagerWrapper sInstance = new WindowManagerWrapper(); 64 65 public static WindowManagerWrapper getInstance() { 66 return sInstance; 67 } 68 69 /** 70 * @return the stable insets for the primary display. 71 */ 72 public void getStableInsets(Rect outStableInsets) { 73 try { 74 WindowManagerGlobal.getWindowManagerService().getStableInsets(DEFAULT_DISPLAY, 75 outStableInsets); 76 } catch (RemoteException e) { 77 Log.e(TAG, "Failed to get stable insets", e); 78 } 79 } 80 81 /** 82 * Overrides a pending app transition. 83 */ 84 public void overridePendingAppTransitionMultiThumbFuture( 85 AppTransitionAnimationSpecsFuture animationSpecFuture, 86 Runnable animStartedCallback, Handler animStartedCallbackHandler, boolean scaleUp) { 87 try { 88 WindowManagerGlobal.getWindowManagerService() 89 .overridePendingAppTransitionMultiThumbFuture(animationSpecFuture.getFuture(), 90 RecentsTransition.wrapStartedListener(animStartedCallbackHandler, 91 animStartedCallback), scaleUp); 92 } catch (RemoteException e) { 93 Log.w(TAG, "Failed to override pending app transition (multi-thumbnail future): ", e); 94 } 95 } 96 97 public void overridePendingAppTransitionRemote( 98 RemoteAnimationAdapterCompat remoteAnimationAdapter) { 99 try { 100 WindowManagerGlobal.getWindowManagerService().overridePendingAppTransitionRemote( 101 remoteAnimationAdapter.getWrapped()); 102 } catch (RemoteException e) { 103 Log.w(TAG, "Failed to override pending app transition (remote): ", e); 104 } 105 } 106 107 /** 108 * Enable or disable haptic feedback on the navigation bar buttons. 109 */ 110 public void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled) { 111 try { 112 WindowManagerGlobal.getWindowManagerService() 113 .setNavBarVirtualKeyHapticFeedbackEnabled(enabled); 114 } catch (RemoteException e) { 115 Log.w(TAG, "Failed to enable or disable navigation bar button haptics: ", e); 116 } 117 } 118 119 public void setShelfHeight(boolean visible, int shelfHeight) { 120 try { 121 WindowManagerGlobal.getWindowManagerService().setShelfHeight(visible, shelfHeight); 122 } catch (RemoteException e) { 123 Log.w(TAG, "Failed to set shelf height"); 124 } 125 } 126} 127