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.internal.policy.impl.keyguard;
18
19import android.os.Bundle;
20import android.os.IBinder;
21import android.os.RemoteException;
22import android.util.Slog;
23import android.view.MotionEvent;
24
25import com.android.internal.policy.IKeyguardServiceConstants;
26import com.android.internal.policy.IKeyguardShowCallback;
27import com.android.internal.policy.IKeyguardExitCallback;
28import com.android.internal.policy.IKeyguardService;
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 IKeyguardService mService;
37    private String TAG = "KeyguardServiceWrapper";
38
39    public KeyguardServiceWrapper(IKeyguardService service) {
40        mService = service;
41    }
42
43    public boolean isShowing() {
44        try {
45            return mService.isShowing();
46        } catch (RemoteException e) {
47            Slog.w(TAG , "Remote Exception", e);
48        }
49        return false;
50    }
51
52    public boolean isSecure() {
53        try {
54            return mService.isSecure();
55        } catch (RemoteException e) {
56            Slog.w(TAG , "Remote Exception", e);
57        }
58        return false; // TODO cache state
59    }
60
61    public boolean isShowingAndNotOccluded() {
62        try {
63            return mService.isShowingAndNotOccluded();
64        } catch (RemoteException e) {
65            Slog.w(TAG , "Remote Exception", e);
66        }
67        return false; // TODO cache state
68    }
69
70    public boolean isInputRestricted() {
71        try {
72            return mService.isInputRestricted();
73        } catch (RemoteException e) {
74            Slog.w(TAG , "Remote Exception", e);
75        }
76        return false; // TODO cache state
77    }
78
79    public boolean isDismissable() {
80        try {
81            return mService.isDismissable();
82        } catch (RemoteException e) {
83            Slog.w(TAG , "Remote Exception", e);
84        }
85        return true; // TODO cache state
86    }
87
88    public void verifyUnlock(IKeyguardExitCallback callback) {
89        try {
90            mService.verifyUnlock(callback);
91        } catch (RemoteException e) {
92            Slog.w(TAG , "Remote Exception", e);
93        }
94    }
95
96    public void keyguardDone(boolean authenticated, boolean wakeup) {
97        try {
98            mService.keyguardDone(authenticated, wakeup);
99        } catch (RemoteException e) {
100            Slog.w(TAG , "Remote Exception", e);
101        }
102    }
103
104    public int setOccluded(boolean isOccluded) {
105        try {
106            return mService.setOccluded(isOccluded);
107        } catch (RemoteException e) {
108            Slog.w(TAG , "Remote Exception", e);
109            return IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_NONE;
110        }
111    }
112
113    public void dismiss() {
114        try {
115            mService.dismiss();
116        } catch (RemoteException e) {
117            Slog.w(TAG , "Remote Exception", e);
118        }
119    }
120
121    public void onDreamingStarted() {
122        try {
123            mService.onDreamingStarted();
124        } catch (RemoteException e) {
125            Slog.w(TAG , "Remote Exception", e);
126        }
127    }
128
129    public void onDreamingStopped() {
130        try {
131            mService.onDreamingStopped();
132        } catch (RemoteException e) {
133            Slog.w(TAG , "Remote Exception", e);
134        }
135    }
136
137    public void onScreenTurnedOff(int reason) {
138        try {
139            mService.onScreenTurnedOff(reason);
140        } catch (RemoteException e) {
141            Slog.w(TAG , "Remote Exception", e);
142        }
143    }
144
145    public void onScreenTurnedOn(IKeyguardShowCallback result) {
146        try {
147            mService.onScreenTurnedOn(result);
148        } catch (RemoteException e) {
149            Slog.w(TAG , "Remote Exception", e);
150        }
151    }
152
153    public void setKeyguardEnabled(boolean enabled) {
154        try {
155            mService.setKeyguardEnabled(enabled);
156        } catch (RemoteException e) {
157            Slog.w(TAG , "Remote Exception", e);
158        }
159    }
160
161    public void onSystemReady() {
162        try {
163            mService.onSystemReady();
164        } catch (RemoteException e) {
165            Slog.w(TAG , "Remote Exception", e);
166        }
167    }
168
169    public void doKeyguardTimeout(Bundle options) {
170        try {
171            mService.doKeyguardTimeout(options);
172        } catch (RemoteException e) {
173            Slog.w(TAG , "Remote Exception", e);
174        }
175    }
176
177    public void setCurrentUser(int userId) {
178        try {
179            mService.setCurrentUser(userId);
180        } catch (RemoteException e) {
181            Slog.w(TAG , "Remote Exception", e);
182        }
183    }
184
185    public void onBootCompleted() {
186        try {
187            mService.onBootCompleted();
188        } catch (RemoteException e) {
189            Slog.w(TAG , "Remote Exception", e);
190        }
191    }
192
193    public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
194        try {
195            mService.startKeyguardExitAnimation(startTime, fadeoutDuration);
196        } catch (RemoteException e) {
197            Slog.w(TAG , "Remote Exception", e);
198        }
199    }
200
201    public void onActivityDrawn() {
202        try {
203            mService.onActivityDrawn();
204        } catch (RemoteException e) {
205            Slog.w(TAG , "Remote Exception", e);
206        }
207    }
208
209    public void showAssistant() {
210        // Not used by PhoneWindowManager
211    }
212
213    public void dispatch(MotionEvent event) {
214        // Not used by PhoneWindowManager.  See code in {@link NavigationBarView}
215    }
216
217    public void launchCamera() {
218        // Not used by PhoneWindowManager.  See code in {@link NavigationBarView}
219    }
220
221    @Override
222    public IBinder asBinder() {
223        return mService.asBinder();
224    }
225
226}