diff options
| author | Clara Bayarri <clarabayarri@google.com> | 2015-12-15 14:14:34 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-12-15 14:14:34 +0000 |
| commit | cf5984710dfa6840b6d41b36d9137fb60a5f13e2 (patch) | |
| tree | 1d2fc106d79bb1cd53b8f6882434b3c2e805aa2f /core/java | |
| parent | 16c9a107b594816ce56b397f0a454368d9e20b35 (diff) | |
| parent | b3987bd7e9d9ed6e2b336c239b1d8019f8ffe073 (diff) | |
Merge "Make ConfirmCredentials take user into account when creating intent"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/KeyguardManager.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index 23e4d97d654c..391065787683 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -21,11 +21,14 @@ import android.annotation.RequiresPermission; import android.app.trust.ITrustManager; import android.content.Context; import android.content.Intent; +import android.content.pm.UserInfo; import android.os.Binder; import android.os.RemoteException; import android.os.IBinder; +import android.os.IUserManager; import android.os.ServiceManager; import android.os.UserHandle; +import android.os.UserManager; import android.view.IWindowManager; import android.view.IOnKeyguardExitResult; import android.view.WindowManagerGlobal; @@ -40,6 +43,7 @@ import android.view.WindowManagerGlobal; public class KeyguardManager { private IWindowManager mWM; private ITrustManager mTrustManager; + private IUserManager mUserManager; /** * Intent used to prompt user for device credentials. @@ -49,6 +53,13 @@ public class KeyguardManager { "android.app.action.CONFIRM_DEVICE_CREDENTIAL"; /** + * Intent used to prompt user for device credentials. + * @hide + */ + public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER = + "android.app.action.CONFIRM_DEVICE_CREDENTIAL_WITH_USER"; + + /** * A CharSequence dialog title to show to the user when used with a * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. * @hide @@ -71,7 +82,7 @@ public class KeyguardManager { * @return the intent for launching the activity or null if no password is required. **/ public Intent createConfirmDeviceCredentialIntent(CharSequence title, CharSequence description) { - if (!isKeyguardSecure()) return null; + if (!isDeviceSecure()) return null; Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_DESCRIPTION, description); @@ -81,6 +92,28 @@ public class KeyguardManager { } /** + * Get an intent to prompt the user to confirm credentials (pin, pattern or password) + * for the given user. The caller is expected to launch this activity using + * {@link android.app.Activity#startActivityForResult(Intent, int)} and check for + * {@link android.app.Activity#RESULT_OK} if the user successfully completes the challenge. + * + * @return the intent for launching the activity or null if no password is required. + * + * @hide + */ + public Intent createConfirmDeviceCredentialIntent( + CharSequence title, CharSequence description, int userId) { + if (!isDeviceSecure(userId)) return null; + Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER); + intent.putExtra(EXTRA_TITLE, title); + intent.putExtra(EXTRA_DESCRIPTION, description); + intent.putExtra(Intent.EXTRA_USER_ID, userId); + // For security reasons, only allow this to come from system settings. + intent.setPackage("com.android.settings"); + return intent; + } + + /** * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD} * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} * instead; this allows you to seamlessly hide the keyguard as your application @@ -162,6 +195,8 @@ public class KeyguardManager { mWM = WindowManagerGlobal.getWindowManagerService(); mTrustManager = ITrustManager.Stub.asInterface( ServiceManager.getService(Context.TRUST_SERVICE)); + mUserManager = IUserManager.Stub.asInterface( + ServiceManager.getService(Context.USER_SERVICE)); } /** |
