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.IKeyguardDrawnCallback; 26 import com.android.internal.policy.IKeyguardExitCallback; 27 import com.android.internal.policy.IKeyguardService; 28 import 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 */ 35 public 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 145 public void onScreenTurnedOn() { 146 try { 147 mService.onScreenTurnedOn(); 148 } catch (RemoteException e) { 149 Slog.w(TAG , "Remote Exception", e); 150 } 151 } 152 153 @Override 154 public void onScreenTurnedOff() { 155 try { 156 mService.onScreenTurnedOff(); 157 } catch (RemoteException e) { 158 Slog.w(TAG , "Remote Exception", e); 159 } 160 } 161 162 @Override // Binder interface 163 public void setKeyguardEnabled(boolean enabled) { 164 try { 165 mService.setKeyguardEnabled(enabled); 166 } catch (RemoteException e) { 167 Slog.w(TAG , "Remote Exception", e); 168 } 169 } 170 171 @Override // Binder interface 172 public void onSystemReady() { 173 try { 174 mService.onSystemReady(); 175 } catch (RemoteException e) { 176 Slog.w(TAG , "Remote Exception", e); 177 } 178 } 179 180 @Override // Binder interface 181 public void doKeyguardTimeout(Bundle options) { 182 try { 183 mService.doKeyguardTimeout(options); 184 } catch (RemoteException e) { 185 Slog.w(TAG , "Remote Exception", e); 186 } 187 } 188 189 @Override // Binder interface 190 public void setCurrentUser(int userId) { 191 mKeyguardStateMonitor.setCurrentUser(userId); 192 try { 193 mService.setCurrentUser(userId); 194 } catch (RemoteException e) { 195 Slog.w(TAG , "Remote Exception", e); 196 } 197 } 198 199 @Override // Binder interface 200 public void onBootCompleted() { 201 try { 202 mService.onBootCompleted(); 203 } catch (RemoteException e) { 204 Slog.w(TAG , "Remote Exception", e); 205 } 206 } 207 208 @Override // Binder interface 209 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { 210 try { 211 mService.startKeyguardExitAnimation(startTime, fadeoutDuration); 212 } catch (RemoteException e) { 213 Slog.w(TAG , "Remote Exception", e); 214 } 215 } 216 217 @Override // Binder interface 218 public void onActivityDrawn() { 219 try { 220 mService.onActivityDrawn(); 221 } catch (RemoteException e) { 222 Slog.w(TAG , "Remote Exception", e); 223 } 224 } 225 226 @Override // Binder interface 227 public IBinder asBinder() { 228 return mService.asBinder(); 229 } 230 231 public boolean isShowing() { 232 return mKeyguardStateMonitor.isShowing(); 233 } 234 235 public boolean isSecure() { 236 return mKeyguardStateMonitor.isSecure(); 237 } 238 239 public boolean isInputRestricted() { 240 return mKeyguardStateMonitor.isInputRestricted(); 241 } 242 }