Add setManagingTrust and expose it on lockscreen

Adds a facility for trust agents to indicate if they
are ready to manage trust. Also adds an indication to
the lock icon on the lockscreen to show whether trust is
being managed.

Bug: 15518469
Bug: 16123013

Change-Id: Ie17f588aebeafe66c81dea4a69c733b0d2c72fd4
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
index c9e0db6..58196f7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
@@ -37,6 +37,7 @@
     private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
     private final ArrayList<OnUnlockMethodChangedListener> mListeners = new ArrayList<>();
     private boolean mMethodInsecure;
+    private boolean mTrustManaged;
 
     private UnlockMethodCache(Context ctx) {
         mLockPatternUtils = new LockPatternUtils(ctx);
@@ -71,9 +72,11 @@
         int user = mLockPatternUtils.getCurrentUser();
         boolean methodInsecure = !mLockPatternUtils.isSecure() ||
                 mKeyguardUpdateMonitor.getUserHasTrust(user);
-        boolean changed = methodInsecure != mMethodInsecure;
+        boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user);
+        boolean changed = methodInsecure != mMethodInsecure || trustManaged != mTrustManaged;
         if (changed || updateAlways) {
             mMethodInsecure = methodInsecure;
+            mTrustManaged = trustManaged;
             notifyListeners(mMethodInsecure);
         }
     }
@@ -96,15 +99,25 @@
         }
 
         @Override
+        public void onTrustManagedChanged(int userId) {
+            updateMethodSecure(false /* updateAlways */);
+        }
+
+        @Override
         public void onScreenTurnedOn() {
             updateMethodSecure(false /* updateAlways */);
         }
 
+        @Override
         public void onFingerprintRecognized(int userId) {
             updateMethodSecure(false /* updateAlways */);
         }
     };
 
+    public boolean isTrustManaged() {
+        return mTrustManaged;
+    }
+
     public static interface OnUnlockMethodChangedListener {
         void onMethodSecureChanged(boolean methodSecure);
     }