1 package com.android.internal.view; 2 3 import android.graphics.Rect; 4 import android.os.Bundle; 5 import android.os.ParcelFileDescriptor; 6 import android.os.RemoteException; 7 import android.view.IWindow; 8 import android.view.IWindowSession; 9 import android.view.KeyEvent; 10 import android.view.MotionEvent; 11 12 public class BaseIWindow extends IWindow.Stub { 13 private IWindowSession mSession; 14 setSession(IWindowSession session)15 public void setSession(IWindowSession session) { 16 mSession = session; 17 } 18 resized(int w, int h, Rect coveredInsets, Rect visibleInsets, boolean reportDraw)19 public void resized(int w, int h, Rect coveredInsets, 20 Rect visibleInsets, boolean reportDraw) { 21 if (reportDraw) { 22 try { 23 mSession.finishDrawing(this); 24 } catch (RemoteException e) { 25 } 26 } 27 } 28 dispatchKey(KeyEvent event)29 public void dispatchKey(KeyEvent event) { 30 try { 31 mSession.finishKey(this); 32 } catch (RemoteException ex) { 33 } 34 } 35 onDispatchPointer(MotionEvent event, long eventTime, boolean callWhenDone)36 public boolean onDispatchPointer(MotionEvent event, long eventTime, 37 boolean callWhenDone) { 38 event.recycle(); 39 return false; 40 } 41 dispatchPointer(MotionEvent event, long eventTime, boolean callWhenDone)42 public void dispatchPointer(MotionEvent event, long eventTime, 43 boolean callWhenDone) { 44 try { 45 if (event == null) { 46 event = mSession.getPendingPointerMove(this); 47 onDispatchPointer(event, eventTime, false); 48 } else if (callWhenDone) { 49 if (!onDispatchPointer(event, eventTime, true)) { 50 mSession.finishKey(this); 51 } 52 } else { 53 onDispatchPointer(event, eventTime, false); 54 } 55 } catch (RemoteException ex) { 56 } 57 } 58 onDispatchTrackball(MotionEvent event, long eventTime, boolean callWhenDone)59 public boolean onDispatchTrackball(MotionEvent event, long eventTime, 60 boolean callWhenDone) { 61 event.recycle(); 62 return false; 63 } 64 dispatchTrackball(MotionEvent event, long eventTime, boolean callWhenDone)65 public void dispatchTrackball(MotionEvent event, long eventTime, 66 boolean callWhenDone) { 67 try { 68 if (event == null) { 69 event = mSession.getPendingTrackballMove(this); 70 onDispatchTrackball(event, eventTime, false); 71 } else if (callWhenDone) { 72 if (!onDispatchTrackball(event, eventTime, true)) { 73 mSession.finishKey(this); 74 } 75 } else { 76 onDispatchTrackball(event, eventTime, false); 77 } 78 } catch (RemoteException ex) { 79 } 80 } 81 dispatchAppVisibility(boolean visible)82 public void dispatchAppVisibility(boolean visible) { 83 } 84 dispatchGetNewSurface()85 public void dispatchGetNewSurface() { 86 } 87 windowFocusChanged(boolean hasFocus, boolean touchEnabled)88 public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) { 89 } 90 executeCommand(String command, String parameters, ParcelFileDescriptor out)91 public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { 92 } 93 closeSystemDialogs(String reason)94 public void closeSystemDialogs(String reason) { 95 } 96 dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync)97 public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync) { 98 if (sync) { 99 try { 100 mSession.wallpaperOffsetsComplete(asBinder()); 101 } catch (RemoteException e) { 102 } 103 } 104 } 105 dispatchWallpaperCommand(String action, int x, int y, int z, Bundle extras, boolean sync)106 public void dispatchWallpaperCommand(String action, int x, int y, 107 int z, Bundle extras, boolean sync) { 108 if (sync) { 109 try { 110 mSession.wallpaperCommandComplete(asBinder(), null); 111 } catch (RemoteException e) { 112 } 113 } 114 } 115 } 116