1 /*
2  * Copyright (C) 2016 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.server.wm;
18 
19 import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
20 
21 import android.annotation.Nullable;
22 import android.content.Context;
23 import android.content.res.Configuration;
24 import android.os.Bundle;
25 import android.os.IBinder;
26 import android.os.PowerManager.GoToSleepReason;
27 import android.os.PowerManager.WakeReason;
28 import android.util.proto.ProtoOutputStream;
29 import android.view.KeyEvent;
30 import android.view.WindowManager;
31 import android.view.animation.Animation;
32 
33 import com.android.internal.policy.IKeyguardDismissCallback;
34 import com.android.internal.policy.IShortcutService;
35 import com.android.server.policy.WindowManagerPolicy;
36 
37 import java.io.PrintWriter;
38 
39 class TestWindowManagerPolicy implements WindowManagerPolicy {
40 
41     boolean mKeyguardShowingAndNotOccluded = false;
42     boolean mOkToAnimate = true;
43     boolean mIsUserSetupComplete = false;
44 
TestWindowManagerPolicy()45     TestWindowManagerPolicy() {
46     }
47 
48     @Override
registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)49     public void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver) {
50     }
51 
52     @Override
init(Context context, WindowManagerFuncs windowManagerFuncs)53     public void init(Context context, WindowManagerFuncs windowManagerFuncs) {
54     }
55 
setDefaultDisplay(DisplayContentInfo displayContentInfo)56     public void setDefaultDisplay(DisplayContentInfo displayContentInfo) {
57     }
58 
59     @Override
checkAddPermission(int type, boolean isRoundedCornerOverlay, String packageName, int[] outAppOp)60     public int checkAddPermission(int type, boolean isRoundedCornerOverlay, String packageName,
61             int[] outAppOp) {
62         return 0;
63     }
64 
65     @Override
adjustConfigurationLw(Configuration config, int keyboardPresence, int navigationPresence)66     public void adjustConfigurationLw(Configuration config, int keyboardPresence,
67             int navigationPresence) {
68     }
69 
70     @Override
isKeyguardHostWindow(WindowManager.LayoutParams attrs)71     public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) {
72         return attrs.type == TYPE_NOTIFICATION_SHADE;
73     }
74 
75     @Override
createHiddenByKeyguardExit(boolean onWallpaper, boolean goingToNotificationShade, boolean subtleAnimation)76     public Animation createHiddenByKeyguardExit(boolean onWallpaper,
77             boolean goingToNotificationShade, boolean subtleAnimation) {
78         return null;
79     }
80 
81     @Override
createKeyguardWallpaperExit(boolean goingToNotificationShade)82     public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade) {
83         return null;
84     }
85 
86     @Override
interceptKeyBeforeQueueing(KeyEvent event, int policyFlags)87     public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
88         return 0;
89     }
90 
91     @Override
interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos, int policyFlags)92     public int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
93             int policyFlags) {
94         return 0;
95     }
96 
97     @Override
interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event, int policyFlags)98     public long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event,
99             int policyFlags) {
100         return 0;
101     }
102 
103     @Override
dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags)104     public KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags) {
105         return null;
106     }
107 
108     @Override
setTopFocusedDisplay(int displayId)109     public void setTopFocusedDisplay(int displayId) {
110     }
111 
112     @Override
setAllowLockscreenWhenOn(int displayId, boolean allow)113     public void setAllowLockscreenWhenOn(int displayId, boolean allow) {
114     }
115 
116     @Override
startedWakingUpGlobal(@akeReason int reason)117     public void startedWakingUpGlobal(@WakeReason int reason) {
118     }
119 
120     @Override
finishedWakingUpGlobal(@akeReason int reason)121     public void finishedWakingUpGlobal(@WakeReason int reason) {
122     }
123 
124     @Override
startedGoingToSleepGlobal(@oToSleepReason int reason)125     public void startedGoingToSleepGlobal(@GoToSleepReason int reason) {
126     }
127 
128     @Override
finishedGoingToSleepGlobal(@oToSleepReason int reason)129     public void finishedGoingToSleepGlobal(@GoToSleepReason int reason) {
130     }
131 
132     @Override
startedWakingUp(int displayGroupId, @WakeReason int wakeReason)133     public void startedWakingUp(int displayGroupId, @WakeReason int wakeReason) {
134     }
135 
136     @Override
finishedWakingUp(int displayGroupId, @WakeReason int wakeReason)137     public void finishedWakingUp(int displayGroupId, @WakeReason int wakeReason) {
138     }
139 
140     @Override
startedGoingToSleep(int displayGroupId, @GoToSleepReason int sleepReason)141     public void startedGoingToSleep(int displayGroupId, @GoToSleepReason int sleepReason) {
142     }
143 
144     @Override
finishedGoingToSleep(int displayGroupId, @GoToSleepReason int sleepReason)145     public void finishedGoingToSleep(int displayGroupId, @GoToSleepReason int sleepReason) {
146     }
147 
148     @Override
screenTurningOn(int displayId, ScreenOnListener screenOnListener)149     public void screenTurningOn(int displayId, ScreenOnListener screenOnListener) {
150     }
151 
152     @Override
screenTurnedOn(int displayId)153     public void screenTurnedOn(int displayId) {
154     }
155 
156     @Override
screenTurningOff(int displayId, ScreenOffListener screenOffListener)157     public void screenTurningOff(int displayId, ScreenOffListener screenOffListener) {
158     }
159 
160     @Override
screenTurnedOff(int displayId, boolean isSwappingDisplay)161     public void screenTurnedOff(int displayId, boolean isSwappingDisplay) {
162     }
163 
164     @Override
isScreenOn()165     public boolean isScreenOn() {
166         return true;
167     }
168 
169     @Override
okToAnimate(boolean ignoreScreenOn)170     public boolean okToAnimate(boolean ignoreScreenOn) {
171         return mOkToAnimate;
172     }
173 
174     @Override
notifyLidSwitchChanged(long whenNanos, boolean lidOpen)175     public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
176     }
177 
178     @Override
notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered)179     public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) {
180     }
181 
182     @Override
enableKeyguard(boolean enabled)183     public void enableKeyguard(boolean enabled) {
184     }
185 
186     @Override
exitKeyguardSecurely(OnKeyguardExitResult callback)187     public void exitKeyguardSecurely(OnKeyguardExitResult callback) {
188     }
189 
190     @Override
isKeyguardLocked()191     public boolean isKeyguardLocked() {
192         return mKeyguardShowingAndNotOccluded;
193     }
194 
195     @Override
isKeyguardSecure(int userId)196     public boolean isKeyguardSecure(int userId) {
197         return false;
198     }
199 
200     @Override
isKeyguardOccluded()201     public boolean isKeyguardOccluded() {
202         return false;
203     }
204 
205     @Override
isKeyguardTrustedLw()206     public boolean isKeyguardTrustedLw() {
207         return false;
208     }
209 
210     @Override
isKeyguardShowing()211     public boolean isKeyguardShowing() {
212         return mKeyguardShowingAndNotOccluded;
213     }
214 
215     @Override
isKeyguardShowingAndNotOccluded()216     public boolean isKeyguardShowingAndNotOccluded() {
217         return mKeyguardShowingAndNotOccluded;
218     }
219 
220     @Override
inKeyguardRestrictedKeyInputMode()221     public boolean inKeyguardRestrictedKeyInputMode() {
222         return false;
223     }
224 
225     @Override
dismissKeyguardLw(@ullable IKeyguardDismissCallback callback, CharSequence message)226     public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback,
227             CharSequence message) {
228     }
229 
230     @Override
isKeyguardDrawnLw()231     public boolean isKeyguardDrawnLw() {
232         return false;
233     }
234 
235     @Override
onKeyguardOccludedChangedLw(boolean occluded)236     public void onKeyguardOccludedChangedLw(boolean occluded) {
237     }
238 
setSafeMode(boolean safeMode)239     public void setSafeMode(boolean safeMode) {
240     }
241 
242     @Override
systemReady()243     public void systemReady() {
244     }
245 
246     @Override
systemBooted()247     public void systemBooted() {
248     }
249 
250     @Override
showBootMessage(CharSequence msg, boolean always)251     public void showBootMessage(CharSequence msg, boolean always) {
252     }
253 
254     @Override
hideBootMessages()255     public void hideBootMessages() {
256     }
257 
258     @Override
userActivity(int displayGroupId, int event)259     public void userActivity(int displayGroupId, int event) {
260     }
261 
262     @Override
enableScreenAfterBoot()263     public void enableScreenAfterBoot() {
264     }
265 
266     @Override
performHapticFeedback(int uid, String packageName, int effectId, boolean always, String reason)267     public boolean performHapticFeedback(int uid, String packageName, int effectId,
268             boolean always, String reason) {
269         return false;
270     }
271 
272     @Override
keepScreenOnStartedLw()273     public void keepScreenOnStartedLw() {
274     }
275 
276     @Override
keepScreenOnStoppedLw()277     public void keepScreenOnStoppedLw() {
278     }
279 
280     @Override
hasNavigationBar()281     public boolean hasNavigationBar() {
282         return false;
283     }
284 
285     @Override
lockNow(Bundle options)286     public void lockNow(Bundle options) {
287     }
288 
289     @Override
showRecentApps()290     public void showRecentApps() {
291     }
292 
293     @Override
showGlobalActions()294     public void showGlobalActions() {
295     }
296 
297     @Override
isUserSetupComplete()298     public boolean isUserSetupComplete() {
299         return mIsUserSetupComplete;
300     }
301 
302     @Override
getUiMode()303     public int getUiMode() {
304         return 0;
305     }
306 
307     @Override
setCurrentUserLw(int newUserId)308     public void setCurrentUserLw(int newUserId) {
309     }
310 
311     @Override
setSwitchingUser(boolean switching)312     public void setSwitchingUser(boolean switching) {
313     }
314 
315     @Override
dumpDebug(ProtoOutputStream proto, long fieldId)316     public void dumpDebug(ProtoOutputStream proto, long fieldId) {
317     }
318 
319     @Override
dump(String prefix, PrintWriter writer, String[] args)320     public void dump(String prefix, PrintWriter writer, String[] args) {
321     }
322 
323     @Override
startKeyguardExitAnimation(long startTime)324     public void startKeyguardExitAnimation(long startTime) {
325     }
326 
327     @Override
applyKeyguardOcclusionChange()328     public int applyKeyguardOcclusionChange() {
329         return 0;
330     }
331 
332     @Override
setPipVisibilityLw(boolean visible)333     public void setPipVisibilityLw(boolean visible) {
334     }
335 
336     @Override
setRecentsVisibilityLw(boolean visible)337     public void setRecentsVisibilityLw(boolean visible) {
338     }
339 
340     @Override
setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled)341     public void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled) {
342     }
343 
344     @Override
onSystemUiStarted()345     public void onSystemUiStarted() {
346     }
347 
348     @Override
canDismissBootAnimation()349     public boolean canDismissBootAnimation() {
350         return true;
351     }
352 
353     @Override
isGlobalKey(int keyCode)354     public boolean isGlobalKey(int keyCode) {
355         return false;
356     }
357 }
358