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