2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.server.policy.keyguard;
19 import android.content.Context;
20 import android.os.Bundle;
21 import android.os.IBinder;
22 import android.os.RemoteException;
23 import android.util.Slog;
25 import com.android.internal.policy.IKeyguardDrawnCallback;
26 import com.android.internal.policy.IKeyguardExitCallback;
27 import com.android.internal.policy.IKeyguardService;
28 import com.android.internal.policy.IKeyguardStateCallback;
30 import java.io.PrintWriter;
33 * A wrapper class for KeyguardService. It implements IKeyguardService to ensure the interface
37 public class KeyguardServiceWrapper implements IKeyguardService {
38 private KeyguardStateMonitor mKeyguardStateMonitor;
39 private IKeyguardService mService;
40 private String TAG = "KeyguardServiceWrapper";
42 public KeyguardServiceWrapper(Context context, IKeyguardService service) {
44 mKeyguardStateMonitor = new KeyguardStateMonitor(context, service);
47 @Override // Binder interface
48 public void verifyUnlock(IKeyguardExitCallback callback) {
50 mService.verifyUnlock(callback);
51 } catch (RemoteException e) {
52 Slog.w(TAG , "Remote Exception", e);
56 @Override // Binder interface
57 public void keyguardDone(boolean authenticated, boolean wakeup) {
59 mService.keyguardDone(authenticated, wakeup);
60 } catch (RemoteException e) {
61 Slog.w(TAG , "Remote Exception", e);
65 @Override // Binder interface
66 public void setOccluded(boolean isOccluded) {
68 mService.setOccluded(isOccluded);
69 } catch (RemoteException e) {
70 Slog.w(TAG , "Remote Exception", e);
75 public void addStateMonitorCallback(IKeyguardStateCallback callback) {
77 mService.addStateMonitorCallback(callback);
78 } catch (RemoteException e) {
79 Slog.w(TAG , "Remote Exception", e);
83 @Override // Binder interface
84 public void dismiss(boolean allowWhileOccluded) {
86 mService.dismiss(allowWhileOccluded);
87 } catch (RemoteException e) {
88 Slog.w(TAG , "Remote Exception", e);
92 @Override // Binder interface
93 public void onDreamingStarted() {
95 mService.onDreamingStarted();
96 } catch (RemoteException e) {
97 Slog.w(TAG , "Remote Exception", e);
101 @Override // Binder interface
102 public void onDreamingStopped() {
104 mService.onDreamingStopped();
105 } catch (RemoteException e) {
106 Slog.w(TAG , "Remote Exception", e);
111 public void onStartedGoingToSleep(int reason) {
113 mService.onStartedGoingToSleep(reason);
114 } catch (RemoteException e) {
115 Slog.w(TAG , "Remote Exception", e);
120 public void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered) {
122 mService.onFinishedGoingToSleep(reason, cameraGestureTriggered);
123 } catch (RemoteException e) {
124 Slog.w(TAG , "Remote Exception", e);
129 public void onStartedWakingUp() {
131 mService.onStartedWakingUp();
132 } catch (RemoteException e) {
133 Slog.w(TAG , "Remote Exception", e);
138 public void onScreenTurningOn(IKeyguardDrawnCallback callback) {
140 mService.onScreenTurningOn(callback);
141 } catch (RemoteException e) {
142 Slog.w(TAG , "Remote Exception", e);
147 public void onScreenTurnedOn() {
149 mService.onScreenTurnedOn();
150 } catch (RemoteException e) {
151 Slog.w(TAG , "Remote Exception", e);
156 public void onScreenTurnedOff() {
158 mService.onScreenTurnedOff();
159 } catch (RemoteException e) {
160 Slog.w(TAG , "Remote Exception", e);
164 @Override // Binder interface
165 public void setKeyguardEnabled(boolean enabled) {
167 mService.setKeyguardEnabled(enabled);
168 } catch (RemoteException e) {
169 Slog.w(TAG , "Remote Exception", e);
173 @Override // Binder interface
174 public void onSystemReady() {
176 mService.onSystemReady();
177 } catch (RemoteException e) {
178 Slog.w(TAG , "Remote Exception", e);
182 @Override // Binder interface
183 public void doKeyguardTimeout(Bundle options) {
185 mService.doKeyguardTimeout(options);
186 } catch (RemoteException e) {
187 Slog.w(TAG , "Remote Exception", e);
191 @Override // Binder interface
192 public void setCurrentUser(int userId) {
193 mKeyguardStateMonitor.setCurrentUser(userId);
195 mService.setCurrentUser(userId);
196 } catch (RemoteException e) {
197 Slog.w(TAG , "Remote Exception", e);
201 @Override // Binder interface
202 public void onBootCompleted() {
204 mService.onBootCompleted();
205 } catch (RemoteException e) {
206 Slog.w(TAG , "Remote Exception", e);
210 @Override // Binder interface
211 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
213 mService.startKeyguardExitAnimation(startTime, fadeoutDuration);
214 } catch (RemoteException e) {
215 Slog.w(TAG , "Remote Exception", e);
219 @Override // Binder interface
220 public void onActivityDrawn() {
222 mService.onActivityDrawn();
223 } catch (RemoteException e) {
224 Slog.w(TAG , "Remote Exception", e);
228 @Override // Binder interface
229 public IBinder asBinder() {
230 return mService.asBinder();
233 public boolean isShowing() {
234 return mKeyguardStateMonitor.isShowing();
237 public boolean isTrusted() {
238 return mKeyguardStateMonitor.isTrusted();
241 public boolean hasLockscreenWallpaper() {
242 return mKeyguardStateMonitor.hasLockscreenWallpaper();
245 public boolean isSecure(int userId) {
246 return mKeyguardStateMonitor.isSecure(userId);
249 public boolean isInputRestricted() {
250 return mKeyguardStateMonitor.isInputRestricted();
253 public void dump(String prefix, PrintWriter pw) {
254 mKeyguardStateMonitor.dump(prefix, pw);