BaseIWindow.java revision 7580493b014a2c7ea883cd291255798dc72ebbff
1package com.android.internal.view;
2
3import android.graphics.Rect;
4import android.os.Bundle;
5import android.os.ParcelFileDescriptor;
6import android.os.RemoteException;
7import android.view.IWindow;
8import android.view.IWindowSession;
9import android.view.KeyEvent;
10import android.view.MotionEvent;
11
12public class BaseIWindow extends IWindow.Stub {
13    private IWindowSession mSession;
14
15    public void setSession(IWindowSession session) {
16        mSession = session;
17    }
18
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
29    public void dispatchKey(KeyEvent event) {
30        try {
31            mSession.finishKey(this);
32        } catch (RemoteException ex) {
33        }
34    }
35
36    public boolean onDispatchPointer(MotionEvent event, long eventTime,
37            boolean callWhenDone) {
38        event.recycle();
39        return false;
40    }
41
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
59    public boolean onDispatchTrackball(MotionEvent event, long eventTime,
60            boolean callWhenDone) {
61        event.recycle();
62        return false;
63    }
64
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
82    public void dispatchAppVisibility(boolean visible) {
83    }
84
85    public void dispatchGetNewSurface() {
86    }
87
88    public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) {
89    }
90
91    public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {
92    }
93
94    public void closeSystemDialogs(String reason) {
95    }
96
97    public void dispatchWallpaperOffsets(float x, float y, boolean sync) {
98        if (sync) {
99            try {
100                mSession.wallpaperOffsetsComplete(asBinder());
101            } catch (RemoteException e) {
102            }
103        }
104    }
105
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