summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-10-22 16:57:16 +0200
committerAdrian Roos <roosa@google.com>2014-10-24 13:59:45 +0200
commitbcd076525ccb8a3dfe7d1002bcae059661c1d111 (patch)
tree8fe04a1971ee2f94786ef9ecf6e88c2ca0056308 /core/java
parentfa36b36c8b66fc89f446a9eb065c31a1b224e662 (diff)
Add API for querying trusted state
Bug: 18084166 Change-Id: Ic755461cc6978943aef4943def93a0e38a1c96c0
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/KeyguardManager.java35
-rw-r--r--core/java/android/app/trust/ITrustManager.aidl1
2 files changed, 36 insertions, 0 deletions
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index cc9aed8ccdbc..5038df93192d 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -16,10 +16,14 @@
package android.app;
+import android.app.trust.ITrustManager;
+import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.RemoteException;
import android.os.IBinder;
+import android.os.ServiceManager;
+import android.os.UserHandle;
import android.view.IWindowManager;
import android.view.IOnKeyguardExitResult;
import android.view.WindowManagerGlobal;
@@ -33,6 +37,7 @@ import android.view.WindowManagerGlobal;
*/
public class KeyguardManager {
private IWindowManager mWM;
+ private ITrustManager mTrustManager;
/**
* Intent used to prompt user for device credentials.
@@ -151,6 +156,8 @@ public class KeyguardManager {
KeyguardManager() {
mWM = WindowManagerGlobal.getWindowManagerService();
+ mTrustManager = ITrustManager.Stub.asInterface(
+ ServiceManager.getService(Context.TRUST_SERVICE));
}
/**
@@ -218,6 +225,34 @@ public class KeyguardManager {
}
/**
+ * Return whether unlocking the device is currently not requiring a password
+ * because of a trust agent.
+ *
+ * @return true if the keyguard can currently be unlocked without entering credentials
+ * because the device is in a trusted environment.
+ */
+ public boolean isKeyguardInTrustedState() {
+ return isKeyguardInTrustedState(UserHandle.getCallingUserId());
+ }
+
+ /**
+ * Return whether unlocking the device is currently not requiring a password
+ * because of a trust agent.
+ *
+ * @param userId the user for which the trusted state should be reported.
+ * @return true if the keyguard can currently be unlocked without entering credentials
+ * because the device is in a trusted environment.
+ * @hide
+ */
+ public boolean isKeyguardInTrustedState(int userId) {
+ try {
+ return mTrustManager.isTrusted(userId);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
* @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
diff --git a/core/java/android/app/trust/ITrustManager.aidl b/core/java/android/app/trust/ITrustManager.aidl
index 6fbf87d2d335..0193711fd588 100644
--- a/core/java/android/app/trust/ITrustManager.aidl
+++ b/core/java/android/app/trust/ITrustManager.aidl
@@ -29,4 +29,5 @@ interface ITrustManager {
void reportRequireCredentialEntry(int userId);
void registerTrustListener(in ITrustListener trustListener);
void unregisterTrustListener(in ITrustListener trustListener);
+ boolean isTrusted(int userId);
}