1 /* 2 * Copyright (C) 2009 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.internal.view; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.graphics.Point; 21 import android.hardware.input.InputManager; 22 import android.os.Bundle; 23 import android.os.ParcelFileDescriptor; 24 import android.os.RemoteException; 25 import android.util.MergedConfiguration; 26 import android.view.DragEvent; 27 import android.view.IScrollCaptureResponseListener; 28 import android.view.IWindow; 29 import android.view.IWindowSession; 30 import android.view.InsetsSourceControl; 31 import android.view.InsetsState; 32 import android.view.PointerIcon; 33 import android.view.ScrollCaptureResponse; 34 import android.view.WindowInsets.Type.InsetsType; 35 import android.window.ClientWindowFrames; 36 37 import com.android.internal.os.IResultReceiver; 38 39 import java.io.IOException; 40 41 public class BaseIWindow extends IWindow.Stub { 42 43 @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P) BaseIWindow()44 public BaseIWindow() {} 45 46 private IWindowSession mSession; 47 setSession(IWindowSession session)48 public void setSession(IWindowSession session) { 49 mSession = session; 50 } 51 52 @Override resized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId)53 public void resized(ClientWindowFrames frames, boolean reportDraw, 54 MergedConfiguration mergedConfiguration, boolean forceLayout, 55 boolean alwaysConsumeSystemBars, int displayId) { 56 if (reportDraw) { 57 try { 58 mSession.finishDrawing(this, null /* postDrawTransaction */); 59 } catch (RemoteException e) { 60 } 61 } 62 } 63 64 @Override locationInParentDisplayChanged(Point offset)65 public void locationInParentDisplayChanged(Point offset) { 66 } 67 68 @Override insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize)69 public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) { 70 } 71 72 @Override insetsControlChanged(InsetsState insetsState, InsetsSourceControl[] activeControls, boolean willMove, boolean willResize)73 public void insetsControlChanged(InsetsState insetsState, 74 InsetsSourceControl[] activeControls, boolean willMove, boolean willResize) { 75 } 76 77 @Override showInsets(@nsetsType int types, boolean fromIme)78 public void showInsets(@InsetsType int types, boolean fromIme) { 79 } 80 81 @Override hideInsets(@nsetsType int types, boolean fromIme)82 public void hideInsets(@InsetsType int types, boolean fromIme) { 83 } 84 85 @Override moved(int newX, int newY)86 public void moved(int newX, int newY) { 87 } 88 89 @Override dispatchAppVisibility(boolean visible)90 public void dispatchAppVisibility(boolean visible) { 91 } 92 93 @Override dispatchGetNewSurface()94 public void dispatchGetNewSurface() { 95 } 96 97 @Override windowFocusChanged(boolean hasFocus, boolean touchEnabled)98 public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) { 99 } 100 101 @Override executeCommand(String command, String parameters, ParcelFileDescriptor out)102 public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { 103 if (out != null) { 104 try { 105 out.closeWithError("Unsupported command " + command); 106 } catch (IOException e) { 107 // Ignore 108 } 109 } 110 } 111 112 @Override closeSystemDialogs(String reason)113 public void closeSystemDialogs(String reason) { 114 } 115 116 @Override dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, float zoom, boolean sync)117 public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, float zoom, 118 boolean sync) { 119 if (sync) { 120 try { 121 mSession.wallpaperOffsetsComplete(asBinder()); 122 } catch (RemoteException e) { 123 } 124 } 125 } 126 127 @Override dispatchDragEvent(DragEvent event)128 public void dispatchDragEvent(DragEvent event) { 129 if (event.getAction() == DragEvent.ACTION_DROP) { 130 try { 131 mSession.reportDropResult(this, false); 132 } catch (RemoteException e) { 133 } 134 } 135 } 136 137 @Override updatePointerIcon(float x, float y)138 public void updatePointerIcon(float x, float y) { 139 InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED); 140 } 141 142 @Override dispatchWallpaperCommand(String action, int x, int y, int z, Bundle extras, boolean sync)143 public void dispatchWallpaperCommand(String action, int x, int y, 144 int z, Bundle extras, boolean sync) { 145 if (sync) { 146 try { 147 mSession.wallpaperCommandComplete(asBinder(), null); 148 } catch (RemoteException e) { 149 } 150 } 151 } 152 153 @Override dispatchWindowShown()154 public void dispatchWindowShown() { 155 } 156 157 @Override requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId)158 public void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId) { 159 } 160 161 @Override requestScrollCapture(IScrollCaptureResponseListener listener)162 public void requestScrollCapture(IScrollCaptureResponseListener listener) { 163 try { 164 listener.onScrollCaptureResponse( 165 new ScrollCaptureResponse.Builder().setDescription("Not Implemented").build()); 166 167 } catch (RemoteException ex) { 168 // ignore 169 } 170 } 171 } 172