diff options
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | core/java/android/app/KeyguardManager.java | 46 | ||||
-rw-r--r-- | core/java/android/content/Intent.java | 23 |
3 files changed, 45 insertions, 27 deletions
diff --git a/api/current.txt b/api/current.txt index 584246b..2a3c086 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4490,6 +4490,7 @@ package android.app { public class KeyguardManager { method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult); + method public android.content.Intent getConfirmDeviceCredentialIntent(java.lang.CharSequence, java.lang.CharSequence); method public boolean inKeyguardRestrictedInputMode(); method public boolean isKeyguardLocked(); method public boolean isKeyguardSecure(); @@ -7680,7 +7681,6 @@ package android.content { field public static final java.lang.String ACTION_CHOOSER = "android.intent.action.CHOOSER"; field public static final java.lang.String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; field public static final java.lang.String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; - field public static final java.lang.String ACTION_CONFIRM_DEVICE_CREDENTIAL = "android.intent.action.CONFIRM_DEVICE_CREDENTIAL"; field public static final java.lang.String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; field public static final java.lang.String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; field public static final java.lang.String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; @@ -7824,7 +7824,6 @@ package android.content { field public static final java.lang.String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list"; field public static final java.lang.String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list"; field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; - field public static final java.lang.String EXTRA_DETAILS = "android.intent.extra.DETAILS"; field public static final java.lang.String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; field public static final int EXTRA_DOCK_STATE_CAR = 2; // 0x2 field public static final int EXTRA_DOCK_STATE_DESK = 1; // 0x1 diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index db91742a..50e3a10 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -16,6 +16,7 @@ package android.app; +import android.content.Intent; import android.os.Binder; import android.os.RemoteException; import android.os.IBinder; @@ -24,7 +25,7 @@ import android.view.IOnKeyguardExitResult; import android.view.WindowManagerGlobal; /** - * Class that can be used to lock and unlock the keyboard. Get an instance of this + * Class that can be used to lock and unlock the keyboard. Get an instance of this * class by calling {@link android.content.Context#getSystemService(java.lang.String)} * with argument {@link android.content.Context#KEYGUARD_SERVICE}. The * actual class to control the keyboard locking is @@ -34,6 +35,45 @@ public class KeyguardManager { private IWindowManager mWM; /** + * Intent used to prompt user for device credentials. + * @hide + */ + public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL = + "android.app.action.CONFIRM_DEVICE_CREDENTIAL"; + + /** + * A CharSequence dialog title to show to the user when used with a + * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. + * @hide + */ + public static final String EXTRA_TITLE = "android.app.extra.TITLE"; + + /** + * A CharSequence description to show to the user when used with + * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. + * @hide + */ + public static final String EXTRA_DESCRIPTION = "android.app.extra.DESCRIPTION"; + + /** + * Get an intent to prompt the user to confirm credentials (pin, pattern or password) + * for the current user of the device. 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. + **/ + public Intent getConfirmDeviceCredentialIntent(CharSequence title, CharSequence description) { + if (!isKeyguardSecure()) return null; + Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL); + intent.putExtra(EXTRA_TITLE, title); + intent.putExtra(EXTRA_DESCRIPTION, description); + // 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 @@ -58,7 +98,7 @@ public class KeyguardManager { * * A good place to call this is from {@link android.app.Activity#onResume()} * - * Note: This call has no effect while any {@link android.app.admin.DevicePolicyManager} + * Note: This call has no effect while any {@link android.app.admin.DevicePolicyManager} * is enabled that requires a password. * * <p>This method requires the caller to hold the permission @@ -121,7 +161,7 @@ public class KeyguardManager { * permissions be requested. * * Enables you to lock or unlock the keyboard. Get an instance of this class by - * calling {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}. + * calling {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}. * This class is wrapped by {@link android.app.KeyguardManager KeyguardManager}. * @param tag A tag that informally identifies who you are (for debugging who * is disabling he keyguard). diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index abe4f0a..61e105b 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1419,21 +1419,6 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; /** - * Activity Action: Prompt the user to confirm credentials (pin, pattern or password) - * for the current user of the device. Launch this activity using - * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the - * result is {@link android.app.Activity#RESULT_OK} for a successful response to the - * challenge.<p/> - * This intent is handled by the system at a high priority and applications cannot intercept - * it.<p/> - * You can use {@link android.app.KeyguardManager#isKeyguardSecure()} to determine if the user will be - * prompted. - */ - @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) - public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL = "android.intent.action.CONFIRM_DEVICE_CREDENTIAL"; - - - /** * Specify whether the package should be uninstalled for all users. * @hide because these should not be part of normal application flow. */ @@ -3192,17 +3177,11 @@ public class Intent implements Parcelable, Cloneable { /** * A CharSequence dialog title to provide to the user when used with a - * {@link #ACTION_CHOOSER} or {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. + * {@link #ACTION_CHOOSER}. */ public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; /** - * A CharSequence description to provide to the user when used with - * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. - */ - public static final String EXTRA_DETAILS = "android.intent.extra.DETAILS"; - - /** * A Parcelable[] of {@link Intent} or * {@link android.content.pm.LabeledIntent} objects as set with * {@link #putExtra(String, Parcelable[])} of additional activities to place |