Home | History | Annotate | Download | only in keyguard
      1 /*
      2  * Copyright (C) 2012 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.keyguard;
     17 
     18 import android.app.PendingIntent;
     19 import android.app.admin.DevicePolicyManager;
     20 import android.graphics.Bitmap;
     21 import android.media.AudioManager;
     22 import android.os.SystemClock;
     23 import android.telephony.TelephonyManager;
     24 import android.view.WindowManagerPolicy;
     25 
     26 import com.android.internal.telephony.IccCardConstants;
     27 
     28 /**
     29  * Callback for general information relevant to lock screen.
     30  */
     31 public class KeyguardUpdateMonitorCallback {
     32 
     33     private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
     34     private long mVisibilityChangedCalled;
     35     private boolean mShowing;
     36 
     37     /**
     38      * Called when the battery status changes, e.g. when plugged in or unplugged, charge
     39      * level, etc. changes.
     40      *
     41      * @param status current battery status
     42      */
     43     public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { }
     44 
     45     /**
     46      * Called once per minute or when the time changes.
     47      */
     48     public void onTimeChanged() { }
     49 
     50     /**
     51      * Called when the carrier PLMN or SPN changes.
     52      */
     53     public void onRefreshCarrierInfo() { }
     54 
     55     /**
     56      * Called when the ringer mode changes.
     57      * @param state the current ringer state, as defined in
     58      * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
     59      */
     60     public void onRingerModeChanged(int state) { }
     61 
     62     /**
     63      * Called when the phone state changes. String will be one of:
     64      * {@link TelephonyManager#EXTRA_STATE_IDLE}
     65      * {@link TelephonyManager@EXTRA_STATE_RINGING}
     66      * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
     67      */
     68     public void onPhoneStateChanged(int phoneState) { }
     69 
     70     /**
     71      * Called when the visibility of the keyguard changes.
     72      * @param showing Indicates if the keyguard is now visible.
     73      */
     74     public void onKeyguardVisibilityChanged(boolean showing) { }
     75 
     76     public void onKeyguardVisibilityChangedRaw(boolean showing) {
     77         final long now = SystemClock.elapsedRealtime();
     78         if (showing == mShowing
     79                 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
     80         onKeyguardVisibilityChanged(showing);
     81         mVisibilityChangedCalled = now;
     82         mShowing = showing;
     83     }
     84 
     85     /**
     86      * Called when the keyguard enters or leaves bouncer mode.
     87      * @param bouncer if true, keyguard is now in bouncer mode.
     88      */
     89     public void onKeyguardBouncerChanged(boolean bouncer) { }
     90 
     91     /**
     92      * Called when visibility of lockscreen clock changes, such as when
     93      * obscured by a widget.
     94      */
     95     public void onClockVisibilityChanged() { }
     96 
     97     /**
     98      * Called when the device becomes provisioned
     99      */
    100     public void onDeviceProvisioned() { }
    101 
    102     /**
    103      * Called when the device policy changes.
    104      * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
    105      */
    106     public void onDevicePolicyManagerStateChanged() { }
    107 
    108     /**
    109      * Called when the user change begins.
    110      */
    111     public void onUserSwitching(int userId) { }
    112 
    113     /**
    114      * Called when the user change is complete.
    115      */
    116     public void onUserSwitchComplete(int userId) { }
    117 
    118     /**
    119      * Called when the SIM state changes.
    120      * @param slotId
    121      * @param simState
    122      */
    123     public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }
    124 
    125     /**
    126      * Called when a user is removed.
    127      */
    128     public void onUserRemoved(int userId) { }
    129 
    130     /**
    131      * Called when the user's info changed.
    132      */
    133     public void onUserInfoChanged(int userId) { }
    134 
    135     /**
    136      * Called when boot completed.
    137      *
    138      * Note, this callback will only be received if boot complete occurs after registering with
    139      * KeyguardUpdateMonitor.
    140      */
    141     public void onBootCompleted() { }
    142 
    143     /**
    144      * Called when the emergency call button is pressed.
    145      */
    146     public void onEmergencyCallAction() { }
    147 
    148     /**
    149      * Called when the transport background changes.
    150      * @param bitmap
    151      */
    152     public void onSetBackground(Bitmap bitmap) {
    153     }
    154 
    155     /**
    156      * Called when the screen turns on
    157      */
    158     public void onScreenTurnedOn() { }
    159 
    160     /**
    161      * Called when the screen turns off
    162      * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN},
    163      * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or
    164      * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}.
    165      */
    166     public void onScreenTurnedOff(int why) { }
    167 
    168     /**
    169      * Called when trust changes for a user.
    170      */
    171     public void onTrustChanged(int userId) { }
    172 
    173     /**
    174      * Called when trust being managed changes for a user.
    175      */
    176     public void onTrustManagedChanged(int userId) { }
    177 
    178     /**
    179      * Called when the user has proved to a trust agent that they want to use the device.
    180      */
    181     public void onTrustInitiatedByUser(int userId) { }
    182 
    183     /**
    184      * Called when a fingerprint is recognized.
    185      * @param userId
    186      */
    187     public void onFingerprintRecognized(int userId) { }
    188 
    189     /**
    190      * Called when fingerprint is acquired but not yet recognized
    191      */
    192     public void onFingerprintAcquired(int info) { }
    193 
    194     /**
    195      * Called when the state of face unlock changed.
    196      */
    197     public void onFaceUnlockStateChanged(boolean running, int userId) { }
    198 }
    199