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