KeyguardServiceWrapper.java revision 4cfdcf5b0551e5656ea379c428e78b812c2e5cbe
1/*
2 * Copyright (C) 2013 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.server.policy.keyguard;
18
19import android.content.Context;
20import android.os.Bundle;
21import android.os.IBinder;
22import android.os.RemoteException;
23import android.util.Slog;
24
25import com.android.internal.policy.IKeyguardDrawnCallback;
26import com.android.internal.policy.IKeyguardExitCallback;
27import com.android.internal.policy.IKeyguardService;
28import com.android.internal.policy.IKeyguardStateCallback;
29
30/**
31 * A wrapper class for KeyguardService.  It implements IKeyguardService to ensure the interface
32 * remains consistent.
33 *
34 */
35public class KeyguardServiceWrapper implements IKeyguardService {
36    private KeyguardStateMonitor mKeyguardStateMonitor;
37    private IKeyguardService mService;
38    private String TAG = "KeyguardServiceWrapper";
39
40    public KeyguardServiceWrapper(Context context, IKeyguardService service) {
41        mService = service;
42        mKeyguardStateMonitor = new KeyguardStateMonitor(context, service);
43    }
44
45    @Override // Binder interface
46    public void verifyUnlock(IKeyguardExitCallback callback) {
47        try {
48            mService.verifyUnlock(callback);
49        } catch (RemoteException e) {
50            Slog.w(TAG , "Remote Exception", e);
51        }
52    }
53
54    @Override // Binder interface
55    public void keyguardDone(boolean authenticated, boolean wakeup) {
56        try {
57            mService.keyguardDone(authenticated, wakeup);
58        } catch (RemoteException e) {
59            Slog.w(TAG , "Remote Exception", e);
60        }
61    }
62
63    @Override // Binder interface
64    public void setOccluded(boolean isOccluded) {
65        try {
66            mService.setOccluded(isOccluded);
67        } catch (RemoteException e) {
68            Slog.w(TAG , "Remote Exception", e);
69        }
70    }
71
72    @Override
73    public void addStateMonitorCallback(IKeyguardStateCallback callback) {
74        try {
75            mService.addStateMonitorCallback(callback);
76        } catch (RemoteException e) {
77            Slog.w(TAG , "Remote Exception", e);
78        }
79    }
80
81    @Override // Binder interface
82    public void dismiss() {
83        try {
84            mService.dismiss();
85        } catch (RemoteException e) {
86            Slog.w(TAG , "Remote Exception", e);
87        }
88    }
89
90    @Override // Binder interface
91    public void onDreamingStarted() {
92        try {
93            mService.onDreamingStarted();
94        } catch (RemoteException e) {
95            Slog.w(TAG , "Remote Exception", e);
96        }
97    }
98
99    @Override // Binder interface
100    public void onDreamingStopped() {
101        try {
102            mService.onDreamingStopped();
103        } catch (RemoteException e) {
104            Slog.w(TAG , "Remote Exception", e);
105        }
106    }
107
108    @Override
109    public void onStartedGoingToSleep(int reason) {
110        try {
111            mService.onStartedGoingToSleep(reason);
112        } catch (RemoteException e) {
113            Slog.w(TAG , "Remote Exception", e);
114        }
115    }
116
117    @Override
118    public void onFinishedGoingToSleep(int reason) {
119        try {
120            mService.onFinishedGoingToSleep(reason);
121        } catch (RemoteException e) {
122            Slog.w(TAG , "Remote Exception", e);
123        }
124    }
125
126    @Override
127    public void onStartedWakingUp() {
128        try {
129            mService.onStartedWakingUp();
130        } catch (RemoteException e) {
131            Slog.w(TAG , "Remote Exception", e);
132        }
133    }
134
135    @Override
136    public void onScreenTurningOn(IKeyguardDrawnCallback callback) {
137        try {
138            mService.onScreenTurningOn(callback);
139        } catch (RemoteException e) {
140            Slog.w(TAG , "Remote Exception", e);
141        }
142    }
143
144    @Override // Binder interface
145    public void setKeyguardEnabled(boolean enabled) {
146        try {
147            mService.setKeyguardEnabled(enabled);
148        } catch (RemoteException e) {
149            Slog.w(TAG , "Remote Exception", e);
150        }
151    }
152
153    @Override // Binder interface
154    public void onSystemReady() {
155        try {
156            mService.onSystemReady();
157        } catch (RemoteException e) {
158            Slog.w(TAG , "Remote Exception", e);
159        }
160    }
161
162    @Override // Binder interface
163    public void doKeyguardTimeout(Bundle options) {
164        try {
165            mService.doKeyguardTimeout(options);
166        } catch (RemoteException e) {
167            Slog.w(TAG , "Remote Exception", e);
168        }
169    }
170
171    @Override // Binder interface
172    public void setCurrentUser(int userId) {
173        mKeyguardStateMonitor.setCurrentUser(userId);
174        try {
175            mService.setCurrentUser(userId);
176        } catch (RemoteException e) {
177            Slog.w(TAG , "Remote Exception", e);
178        }
179    }
180
181    @Override // Binder interface
182    public void onBootCompleted() {
183        try {
184            mService.onBootCompleted();
185        } catch (RemoteException e) {
186            Slog.w(TAG , "Remote Exception", e);
187        }
188    }
189
190    @Override // Binder interface
191    public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
192        try {
193            mService.startKeyguardExitAnimation(startTime, fadeoutDuration);
194        } catch (RemoteException e) {
195            Slog.w(TAG , "Remote Exception", e);
196        }
197    }
198
199    @Override // Binder interface
200    public void onActivityDrawn() {
201        try {
202            mService.onActivityDrawn();
203        } catch (RemoteException e) {
204            Slog.w(TAG , "Remote Exception", e);
205        }
206    }
207
208    @Override // Binder interface
209    public IBinder asBinder() {
210        return mService.asBinder();
211    }
212
213    public boolean isShowing() {
214        return mKeyguardStateMonitor.isShowing();
215    }
216
217    public boolean isSecure() {
218        return mKeyguardStateMonitor.isSecure();
219    }
220
221    public boolean isInputRestricted() {
222        return mKeyguardStateMonitor.isInputRestricted();
223    }
224}