KeyguardServiceWrapper.java revision e51cf7aeb6157017801a802b4c1d74cbf51b7a01
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; 23 24import com.android.internal.policy.IKeyguardShowCallback; 25import com.android.internal.policy.IKeyguardExitCallback; 26import com.android.internal.policy.IKeyguardService; 27 28/** 29 * A wrapper class for KeyguardService. It implements IKeyguardService to ensure the interface 30 * remains consistent. 31 * 32 */ 33public class KeyguardServiceWrapper implements IKeyguardService { 34 private IKeyguardService mService; 35 private String TAG = "KeyguardServiceWrapper"; 36 37 public KeyguardServiceWrapper(IKeyguardService service) { 38 mService = service; 39 } 40 41 public boolean isShowing() { 42 try { 43 return mService.isShowing(); 44 } catch (RemoteException e) { 45 Slog.w(TAG , "Remote Exception", e); 46 } 47 return false; 48 } 49 50 public boolean isSecure() { 51 try { 52 return mService.isSecure(); 53 } catch (RemoteException e) { 54 Slog.w(TAG , "Remote Exception", e); 55 } 56 return false; // TODO cache state 57 } 58 59 public boolean isShowingAndNotHidden() { 60 try { 61 return mService.isShowingAndNotHidden(); 62 } catch (RemoteException e) { 63 Slog.w(TAG , "Remote Exception", e); 64 } 65 return false; // TODO cache state 66 } 67 68 public boolean isInputRestricted() { 69 try { 70 return mService.isInputRestricted(); 71 } catch (RemoteException e) { 72 Slog.w(TAG , "Remote Exception", e); 73 } 74 return false; // TODO cache state 75 } 76 77 public boolean isDismissable() { 78 try { 79 return mService.isDismissable(); 80 } catch (RemoteException e) { 81 Slog.w(TAG , "Remote Exception", e); 82 } 83 return true; // TODO cache state 84 } 85 86 public void verifyUnlock(IKeyguardExitCallback callback) { 87 try { 88 mService.verifyUnlock(callback); 89 } catch (RemoteException e) { 90 Slog.w(TAG , "Remote Exception", e); 91 } 92 } 93 94 public void keyguardDone(boolean authenticated, boolean wakeup) { 95 try { 96 mService.keyguardDone(authenticated, wakeup); 97 } catch (RemoteException e) { 98 Slog.w(TAG , "Remote Exception", e); 99 } 100 } 101 102 public void setHidden(boolean isHidden) { 103 try { 104 mService.setHidden(isHidden); 105 } catch (RemoteException e) { 106 Slog.w(TAG , "Remote Exception", e); 107 } 108 } 109 110 public void dismiss() { 111 try { 112 mService.dismiss(); 113 } catch (RemoteException e) { 114 Slog.w(TAG , "Remote Exception", e); 115 } 116 } 117 118 public void onDreamingStarted() { 119 try { 120 mService.onDreamingStarted(); 121 } catch (RemoteException e) { 122 Slog.w(TAG , "Remote Exception", e); 123 } 124 } 125 126 public void onDreamingStopped() { 127 try { 128 mService.onDreamingStopped(); 129 } catch (RemoteException e) { 130 Slog.w(TAG , "Remote Exception", e); 131 } 132 } 133 134 public void onScreenTurnedOff(int reason) { 135 try { 136 mService.onScreenTurnedOff(reason); 137 } catch (RemoteException e) { 138 Slog.w(TAG , "Remote Exception", e); 139 } 140 } 141 142 public void onScreenTurnedOn(IKeyguardShowCallback result) { 143 try { 144 mService.onScreenTurnedOn(result); 145 } catch (RemoteException e) { 146 Slog.w(TAG , "Remote Exception", e); 147 } 148 } 149 150 public void setKeyguardEnabled(boolean enabled) { 151 try { 152 mService.setKeyguardEnabled(enabled); 153 } catch (RemoteException e) { 154 Slog.w(TAG , "Remote Exception", e); 155 } 156 } 157 158 public void onSystemReady() { 159 try { 160 mService.onSystemReady(); 161 } catch (RemoteException e) { 162 Slog.w(TAG , "Remote Exception", e); 163 } 164 } 165 166 public void doKeyguardTimeout(Bundle options) { 167 try { 168 mService.doKeyguardTimeout(options); 169 } catch (RemoteException e) { 170 Slog.w(TAG , "Remote Exception", e); 171 } 172 } 173 174 public void setCurrentUser(int userId) { 175 try { 176 mService.setCurrentUser(userId); 177 } catch (RemoteException e) { 178 Slog.w(TAG , "Remote Exception", e); 179 } 180 } 181 182 public void showAssistant() { 183 try { 184 mService.showAssistant(); 185 } catch (RemoteException e) { 186 Slog.w(TAG , "Remote Exception", e); 187 } 188 } 189 190 @Override 191 public IBinder asBinder() { 192 return mService.asBinder(); 193 } 194 195}