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
17package com.android.internal.view;
18
19import android.graphics.Rect;
20import android.hardware.input.InputManager;
21import android.os.Bundle;
22import android.os.ParcelFileDescriptor;
23import android.os.RemoteException;
24import android.util.MergedConfiguration;
25import android.view.DragEvent;
26import android.view.IWindow;
27import android.view.IWindowSession;
28import android.view.PointerIcon;
29
30import com.android.internal.os.IResultReceiver;
31
32public class BaseIWindow extends IWindow.Stub {
33    private IWindowSession mSession;
34    public int mSeq;
35
36    public void setSession(IWindowSession session) {
37        mSession = session;
38    }
39
40    @Override
41    public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets,
42            Rect stableInsets, Rect outsets, boolean reportDraw,
43            MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout,
44            boolean alwaysConsumeNavBar, int displayId) {
45        if (reportDraw) {
46            try {
47                mSession.finishDrawing(this);
48            } catch (RemoteException e) {
49            }
50        }
51    }
52
53    @Override
54    public void moved(int newX, int newY) {
55    }
56
57    @Override
58    public void dispatchAppVisibility(boolean visible) {
59    }
60
61    @Override
62    public void dispatchGetNewSurface() {
63    }
64
65    @Override
66    public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) {
67    }
68
69    @Override
70    public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {
71    }
72
73    @Override
74    public void closeSystemDialogs(String reason) {
75    }
76
77    @Override
78    public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync) {
79        if (sync) {
80            try {
81                mSession.wallpaperOffsetsComplete(asBinder());
82            } catch (RemoteException e) {
83            }
84        }
85    }
86
87    @Override
88    public void dispatchDragEvent(DragEvent event) {
89        if (event.getAction() == DragEvent.ACTION_DROP) {
90            try {
91                mSession.reportDropResult(this, false);
92            } catch (RemoteException e) {
93            }
94        }
95    }
96
97    @Override
98    public void updatePointerIcon(float x, float y) {
99        InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED);
100    }
101
102    @Override
103    public void dispatchSystemUiVisibilityChanged(int seq, int globalUi,
104            int localValue, int localChanges) {
105        mSeq = seq;
106    }
107
108    @Override
109    public void dispatchWallpaperCommand(String action, int x, int y,
110            int z, Bundle extras, boolean sync) {
111        if (sync) {
112            try {
113                mSession.wallpaperCommandComplete(asBinder(), null);
114            } catch (RemoteException e) {
115            }
116        }
117    }
118
119    @Override
120    public void dispatchWindowShown() {
121    }
122
123    @Override
124    public void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId) {
125    }
126
127    @Override
128    public void dispatchPointerCaptureChanged(boolean hasCapture) {
129    }
130}
131