Home | History | Annotate | Download | only in keyguard
      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.internal.policy.impl.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.IKeyguardExitCallback;
     26 import com.android.internal.policy.IKeyguardService;
     27 import com.android.internal.policy.IKeyguardShowCallback;
     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 // Binder interface
    109     public void onScreenTurnedOff(int reason) {
    110         try {
    111             mService.onScreenTurnedOff(reason);
    112         } catch (RemoteException e) {
    113             Slog.w(TAG , "Remote Exception", e);
    114         }
    115     }
    116 
    117     @Override // Binder interface
    118     public void onScreenTurnedOn(IKeyguardShowCallback result) {
    119         try {
    120             mService.onScreenTurnedOn(result);
    121         } catch (RemoteException e) {
    122             Slog.w(TAG , "Remote Exception", e);
    123         }
    124     }
    125 
    126     @Override // Binder interface
    127     public void setKeyguardEnabled(boolean enabled) {
    128         try {
    129             mService.setKeyguardEnabled(enabled);
    130         } catch (RemoteException e) {
    131             Slog.w(TAG , "Remote Exception", e);
    132         }
    133     }
    134 
    135     @Override // Binder interface
    136     public void onSystemReady() {
    137         try {
    138             mService.onSystemReady();
    139         } catch (RemoteException e) {
    140             Slog.w(TAG , "Remote Exception", e);
    141         }
    142     }
    143 
    144     @Override // Binder interface
    145     public void doKeyguardTimeout(Bundle options) {
    146         try {
    147             mService.doKeyguardTimeout(options);
    148         } catch (RemoteException e) {
    149             Slog.w(TAG , "Remote Exception", e);
    150         }
    151     }
    152 
    153     @Override // Binder interface
    154     public void setCurrentUser(int userId) {
    155         mKeyguardStateMonitor.setCurrentUser(userId);
    156         try {
    157             mService.setCurrentUser(userId);
    158         } catch (RemoteException e) {
    159             Slog.w(TAG , "Remote Exception", e);
    160         }
    161     }
    162 
    163     @Override // Binder interface
    164     public void onBootCompleted() {
    165         try {
    166             mService.onBootCompleted();
    167         } catch (RemoteException e) {
    168             Slog.w(TAG , "Remote Exception", e);
    169         }
    170     }
    171 
    172     @Override // Binder interface
    173     public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
    174         try {
    175             mService.startKeyguardExitAnimation(startTime, fadeoutDuration);
    176         } catch (RemoteException e) {
    177             Slog.w(TAG , "Remote Exception", e);
    178         }
    179     }
    180 
    181     @Override // Binder interface
    182     public void onActivityDrawn() {
    183         try {
    184             mService.onActivityDrawn();
    185         } catch (RemoteException e) {
    186             Slog.w(TAG , "Remote Exception", e);
    187         }
    188     }
    189 
    190     @Override // Binder interface
    191     public IBinder asBinder() {
    192         return mService.asBinder();
    193     }
    194 
    195     public boolean isShowing() {
    196         return mKeyguardStateMonitor.isShowing();
    197     }
    198 
    199     public boolean isSecure() {
    200         return mKeyguardStateMonitor.isSecure();
    201     }
    202 
    203     public boolean isInputRestricted() {
    204         return mKeyguardStateMonitor.isInputRestricted();
    205     }
    206 }