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, int source, int action, long whenNanos, int policyFlags)92     public int interceptMotionBeforeQueueingNonInteractive(int displayId, int source, int action,
93             long whenNanos, 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
onDisplaySwitchStart(int displayId)170     public void onDisplaySwitchStart(int displayId) {
171     }
172 
173     @Override
okToAnimate(boolean ignoreScreenOn)174     public boolean okToAnimate(boolean ignoreScreenOn) {
175         return mOkToAnimate;
176     }
177 
178     @Override
notifyLidSwitchChanged(long whenNanos, boolean lidOpen)179     public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
180     }
181 
182     @Override
notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered)183     public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) {
184     }
185 
186     @Override
enableKeyguard(boolean enabled)187     public void enableKeyguard(boolean enabled) {
188     }
189 
190     @Override
exitKeyguardSecurely(OnKeyguardExitResult callback)191     public void exitKeyguardSecurely(OnKeyguardExitResult callback) {
192     }
193 
194     @Override
isKeyguardLocked()195     public boolean isKeyguardLocked() {
196         return mKeyguardShowingAndNotOccluded;
197     }
198 
199     @Override
isKeyguardSecure(int userId)200     public boolean isKeyguardSecure(int userId) {
201         return false;
202     }
203 
204     @Override
isKeyguardOccluded()205     public boolean isKeyguardOccluded() {
206         return false;
207     }
208 
209     @Override
isKeyguardTrustedLw()210     public boolean isKeyguardTrustedLw() {
211         return false;
212     }
213 
214     @Override
isKeyguardShowing()215     public boolean isKeyguardShowing() {
216         return mKeyguardShowingAndNotOccluded;
217     }
218 
219     @Override
isKeyguardShowingAndNotOccluded()220     public boolean isKeyguardShowingAndNotOccluded() {
221         return mKeyguardShowingAndNotOccluded;
222     }
223 
224     @Override
inKeyguardRestrictedKeyInputMode()225     public boolean inKeyguardRestrictedKeyInputMode() {
226         return false;
227     }
228 
229     @Override
dismissKeyguardLw(@ullable IKeyguardDismissCallback callback, CharSequence message)230     public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback,
231             CharSequence message) {
232     }
233 
234     @Override
isKeyguardDrawnLw()235     public boolean isKeyguardDrawnLw() {
236         return false;
237     }
238 
239     @Override
onKeyguardOccludedChangedLw(boolean occluded)240     public void onKeyguardOccludedChangedLw(boolean occluded) {
241     }
242 
setSafeMode(boolean safeMode)243     public void setSafeMode(boolean safeMode) {
244     }
245 
246     @Override
systemReady()247     public void systemReady() {
248     }
249 
250     @Override
systemBooted()251     public void systemBooted() {
252     }
253 
254     @Override
showBootMessage(CharSequence msg, boolean always)255     public void showBootMessage(CharSequence msg, boolean always) {
256     }
257 
258     @Override
hideBootMessages()259     public void hideBootMessages() {
260     }
261 
262     @Override
userActivity(int displayGroupId, int event)263     public void userActivity(int displayGroupId, int event) {
264     }
265 
266     @Override
enableScreenAfterBoot()267     public void enableScreenAfterBoot() {
268     }
269 
270     @Override
performHapticFeedback(int uid, String packageName, int effectId, boolean always, String reason, boolean fromIme)271     public boolean performHapticFeedback(int uid, String packageName, int effectId,
272             boolean always, String reason, boolean fromIme) {
273         return false;
274     }
275 
276     @Override
keepScreenOnStartedLw()277     public void keepScreenOnStartedLw() {
278     }
279 
280     @Override
keepScreenOnStoppedLw()281     public void keepScreenOnStoppedLw() {
282     }
283 
284     @Override
hasNavigationBar()285     public boolean hasNavigationBar() {
286         return false;
287     }
288 
289     @Override
lockNow(Bundle options)290     public void lockNow(Bundle options) {
291     }
292 
293     @Override
showRecentApps()294     public void showRecentApps() {
295     }
296 
297     @Override
showGlobalActions()298     public void showGlobalActions() {
299     }
300 
301     @Override
isUserSetupComplete()302     public boolean isUserSetupComplete() {
303         return mIsUserSetupComplete;
304     }
305 
306     @Override
getUiMode()307     public int getUiMode() {
308         return 0;
309     }
310 
311     @Override
setCurrentUserLw(int newUserId)312     public void setCurrentUserLw(int newUserId) {
313     }
314 
315     @Override
setSwitchingUser(boolean switching)316     public void setSwitchingUser(boolean switching) {
317     }
318 
319     @Override
dumpDebug(ProtoOutputStream proto, long fieldId)320     public void dumpDebug(ProtoOutputStream proto, long fieldId) {
321     }
322 
323     @Override
dump(String prefix, PrintWriter writer, String[] args)324     public void dump(String prefix, PrintWriter writer, String[] args) {
325     }
326 
327     @Override
startKeyguardExitAnimation(long startTime)328     public void startKeyguardExitAnimation(long startTime) {
329     }
330 
331     @Override
applyKeyguardOcclusionChange()332     public int applyKeyguardOcclusionChange() {
333         return 0;
334     }
335 
336     @Override
showDismissibleKeyguard()337     public void showDismissibleKeyguard() {
338     }
339 
340     @Override
setPipVisibilityLw(boolean visible)341     public void setPipVisibilityLw(boolean visible) {
342     }
343 
344     @Override
setRecentsVisibilityLw(boolean visible)345     public void setRecentsVisibilityLw(boolean visible) {
346     }
347 
348     @Override
setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled)349     public void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled) {
350     }
351 
352     @Override
onSystemUiStarted()353     public void onSystemUiStarted() {
354     }
355 
356     @Override
canDismissBootAnimation()357     public boolean canDismissBootAnimation() {
358         return true;
359     }
360 
361     @Override
isGlobalKey(int keyCode)362     public boolean isGlobalKey(int keyCode) {
363         return false;
364     }
365 }
366