/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java

https://github.com/aizuzi/platform_frameworks_base · Java · 208 lines · 157 code · 28 blank · 23 comment · 0 complexity · f31423a9052b042c38cbaefd4ecf8962 MD5 · raw file

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