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