Loading core/java/android/app/trust/ITrustListener.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,6 @@ package android.app.trust; * {@hide} */ oneway interface ITrustListener { void onTrustChanged(boolean enabled, int userId); void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser); void onTrustManagedChanged(boolean managed, int userId); } No newline at end of file core/java/android/app/trust/TrustManager.java +17 −7 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ public class TrustManager { private static final int MSG_TRUST_MANAGED_CHANGED = 2; private static final String TAG = "TrustManager"; private static final String DATA_INITIATED_BY_USER = "initiatedByUser"; private final ITrustManager mService; private final ArrayMap<TrustListener, ITrustListener> mTrustListeners; Loading Loading @@ -95,14 +96,17 @@ public class TrustManager { try { ITrustListener.Stub iTrustListener = new ITrustListener.Stub() { @Override public void onTrustChanged(boolean enabled, int userId) throws RemoteException { mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId, trustListener).sendToTarget(); public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { Message m = mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId, trustListener); if (initiatedByUser) { m.getData().putBoolean(DATA_INITIATED_BY_USER, initiatedByUser); } m.sendToTarget(); } @Override public void onTrustManagedChanged(boolean managed, int userId) throws RemoteException { public void onTrustManagedChanged(boolean managed, int userId) { mHandler.obtainMessage(MSG_TRUST_MANAGED_CHANGED, (managed ? 1 : 0), userId, trustListener).sendToTarget(); } Loading Loading @@ -139,7 +143,11 @@ public class TrustManager { public void handleMessage(Message msg) { switch(msg.what) { case MSG_TRUST_CHANGED: ((TrustListener)msg.obj).onTrustChanged(msg.arg1 != 0, msg.arg2); boolean initiatedByUser = msg.peekData() != null && msg.peekData().getBoolean(DATA_INITIATED_BY_USER); ((TrustListener)msg.obj).onTrustChanged( msg.arg1 != 0, msg.arg2, initiatedByUser); break; case MSG_TRUST_MANAGED_CHANGED: ((TrustListener)msg.obj).onTrustManagedChanged(msg.arg1 != 0, msg.arg2); Loading @@ -153,8 +161,10 @@ public class TrustManager { * Reports that the trust state has changed. * @param enabled if true, the system believes the environment to be trusted. * @param userId the user, for which the trust changed. * @param initiatedByUser indicates that the user has explicitly initiated an action that * proves the user is about to use the device. */ void onTrustChanged(boolean enabled, int userId); void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser); /** * Reports that whether trust is managed has changed Loading packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +4 −1 Original line number Diff line number Diff line Loading @@ -229,13 +229,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private SparseBooleanArray mUserFingerprintRecognized = new SparseBooleanArray(); @Override public void onTrustChanged(boolean enabled, int userId) { public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { mUserHasTrust.put(userId, enabled); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { cb.onTrustChanged(userId); if (enabled && initiatedByUser) { cb.onTrustInitiatedByUser(userId); } } } } Loading packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +5 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,11 @@ public class KeyguardUpdateMonitorCallback { */ public void onTrustManagedChanged(int userId) { } /** * Called when the user has proved to a trust agent that they want to use the device. */ public void onTrustInitiatedByUser(int userId) { } /** * Called when a fingerprint is recognized. * @param userId Loading services/core/java/com/android/server/trust/TrustAgentWrapper.java +5 −6 Original line number Diff line number Diff line Loading @@ -93,7 +93,6 @@ public class TrustAgentWrapper { mTrusted = true; mMessage = (CharSequence) msg.obj; boolean initiatedByUser = msg.arg1 != 0; // TODO: Handle initiatedByUser. long durationMs = msg.getData().getLong(DATA_DURATION); if (durationMs > 0) { mHandler.removeMessages(MSG_TRUST_TIMEOUT); Loading @@ -102,7 +101,7 @@ public class TrustAgentWrapper { mTrustManagerService.mArchive.logGrantTrust(mUserId, mName, (mMessage != null ? mMessage.toString() : null), durationMs, initiatedByUser); mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, initiatedByUser); break; case MSG_TRUST_TIMEOUT: if (DEBUG) Slog.v(TAG, "Trust timed out : " + mName.flattenToShortString()); Loading @@ -115,7 +114,7 @@ public class TrustAgentWrapper { if (msg.what == MSG_REVOKE_TRUST) { mTrustManagerService.mArchive.logRevokeTrust(mUserId, mName); } mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); break; case MSG_RESTART_TIMEOUT: unbind(); Loading @@ -130,7 +129,7 @@ public class TrustAgentWrapper { if (DEBUG) Log.v(TAG, "Re-enabling agent because it acknowledged " + "enabled features: " + mName); mTrustDisabledByDpm = false; mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); } } else { if (DEBUG) Log.w(TAG, "Ignoring MSG_SET_TRUST_AGENT_FEATURES_COMPLETED " Loading @@ -144,7 +143,7 @@ public class TrustAgentWrapper { mMessage = null; } mTrustManagerService.mArchive.logManagingTrust(mUserId, mName, mManagingTrust); mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); break; } } Loading Loading @@ -282,7 +281,7 @@ public class TrustAgentWrapper { } if (mTrustDisabledByDpm != trustDisabled) { mTrustDisabledByDpm = trustDisabled; mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); } return trustDisabled; } Loading Loading
core/java/android/app/trust/ITrustListener.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,6 @@ package android.app.trust; * {@hide} */ oneway interface ITrustListener { void onTrustChanged(boolean enabled, int userId); void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser); void onTrustManagedChanged(boolean managed, int userId); } No newline at end of file
core/java/android/app/trust/TrustManager.java +17 −7 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ public class TrustManager { private static final int MSG_TRUST_MANAGED_CHANGED = 2; private static final String TAG = "TrustManager"; private static final String DATA_INITIATED_BY_USER = "initiatedByUser"; private final ITrustManager mService; private final ArrayMap<TrustListener, ITrustListener> mTrustListeners; Loading Loading @@ -95,14 +96,17 @@ public class TrustManager { try { ITrustListener.Stub iTrustListener = new ITrustListener.Stub() { @Override public void onTrustChanged(boolean enabled, int userId) throws RemoteException { mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId, trustListener).sendToTarget(); public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { Message m = mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId, trustListener); if (initiatedByUser) { m.getData().putBoolean(DATA_INITIATED_BY_USER, initiatedByUser); } m.sendToTarget(); } @Override public void onTrustManagedChanged(boolean managed, int userId) throws RemoteException { public void onTrustManagedChanged(boolean managed, int userId) { mHandler.obtainMessage(MSG_TRUST_MANAGED_CHANGED, (managed ? 1 : 0), userId, trustListener).sendToTarget(); } Loading Loading @@ -139,7 +143,11 @@ public class TrustManager { public void handleMessage(Message msg) { switch(msg.what) { case MSG_TRUST_CHANGED: ((TrustListener)msg.obj).onTrustChanged(msg.arg1 != 0, msg.arg2); boolean initiatedByUser = msg.peekData() != null && msg.peekData().getBoolean(DATA_INITIATED_BY_USER); ((TrustListener)msg.obj).onTrustChanged( msg.arg1 != 0, msg.arg2, initiatedByUser); break; case MSG_TRUST_MANAGED_CHANGED: ((TrustListener)msg.obj).onTrustManagedChanged(msg.arg1 != 0, msg.arg2); Loading @@ -153,8 +161,10 @@ public class TrustManager { * Reports that the trust state has changed. * @param enabled if true, the system believes the environment to be trusted. * @param userId the user, for which the trust changed. * @param initiatedByUser indicates that the user has explicitly initiated an action that * proves the user is about to use the device. */ void onTrustChanged(boolean enabled, int userId); void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser); /** * Reports that whether trust is managed has changed Loading
packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +4 −1 Original line number Diff line number Diff line Loading @@ -229,13 +229,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private SparseBooleanArray mUserFingerprintRecognized = new SparseBooleanArray(); @Override public void onTrustChanged(boolean enabled, int userId) { public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { mUserHasTrust.put(userId, enabled); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { cb.onTrustChanged(userId); if (enabled && initiatedByUser) { cb.onTrustInitiatedByUser(userId); } } } } Loading
packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +5 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,11 @@ public class KeyguardUpdateMonitorCallback { */ public void onTrustManagedChanged(int userId) { } /** * Called when the user has proved to a trust agent that they want to use the device. */ public void onTrustInitiatedByUser(int userId) { } /** * Called when a fingerprint is recognized. * @param userId Loading
services/core/java/com/android/server/trust/TrustAgentWrapper.java +5 −6 Original line number Diff line number Diff line Loading @@ -93,7 +93,6 @@ public class TrustAgentWrapper { mTrusted = true; mMessage = (CharSequence) msg.obj; boolean initiatedByUser = msg.arg1 != 0; // TODO: Handle initiatedByUser. long durationMs = msg.getData().getLong(DATA_DURATION); if (durationMs > 0) { mHandler.removeMessages(MSG_TRUST_TIMEOUT); Loading @@ -102,7 +101,7 @@ public class TrustAgentWrapper { mTrustManagerService.mArchive.logGrantTrust(mUserId, mName, (mMessage != null ? mMessage.toString() : null), durationMs, initiatedByUser); mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, initiatedByUser); break; case MSG_TRUST_TIMEOUT: if (DEBUG) Slog.v(TAG, "Trust timed out : " + mName.flattenToShortString()); Loading @@ -115,7 +114,7 @@ public class TrustAgentWrapper { if (msg.what == MSG_REVOKE_TRUST) { mTrustManagerService.mArchive.logRevokeTrust(mUserId, mName); } mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); break; case MSG_RESTART_TIMEOUT: unbind(); Loading @@ -130,7 +129,7 @@ public class TrustAgentWrapper { if (DEBUG) Log.v(TAG, "Re-enabling agent because it acknowledged " + "enabled features: " + mName); mTrustDisabledByDpm = false; mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); } } else { if (DEBUG) Log.w(TAG, "Ignoring MSG_SET_TRUST_AGENT_FEATURES_COMPLETED " Loading @@ -144,7 +143,7 @@ public class TrustAgentWrapper { mMessage = null; } mTrustManagerService.mArchive.logManagingTrust(mUserId, mName, mManagingTrust); mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); break; } } Loading Loading @@ -282,7 +281,7 @@ public class TrustAgentWrapper { } if (mTrustDisabledByDpm != trustDisabled) { mTrustDisabledByDpm = trustDisabled; mTrustManagerService.updateTrust(mUserId); mTrustManagerService.updateTrust(mUserId, false); } return trustDisabled; } Loading