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 17 package com.android.server.policy.keyguard; 18 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; 24 25 import com.android.internal.policy.IKeyguardDismissCallback; 26 import com.android.internal.policy.IKeyguardDrawnCallback; 27 import com.android.internal.policy.IKeyguardExitCallback; 28 import com.android.internal.policy.IKeyguardService; 29 import com.android.internal.policy.IKeyguardStateCallback; 30 31 import java.io.PrintWriter; 32 33 /** 34 * A wrapper class for KeyguardService. It implements IKeyguardService to ensure the interface 35 * remains consistent. 36 * 37 */ 38 public class KeyguardServiceWrapper implements IKeyguardService { 39 private KeyguardStateMonitor mKeyguardStateMonitor; 40 private IKeyguardService mService; 41 private String TAG = "KeyguardServiceWrapper"; 42 43 public KeyguardServiceWrapper(Context context, IKeyguardService service, 44 KeyguardStateMonitor.StateCallback callback) { 45 mService = service; 46 mKeyguardStateMonitor = new KeyguardStateMonitor(context, service, callback); 47 } 48 49 @Override // Binder interface 50 public void verifyUnlock(IKeyguardExitCallback callback) { 51 try { 52 mService.verifyUnlock(callback); 53 } catch (RemoteException e) { 54 Slog.w(TAG , "Remote Exception", e); 55 } 56 } 57 58 @Override // Binder interface 59 public void setOccluded(boolean isOccluded, boolean animate) { 60 try { 61 mService.setOccluded(isOccluded, animate); 62 } catch (RemoteException e) { 63 Slog.w(TAG , "Remote Exception", e); 64 } 65 } 66 67 @Override 68 public void addStateMonitorCallback(IKeyguardStateCallback callback) { 69 try { 70 mService.addStateMonitorCallback(callback); 71 } catch (RemoteException e) { 72 Slog.w(TAG , "Remote Exception", e); 73 } 74 } 75 76 @Override // Binder interface 77 public void dismiss(IKeyguardDismissCallback callback) { 78 try { 79 mService.dismiss(callback); 80 } catch (RemoteException e) { 81 Slog.w(TAG , "Remote Exception", e); 82 } 83 } 84 85 @Override // Binder interface 86 public void onDreamingStarted() { 87 try { 88 mService.onDreamingStarted(); 89 } catch (RemoteException e) { 90 Slog.w(TAG , "Remote Exception", e); 91 } 92 } 93 94 @Override // Binder interface 95 public void onDreamingStopped() { 96 try { 97 mService.onDreamingStopped(); 98 } catch (RemoteException e) { 99 Slog.w(TAG , "Remote Exception", e); 100 } 101 } 102 103 @Override 104 public void onStartedGoingToSleep(int reason) { 105 try { 106 mService.onStartedGoingToSleep(reason); 107 } catch (RemoteException e) { 108 Slog.w(TAG , "Remote Exception", e); 109 } 110 } 111 112 @Override 113 public void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered) { 114 try { 115 mService.onFinishedGoingToSleep(reason, cameraGestureTriggered); 116 } catch (RemoteException e) { 117 Slog.w(TAG , "Remote Exception", e); 118 } 119 } 120 121 @Override 122 public void onStartedWakingUp() { 123 try { 124 mService.onStartedWakingUp(); 125 } catch (RemoteException e) { 126 Slog.w(TAG , "Remote Exception", e); 127 } 128 } 129 130 @Override 131 public void onFinishedWakingUp() { 132 try { 133 mService.onFinishedWakingUp(); 134 } catch (RemoteException e) { 135 Slog.w(TAG , "Remote Exception", e); 136 } 137 } 138 139 @Override 140 public void onScreenTurningOn(IKeyguardDrawnCallback callback) { 141 try { 142 mService.onScreenTurningOn(callback); 143 } catch (RemoteException e) { 144 Slog.w(TAG , "Remote Exception", e); 145 } 146 } 147 148 @Override 149 public void onScreenTurnedOn() { 150 try { 151 mService.onScreenTurnedOn(); 152 } catch (RemoteException e) { 153 Slog.w(TAG , "Remote Exception", e); 154 } 155 } 156 157 @Override 158 public void onScreenTurningOff() { 159 try { 160 mService.onScreenTurningOff(); 161 } catch (RemoteException e) { 162 Slog.w(TAG , "Remote Exception", e); 163 } 164 } 165 166 @Override 167 public void onScreenTurnedOff() { 168 try { 169 mService.onScreenTurnedOff(); 170 } catch (RemoteException e) { 171 Slog.w(TAG , "Remote Exception", e); 172 } 173 } 174 175 @Override // Binder interface 176 public void setKeyguardEnabled(boolean enabled) { 177 try { 178 mService.setKeyguardEnabled(enabled); 179 } catch (RemoteException e) { 180 Slog.w(TAG , "Remote Exception", e); 181 } 182 } 183 184 @Override // Binder interface 185 public void onSystemReady() { 186 try { 187 mService.onSystemReady(); 188 } catch (RemoteException e) { 189 Slog.w(TAG , "Remote Exception", e); 190 } 191 } 192 193 @Override // Binder interface 194 public void doKeyguardTimeout(Bundle options) { 195 try { 196 mService.doKeyguardTimeout(options); 197 } catch (RemoteException e) { 198 Slog.w(TAG , "Remote Exception", e); 199 } 200 } 201 202 @Override // Binder interface 203 public void setSwitchingUser(boolean switching) { 204 try { 205 mService.setSwitchingUser(switching); 206 } catch (RemoteException e) { 207 Slog.w(TAG , "Remote Exception", e); 208 } 209 } 210 211 @Override // Binder interface 212 public void setCurrentUser(int userId) { 213 mKeyguardStateMonitor.setCurrentUser(userId); 214 try { 215 mService.setCurrentUser(userId); 216 } catch (RemoteException e) { 217 Slog.w(TAG , "Remote Exception", e); 218 } 219 } 220 221 @Override // Binder interface 222 public void onBootCompleted() { 223 try { 224 mService.onBootCompleted(); 225 } catch (RemoteException e) { 226 Slog.w(TAG , "Remote Exception", e); 227 } 228 } 229 230 @Override // Binder interface 231 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { 232 try { 233 mService.startKeyguardExitAnimation(startTime, fadeoutDuration); 234 } catch (RemoteException e) { 235 Slog.w(TAG , "Remote Exception", e); 236 } 237 } 238 239 @Override 240 public void onShortPowerPressedGoHome() { 241 try { 242 mService.onShortPowerPressedGoHome(); 243 } catch (RemoteException e) { 244 Slog.w(TAG , "Remote Exception", e); 245 } 246 } 247 248 @Override // Binder interface 249 public IBinder asBinder() { 250 return mService.asBinder(); 251 } 252 253 public boolean isShowing() { 254 return mKeyguardStateMonitor.isShowing(); 255 } 256 257 public boolean isTrusted() { 258 return mKeyguardStateMonitor.isTrusted(); 259 } 260 261 public boolean hasLockscreenWallpaper() { 262 return mKeyguardStateMonitor.hasLockscreenWallpaper(); 263 } 264 265 public boolean isSecure(int userId) { 266 return mKeyguardStateMonitor.isSecure(userId); 267 } 268 269 public boolean isInputRestricted() { 270 return mKeyguardStateMonitor.isInputRestricted(); 271 } 272 273 public void dump(String prefix, PrintWriter pw) { 274 mKeyguardStateMonitor.dump(prefix, pw); 275 } 276 }