The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 android.app; |
| 18 | |
Tor Norbye | 672055e | 2015-04-23 17:30:56 -0700 | [diff] [blame] | 19 | import android.Manifest; |
| 20 | import android.annotation.RequiresPermission; |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 21 | import android.app.trust.ITrustManager; |
| 22 | import android.content.Context; |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 23 | import android.content.Intent; |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 24 | import android.content.pm.UserInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.os.Binder; |
| 26 | import android.os.RemoteException; |
| 27 | import android.os.IBinder; |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 28 | import android.os.IUserManager; |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 29 | import android.os.ServiceManager; |
| 30 | import android.os.UserHandle; |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 31 | import android.os.UserManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.view.IWindowManager; |
| 33 | import android.view.IOnKeyguardExitResult; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 34 | import android.view.WindowManagerGlobal; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 37 | * Class that can be used to lock and unlock the keyboard. Get an instance of this |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | * class by calling {@link android.content.Context#getSystemService(java.lang.String)} |
| 39 | * with argument {@link android.content.Context#KEYGUARD_SERVICE}. The |
Jean-Michel Trivi | 37fde0a | 2012-05-24 17:13:06 -0700 | [diff] [blame] | 40 | * actual class to control the keyboard locking is |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | * {@link android.app.KeyguardManager.KeyguardLock}. |
| 42 | */ |
| 43 | public class KeyguardManager { |
| 44 | private IWindowManager mWM; |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 45 | private ITrustManager mTrustManager; |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 46 | private IUserManager mUserManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | |
| 48 | /** |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 49 | * Intent used to prompt user for device credentials. |
| 50 | * @hide |
| 51 | */ |
| 52 | public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL = |
| 53 | "android.app.action.CONFIRM_DEVICE_CREDENTIAL"; |
| 54 | |
| 55 | /** |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 56 | * Intent used to prompt user for device credentials. |
| 57 | * @hide |
| 58 | */ |
| 59 | public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER = |
| 60 | "android.app.action.CONFIRM_DEVICE_CREDENTIAL_WITH_USER"; |
| 61 | |
| 62 | /** |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 63 | * A CharSequence dialog title to show to the user when used with a |
| 64 | * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. |
| 65 | * @hide |
| 66 | */ |
| 67 | public static final String EXTRA_TITLE = "android.app.extra.TITLE"; |
| 68 | |
| 69 | /** |
| 70 | * A CharSequence description to show to the user when used with |
| 71 | * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. |
| 72 | * @hide |
| 73 | */ |
| 74 | public static final String EXTRA_DESCRIPTION = "android.app.extra.DESCRIPTION"; |
| 75 | |
| 76 | /** |
| 77 | * Get an intent to prompt the user to confirm credentials (pin, pattern or password) |
| 78 | * for the current user of the device. The caller is expected to launch this activity using |
| 79 | * {@link android.app.Activity#startActivityForResult(Intent, int)} and check for |
| 80 | * {@link android.app.Activity#RESULT_OK} if the user successfully completes the challenge. |
| 81 | * |
| 82 | * @return the intent for launching the activity or null if no password is required. |
| 83 | **/ |
Jim Miller | bde3d18 | 2014-08-26 19:53:17 -0700 | [diff] [blame] | 84 | public Intent createConfirmDeviceCredentialIntent(CharSequence title, CharSequence description) { |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 85 | if (!isDeviceSecure()) return null; |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 86 | Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL); |
| 87 | intent.putExtra(EXTRA_TITLE, title); |
| 88 | intent.putExtra(EXTRA_DESCRIPTION, description); |
| 89 | // For security reasons, only allow this to come from system settings. |
| 90 | intent.setPackage("com.android.settings"); |
| 91 | return intent; |
| 92 | } |
| 93 | |
| 94 | /** |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 95 | * Get an intent to prompt the user to confirm credentials (pin, pattern or password) |
| 96 | * for the given user. The caller is expected to launch this activity using |
| 97 | * {@link android.app.Activity#startActivityForResult(Intent, int)} and check for |
| 98 | * {@link android.app.Activity#RESULT_OK} if the user successfully completes the challenge. |
| 99 | * |
| 100 | * @return the intent for launching the activity or null if no password is required. |
| 101 | * |
| 102 | * @hide |
| 103 | */ |
| 104 | public Intent createConfirmDeviceCredentialIntent( |
| 105 | CharSequence title, CharSequence description, int userId) { |
| 106 | if (!isDeviceSecure(userId)) return null; |
| 107 | Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER); |
| 108 | intent.putExtra(EXTRA_TITLE, title); |
| 109 | intent.putExtra(EXTRA_DESCRIPTION, description); |
| 110 | intent.putExtra(Intent.EXTRA_USER_ID, userId); |
| 111 | // For security reasons, only allow this to come from system settings. |
| 112 | intent.setPackage("com.android.settings"); |
| 113 | return intent; |
| 114 | } |
| 115 | |
| 116 | /** |
Dianne Hackborn | 9567a66 | 2011-04-19 18:44:03 -0700 | [diff] [blame] | 117 | * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD} |
| 118 | * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} |
| 119 | * instead; this allows you to seamlessly hide the keyguard as your application |
| 120 | * moves in and out of the foreground and does not require that any special |
| 121 | * permissions be requested. |
| 122 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | * Handle returned by {@link KeyguardManager#newKeyguardLock} that allows |
| 124 | * you to disable / reenable the keyguard. |
| 125 | */ |
| 126 | public class KeyguardLock { |
Kenny Root | d7d2d43 | 2014-05-09 10:33:29 -0700 | [diff] [blame] | 127 | private final IBinder mToken = new Binder(); |
| 128 | private final String mTag; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | |
| 130 | KeyguardLock(String tag) { |
| 131 | mTag = tag; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Disable the keyguard from showing. If the keyguard is currently |
| 136 | * showing, hide it. The keyguard will be prevented from showing again |
| 137 | * until {@link #reenableKeyguard()} is called. |
| 138 | * |
| 139 | * A good place to call this is from {@link android.app.Activity#onResume()} |
| 140 | * |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 141 | * Note: This call has no effect while any {@link android.app.admin.DevicePolicyManager} |
Jim Miller | cb52cb5 | 2010-06-07 21:19:16 -0700 | [diff] [blame] | 142 | * is enabled that requires a password. |
Jim Miller | d6b5705 | 2010-06-07 17:52:42 -0700 | [diff] [blame] | 143 | * |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 144 | * <p>This method requires the caller to hold the permission |
| 145 | * {@link android.Manifest.permission#DISABLE_KEYGUARD}. |
| 146 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | * @see #reenableKeyguard() |
| 148 | */ |
Tor Norbye | 672055e | 2015-04-23 17:30:56 -0700 | [diff] [blame] | 149 | @RequiresPermission(Manifest.permission.DISABLE_KEYGUARD) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | public void disableKeyguard() { |
| 151 | try { |
| 152 | mWM.disableKeyguard(mToken, mTag); |
| 153 | } catch (RemoteException ex) { |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Reenable the keyguard. The keyguard will reappear if the previous |
Jean-Michel Trivi | 37fde0a | 2012-05-24 17:13:06 -0700 | [diff] [blame] | 159 | * call to {@link #disableKeyguard()} caused it to be hidden. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 160 | * |
Jim Miller | d6b5705 | 2010-06-07 17:52:42 -0700 | [diff] [blame] | 161 | * A good place to call this is from {@link android.app.Activity#onPause()} |
| 162 | * |
Jim Miller | cb52cb5 | 2010-06-07 21:19:16 -0700 | [diff] [blame] | 163 | * Note: This call has no effect while any {@link android.app.admin.DevicePolicyManager} |
| 164 | * is enabled that requires a password. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 165 | * |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 166 | * <p>This method requires the caller to hold the permission |
| 167 | * {@link android.Manifest.permission#DISABLE_KEYGUARD}. |
| 168 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | * @see #disableKeyguard() |
| 170 | */ |
Tor Norbye | 672055e | 2015-04-23 17:30:56 -0700 | [diff] [blame] | 171 | @RequiresPermission(Manifest.permission.DISABLE_KEYGUARD) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | public void reenableKeyguard() { |
| 173 | try { |
| 174 | mWM.reenableKeyguard(mToken); |
| 175 | } catch (RemoteException ex) { |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Callback passed to {@link KeyguardManager#exitKeyguardSecurely} to notify |
| 182 | * caller of result. |
| 183 | */ |
| 184 | public interface OnKeyguardExitResult { |
| 185 | |
| 186 | /** |
| 187 | * @param success True if the user was able to authenticate, false if |
| 188 | * not. |
| 189 | */ |
| 190 | void onKeyguardExitResult(boolean success); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | KeyguardManager() { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 195 | mWM = WindowManagerGlobal.getWindowManagerService(); |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 196 | mTrustManager = ITrustManager.Stub.asInterface( |
| 197 | ServiceManager.getService(Context.TRUST_SERVICE)); |
Clara Bayarri | b3987bd | 2015-11-18 16:39:34 -0800 | [diff] [blame] | 198 | mUserManager = IUserManager.Stub.asInterface( |
| 199 | ServiceManager.getService(Context.USER_SERVICE)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | /** |
Dianne Hackborn | 9567a66 | 2011-04-19 18:44:03 -0700 | [diff] [blame] | 203 | * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD} |
| 204 | * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} |
| 205 | * instead; this allows you to seamlessly hide the keyguard as your application |
| 206 | * moves in and out of the foreground and does not require that any special |
| 207 | * permissions be requested. |
| 208 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | * Enables you to lock or unlock the keyboard. Get an instance of this class by |
Jim Miller | 66093a9 | 2014-08-13 14:47:47 -0700 | [diff] [blame] | 210 | * calling {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | * This class is wrapped by {@link android.app.KeyguardManager KeyguardManager}. |
| 212 | * @param tag A tag that informally identifies who you are (for debugging who |
| 213 | * is disabling he keyguard). |
| 214 | * |
| 215 | * @return A {@link KeyguardLock} handle to use to disable and reenable the |
| 216 | * keyguard. |
| 217 | */ |
Dianne Hackborn | 9567a66 | 2011-04-19 18:44:03 -0700 | [diff] [blame] | 218 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 219 | public KeyguardLock newKeyguardLock(String tag) { |
| 220 | return new KeyguardLock(tag); |
| 221 | } |
| 222 | |
| 223 | /** |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 224 | * Return whether the keyguard is currently locked. |
| 225 | * |
Jean-Michel Trivi | 37fde0a | 2012-05-24 17:13:06 -0700 | [diff] [blame] | 226 | * @return true if keyguard is locked. |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 227 | */ |
| 228 | public boolean isKeyguardLocked() { |
| 229 | try { |
Mike Lockwood | 5053124 | 2011-02-26 11:23:49 -0500 | [diff] [blame] | 230 | return mWM.isKeyguardLocked(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 231 | } catch (RemoteException ex) { |
| 232 | return false; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | /** |
Adrian Roos | c39b4fc | 2015-04-28 15:48:00 -0700 | [diff] [blame] | 237 | * Return whether the keyguard is secured by a PIN, pattern or password or a SIM card |
| 238 | * is currently locked. |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 239 | * |
Adrian Roos | c39b4fc | 2015-04-28 15:48:00 -0700 | [diff] [blame] | 240 | * <p>See also {@link #isDeviceSecure()} which ignores SIM locked states. |
| 241 | * |
| 242 | * @return true if a PIN, pattern or password is set or a SIM card is locked. |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 243 | */ |
| 244 | public boolean isKeyguardSecure() { |
| 245 | try { |
| 246 | return mWM.isKeyguardSecure(); |
| 247 | } catch (RemoteException ex) { |
| 248 | return false; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | * If keyguard screen is showing or in restricted key input mode (i.e. in |
| 254 | * keyguard password emergency screen). When in such mode, certain keys, |
| 255 | * such as the Home key and the right soft keys, don't work. |
| 256 | * |
| 257 | * @return true if in keyguard restricted input mode. |
| 258 | * |
| 259 | * @see android.view.WindowManagerPolicy#inKeyguardRestrictedKeyInputMode |
| 260 | */ |
| 261 | public boolean inKeyguardRestrictedInputMode() { |
| 262 | try { |
| 263 | return mWM.inKeyguardRestrictedInputMode(); |
| 264 | } catch (RemoteException ex) { |
| 265 | return false; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
Adrian Roos | 50bfeec | 2014-11-20 16:21:11 +0100 | [diff] [blame] | 270 | * Returns whether the device is currently locked and requires a PIN, pattern or |
| 271 | * password to unlock. |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 272 | * |
Adrian Roos | 50bfeec | 2014-11-20 16:21:11 +0100 | [diff] [blame] | 273 | * @return true if unlocking the device currently requires a PIN, pattern or |
| 274 | * password. |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 275 | */ |
Adrian Roos | 50bfeec | 2014-11-20 16:21:11 +0100 | [diff] [blame] | 276 | public boolean isDeviceLocked() { |
| 277 | return isDeviceLocked(UserHandle.getCallingUserId()); |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /** |
Adrian Roos | c39b4fc | 2015-04-28 15:48:00 -0700 | [diff] [blame] | 281 | * Per-user version of {@link #isDeviceLocked()}. |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 282 | * |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 283 | * @hide |
| 284 | */ |
Adrian Roos | 50bfeec | 2014-11-20 16:21:11 +0100 | [diff] [blame] | 285 | public boolean isDeviceLocked(int userId) { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 286 | ITrustManager trustManager = getTrustManager(); |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 287 | try { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 288 | return trustManager.isDeviceLocked(userId); |
Adrian Roos | bcd0765 | 2014-10-22 16:57:16 +0200 | [diff] [blame] | 289 | } catch (RemoteException e) { |
| 290 | return false; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | /** |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 295 | * Returns whether the device is secured with a PIN, pattern or |
| 296 | * password. |
| 297 | * |
Adrian Roos | c39b4fc | 2015-04-28 15:48:00 -0700 | [diff] [blame] | 298 | * <p>See also {@link #isKeyguardSecure} which treats SIM locked states as secure. |
| 299 | * |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 300 | * @return true if a PIN, pattern or password was set. |
| 301 | */ |
| 302 | public boolean isDeviceSecure() { |
| 303 | return isDeviceSecure(UserHandle.getCallingUserId()); |
| 304 | } |
| 305 | |
| 306 | /** |
Adrian Roos | c39b4fc | 2015-04-28 15:48:00 -0700 | [diff] [blame] | 307 | * Per-user version of {@link #isDeviceSecure()}. |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 308 | * |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 309 | * @hide |
| 310 | */ |
| 311 | public boolean isDeviceSecure(int userId) { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 312 | ITrustManager trustManager = getTrustManager(); |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 313 | try { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 314 | return trustManager.isDeviceSecure(userId); |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 315 | } catch (RemoteException e) { |
| 316 | return false; |
| 317 | } |
| 318 | } |
| 319 | |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 320 | private synchronized ITrustManager getTrustManager() { |
| 321 | if (mTrustManager == null) { |
| 322 | mTrustManager = ITrustManager.Stub.asInterface( |
| 323 | ServiceManager.getService(Context.TRUST_SERVICE)); |
| 324 | } |
| 325 | return mTrustManager; |
| 326 | } |
| 327 | |
Adrian Roos | 8289368 | 2015-04-02 16:17:46 +0200 | [diff] [blame] | 328 | /** |
Dianne Hackborn | 9567a66 | 2011-04-19 18:44:03 -0700 | [diff] [blame] | 329 | * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD} |
| 330 | * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} |
| 331 | * instead; this allows you to seamlessly hide the keyguard as your application |
| 332 | * moves in and out of the foreground and does not require that any special |
| 333 | * permissions be requested. |
| 334 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 335 | * Exit the keyguard securely. The use case for this api is that, after |
| 336 | * disabling the keyguard, your app, which was granted permission to |
| 337 | * disable the keyguard and show a limited amount of information deemed |
| 338 | * safe without the user getting past the keyguard, needs to navigate to |
| 339 | * something that is not safe to view without getting past the keyguard. |
| 340 | * |
| 341 | * This will, if the keyguard is secure, bring up the unlock screen of |
| 342 | * the keyguard. |
| 343 | * |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 344 | * <p>This method requires the caller to hold the permission |
| 345 | * {@link android.Manifest.permission#DISABLE_KEYGUARD}. |
| 346 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 347 | * @param callback Let's you know whether the operation was succesful and |
| 348 | * it is safe to launch anything that would normally be considered safe |
| 349 | * once the user has gotten past the keyguard. |
| 350 | */ |
Dianne Hackborn | 9567a66 | 2011-04-19 18:44:03 -0700 | [diff] [blame] | 351 | @Deprecated |
Tor Norbye | 672055e | 2015-04-23 17:30:56 -0700 | [diff] [blame] | 352 | @RequiresPermission(Manifest.permission.DISABLE_KEYGUARD) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | public void exitKeyguardSecurely(final OnKeyguardExitResult callback) { |
| 354 | try { |
| 355 | mWM.exitKeyguardSecurely(new IOnKeyguardExitResult.Stub() { |
| 356 | public void onKeyguardExitResult(boolean success) throws RemoteException { |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 357 | if (callback != null) { |
| 358 | callback.onKeyguardExitResult(success); |
| 359 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 360 | } |
| 361 | }); |
| 362 | } catch (RemoteException e) { |
| 363 | |
| 364 | } |
| 365 | } |
| 366 | } |