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