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      * @param plmn The operator name of the registered network.  May be null if it shouldn't
     54      *   be displayed.
     55      * @param spn The service provider name.  May be null if it shouldn't be displayed.
     56      */
     57     public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { }
     58 
     59     /**
     60      * Called when the ringer mode changes.
     61      * @param state the current ringer state, as defined in
     62      * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
     63      */
     64     public void onRingerModeChanged(int state) { }
     65 
     66     /**
     67      * Called when the phone state changes. String will be one of:
     68      * {@link TelephonyManager#EXTRA_STATE_IDLE}
     69      * {@link TelephonyManager@EXTRA_STATE_RINGING}
     70      * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
     71      */
     72     public void onPhoneStateChanged(int phoneState) { }
     73 
     74     /**
     75      * Called when the visibility of the keyguard changes.
     76      * @param showing Indicates if the keyguard is now visible.
     77      */
     78     public void onKeyguardVisibilityChanged(boolean showing) { }
     79 
     80     public void onKeyguardVisibilityChangedRaw(boolean showing) {
     81         final long now = SystemClock.elapsedRealtime();
     82         if (showing == mShowing
     83                 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
     84         onKeyguardVisibilityChanged(showing);
     85         mVisibilityChangedCalled = now;
     86         mShowing = showing;
     87     }
     88 
     89     /**
     90      * Called when the keyguard enters or leaves bouncer mode.
     91      * @param bouncer if true, keyguard is now in bouncer mode.
     92      */
     93     public void onKeyguardBouncerChanged(boolean bouncer) { }
     94 
     95     /**
     96      * Called when visibility of lockscreen clock changes, such as when
     97      * obscured by a widget.
     98      */
     99     public void onClockVisibilityChanged() { }
    100 
    101     /**
    102      * Called when the device becomes provisioned
    103      */
    104     public void onDeviceProvisioned() { }
    105 
    106     /**
    107      * Called when the device policy changes.
    108      * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
    109      */
    110     public void onDevicePolicyManagerStateChanged() { }
    111 
    112     /**
    113      * Called when the user change begins.
    114      */
    115     public void onUserSwitching(int userId) { }
    116 
    117     /**
    118      * Called when the user change is complete.
    119      */
    120     public void onUserSwitchComplete(int userId) { }
    121 
    122     /**
    123      * Called when the SIM state changes.
    124      * @param simState
    125      */
    126     public void onSimStateChanged(IccCardConstants.State simState) { }
    127 
    128     /**
    129      * Called when a user is removed.
    130      */
    131     public void onUserRemoved(int userId) { }
    132 
    133     /**
    134      * Called when the user's info changed.
    135      */
    136     public void onUserInfoChanged(int userId) { }
    137 
    138     /**
    139      * Called when boot completed.
    140      *
    141      * Note, this callback will only be received if boot complete occurs after registering with
    142      * KeyguardUpdateMonitor.
    143      */
    144     public void onBootCompleted() { }
    145 
    146     /**
    147      * Called when the emergency call button is pressed.
    148      */
    149     public void onEmergencyCallAction() { }
    150 
    151     /**
    152      * Called when the transport background changes.
    153      * @param bitmap
    154      */
    155     public void onSetBackground(Bitmap bitmap) {
    156     }
    157 
    158     /**
    159      * Called when the screen turns on
    160      */
    161     public void onScreenTurnedOn() { }
    162 
    163     /**
    164      * Called when the screen turns off
    165      * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN},
    166      * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or
    167      * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}.
    168      */
    169     public void onScreenTurnedOff(int why) { }
    170 
    171     /**
    172      * Called when trust changes for a user.
    173      */
    174     public void onTrustChanged(int userId) { }
    175 
    176     /**
    177      * Called when trust being managed changes for a user.
    178      */
    179     public void onTrustManagedChanged(int userId) { }
    180 
    181     /**
    182      * Called when the user has proved to a trust agent that they want to use the device.
    183      */
    184     public void onTrustInitiatedByUser(int userId) { }
    185 
    186     /**
    187      * Called when a fingerprint is recognized.
    188      * @param userId
    189      */
    190     public void onFingerprintRecognized(int userId) { }
    191 
    192     /**
    193      * Called when fingerprint is acquired but not yet recognized
    194      */
    195     public void onFingerprintAcquired(int info) { }
    196 
    197     /**
    198      * Called when the state of face unlock changed.
    199      */
    200     public void onFaceUnlockStateChanged(boolean running, int userId) { }
    201 }
    202