Loading api/system-current.txt +4 −1 Original line number Diff line number Diff line Loading @@ -30942,7 +30942,8 @@ package android.service.trust { public class TrustAgentService extends android.app.Service { ctor public TrustAgentService(); method public final void grantTrust(java.lang.CharSequence, long, boolean); method public final deprecated void grantTrust(java.lang.CharSequence, long, boolean); method public final void grantTrust(java.lang.CharSequence, long, int); method public final android.os.IBinder onBind(android.content.Intent); method public boolean onConfigure(java.util.List<android.os.PersistableBundle>); method public void onDeviceLocked(); Loading @@ -30951,6 +30952,8 @@ package android.service.trust { method public void onUnlockAttempt(boolean); method public final void revokeTrust(); method public final void setManagingTrust(boolean); field public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 2; // 0x2 field public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1; // 0x1 field public static final java.lang.String SERVICE_INTERFACE = "android.service.trust.TrustAgentService"; field public static final java.lang.String TRUST_AGENT_META_DATA = "android.service.trust.trustagent"; } 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, boolean initiatedByUser); void onTrustChanged(boolean enabled, int userId, int flags); void onTrustManagedChanged(boolean managed, int userId); } No newline at end of file core/java/android/app/trust/TrustManager.java +10 −12 Original line number Diff line number Diff line Loading @@ -34,7 +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 static final String DATA_FLAGS = "initiatedByUser"; private final ITrustManager mService; private final ArrayMap<TrustListener, ITrustListener> mTrustListeners; Loading Loading @@ -109,11 +109,11 @@ public class TrustManager { try { ITrustListener.Stub iTrustListener = new ITrustListener.Stub() { @Override public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { public void onTrustChanged(boolean enabled, int userId, int flags) { Message m = mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId, trustListener); if (initiatedByUser) { m.getData().putBoolean(DATA_INITIATED_BY_USER, initiatedByUser); if (flags != 0) { m.getData().putInt(DATA_FLAGS, flags); } m.sendToTarget(); } Loading Loading @@ -156,11 +156,8 @@ public class TrustManager { public void handleMessage(Message msg) { switch(msg.what) { case MSG_TRUST_CHANGED: boolean initiatedByUser = msg.peekData() != null && msg.peekData().getBoolean(DATA_INITIATED_BY_USER); ((TrustListener)msg.obj).onTrustChanged( msg.arg1 != 0, msg.arg2, initiatedByUser); int flags = msg.peekData() != null ? msg.peekData().getInt(DATA_FLAGS) : 0; ((TrustListener)msg.obj).onTrustChanged(msg.arg1 != 0, msg.arg2, flags); break; case MSG_TRUST_MANAGED_CHANGED: ((TrustListener)msg.obj).onTrustManagedChanged(msg.arg1 != 0, msg.arg2); Loading @@ -174,10 +171,11 @@ 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. * @param flags flags specified by the trust agent when granting trust. See * {@link android.service.trust.TrustAgentService#grantTrust(CharSequence, long, int) * TrustAgentService.grantTrust(CharSequence, long, int)}. */ void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser); void onTrustChanged(boolean enabled, int userId, int flags); /** * Reports that whether trust is managed has changed Loading core/java/android/service/trust/ITrustAgentServiceCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import android.os.UserHandle; * @hide */ oneway interface ITrustAgentServiceCallback { void grantTrust(CharSequence message, long durationMs, boolean initiatedByUser); void grantTrust(CharSequence message, long durationMs, int flags); void revokeTrust(); void setManagingTrust(boolean managingTrust); void onConfigureCompleted(boolean result, IBinder token); Loading core/java/android/service/trust/TrustAgentService.java +59 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.service.trust; import android.Manifest; import android.annotation.IntDef; import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.app.Service; Loading @@ -32,6 +33,8 @@ import android.os.RemoteException; import android.util.Log; import android.util.Slog; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** Loading Loading @@ -69,6 +72,7 @@ import java.util.List; */ @SystemApi public class TrustAgentService extends Service { private final String TAG = TrustAgentService.class.getSimpleName() + "[" + getClass().getSimpleName() + "]"; private static final boolean DEBUG = false; Loading @@ -86,6 +90,34 @@ public class TrustAgentService extends Service { */ public static final String TRUST_AGENT_META_DATA = "android.service.trust.trustagent"; /** * Flag for {@link #grantTrust(CharSequence, long, int)} indicating that trust is being granted * as the direct result of user action - such as solving a security challenge. The hint is used * by the system to optimize the experience. Behavior may vary by device and release, so * one should only set this parameter if it meets the above criteria rather than relying on * the behavior of any particular device or release. */ public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1 << 0; /** * Flag for {@link #grantTrust(CharSequence, long, int)} indicating that the agent would like * to dismiss the keyguard. When using this flag, the {@code TrustAgentService} must ensure * it is only set in response to a direct user action with the expectation of dismissing the * keyguard. */ public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 1 << 1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = { FLAG_GRANT_TRUST_INITIATED_BY_USER, FLAG_GRANT_TRUST_DISMISS_KEYGUARD, }) public @interface GrantTrustFlags {} private static final int MSG_UNLOCK_ATTEMPT = 1; private static final int MSG_CONFIGURE = 2; private static final int MSG_TRUST_TIMEOUT = 3; Loading Loading @@ -228,11 +260,35 @@ public class TrustAgentService extends Service { * direct result of user action - such as solving a security challenge. The hint is used * by the system to optimize the experience. Behavior may vary by device and release, so * one should only set this parameter if it meets the above criteria rather than relying on * the behavior of any particular device or release. * the behavior of any particular device or release. Corresponds to * {@link #FLAG_GRANT_TRUST_INITIATED_BY_USER}. * @throws IllegalStateException if the agent is not currently managing trust. * * @deprecated use {@link #grantTrust(CharSequence, long, int)} instead. */ @Deprecated public final void grantTrust( final CharSequence message, final long durationMs, final boolean initiatedByUser) { grantTrust(message, durationMs, initiatedByUser ? FLAG_GRANT_TRUST_INITIATED_BY_USER : 0); } /** * Call to grant trust on the device. * * @param message describes why the device is trusted, e.g. "Trusted by location". * @param durationMs amount of time in milliseconds to keep the device in a trusted state. * Trust for this agent will automatically be revoked when the timeout expires unless * extended by a subsequent call to this function. The timeout is measured from the * invocation of this function as dictated by {@link SystemClock#elapsedRealtime())}. * For security reasons, the value should be no larger than necessary. * The value may be adjusted by the system as necessary to comply with a policy controlled * by the system or {@link DevicePolicyManager} restrictions. See {@link #onTrustTimeout()} * for determining when trust expires. * @param flags TBDocumented * @throws IllegalStateException if the agent is not currently managing trust. */ public final void grantTrust( final CharSequence message, final long durationMs, @GrantTrustFlags final int flags) { synchronized (mLock) { if (!mManagingTrust) { throw new IllegalStateException("Cannot grant trust if agent is not managing trust." Loading @@ -240,7 +296,7 @@ public class TrustAgentService extends Service { } if (mCallback != null) { try { mCallback.grantTrust(message.toString(), durationMs, initiatedByUser); mCallback.grantTrust(message.toString(), durationMs, flags); } catch (RemoteException e) { onError("calling enableTrust()"); } Loading @@ -250,7 +306,7 @@ public class TrustAgentService extends Service { mPendingGrantTrustTask = new Runnable() { @Override public void run() { grantTrust(message, durationMs, initiatedByUser); grantTrust(message, durationMs, flags); } }; } Loading Loading
api/system-current.txt +4 −1 Original line number Diff line number Diff line Loading @@ -30942,7 +30942,8 @@ package android.service.trust { public class TrustAgentService extends android.app.Service { ctor public TrustAgentService(); method public final void grantTrust(java.lang.CharSequence, long, boolean); method public final deprecated void grantTrust(java.lang.CharSequence, long, boolean); method public final void grantTrust(java.lang.CharSequence, long, int); method public final android.os.IBinder onBind(android.content.Intent); method public boolean onConfigure(java.util.List<android.os.PersistableBundle>); method public void onDeviceLocked(); Loading @@ -30951,6 +30952,8 @@ package android.service.trust { method public void onUnlockAttempt(boolean); method public final void revokeTrust(); method public final void setManagingTrust(boolean); field public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 2; // 0x2 field public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1; // 0x1 field public static final java.lang.String SERVICE_INTERFACE = "android.service.trust.TrustAgentService"; field public static final java.lang.String TRUST_AGENT_META_DATA = "android.service.trust.trustagent"; }
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, boolean initiatedByUser); void onTrustChanged(boolean enabled, int userId, int flags); void onTrustManagedChanged(boolean managed, int userId); } No newline at end of file
core/java/android/app/trust/TrustManager.java +10 −12 Original line number Diff line number Diff line Loading @@ -34,7 +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 static final String DATA_FLAGS = "initiatedByUser"; private final ITrustManager mService; private final ArrayMap<TrustListener, ITrustListener> mTrustListeners; Loading Loading @@ -109,11 +109,11 @@ public class TrustManager { try { ITrustListener.Stub iTrustListener = new ITrustListener.Stub() { @Override public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { public void onTrustChanged(boolean enabled, int userId, int flags) { Message m = mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId, trustListener); if (initiatedByUser) { m.getData().putBoolean(DATA_INITIATED_BY_USER, initiatedByUser); if (flags != 0) { m.getData().putInt(DATA_FLAGS, flags); } m.sendToTarget(); } Loading Loading @@ -156,11 +156,8 @@ public class TrustManager { public void handleMessage(Message msg) { switch(msg.what) { case MSG_TRUST_CHANGED: boolean initiatedByUser = msg.peekData() != null && msg.peekData().getBoolean(DATA_INITIATED_BY_USER); ((TrustListener)msg.obj).onTrustChanged( msg.arg1 != 0, msg.arg2, initiatedByUser); int flags = msg.peekData() != null ? msg.peekData().getInt(DATA_FLAGS) : 0; ((TrustListener)msg.obj).onTrustChanged(msg.arg1 != 0, msg.arg2, flags); break; case MSG_TRUST_MANAGED_CHANGED: ((TrustListener)msg.obj).onTrustManagedChanged(msg.arg1 != 0, msg.arg2); Loading @@ -174,10 +171,11 @@ 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. * @param flags flags specified by the trust agent when granting trust. See * {@link android.service.trust.TrustAgentService#grantTrust(CharSequence, long, int) * TrustAgentService.grantTrust(CharSequence, long, int)}. */ void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser); void onTrustChanged(boolean enabled, int userId, int flags); /** * Reports that whether trust is managed has changed Loading
core/java/android/service/trust/ITrustAgentServiceCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import android.os.UserHandle; * @hide */ oneway interface ITrustAgentServiceCallback { void grantTrust(CharSequence message, long durationMs, boolean initiatedByUser); void grantTrust(CharSequence message, long durationMs, int flags); void revokeTrust(); void setManagingTrust(boolean managingTrust); void onConfigureCompleted(boolean result, IBinder token); Loading
core/java/android/service/trust/TrustAgentService.java +59 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.service.trust; import android.Manifest; import android.annotation.IntDef; import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.app.Service; Loading @@ -32,6 +33,8 @@ import android.os.RemoteException; import android.util.Log; import android.util.Slog; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** Loading Loading @@ -69,6 +72,7 @@ import java.util.List; */ @SystemApi public class TrustAgentService extends Service { private final String TAG = TrustAgentService.class.getSimpleName() + "[" + getClass().getSimpleName() + "]"; private static final boolean DEBUG = false; Loading @@ -86,6 +90,34 @@ public class TrustAgentService extends Service { */ public static final String TRUST_AGENT_META_DATA = "android.service.trust.trustagent"; /** * Flag for {@link #grantTrust(CharSequence, long, int)} indicating that trust is being granted * as the direct result of user action - such as solving a security challenge. The hint is used * by the system to optimize the experience. Behavior may vary by device and release, so * one should only set this parameter if it meets the above criteria rather than relying on * the behavior of any particular device or release. */ public static final int FLAG_GRANT_TRUST_INITIATED_BY_USER = 1 << 0; /** * Flag for {@link #grantTrust(CharSequence, long, int)} indicating that the agent would like * to dismiss the keyguard. When using this flag, the {@code TrustAgentService} must ensure * it is only set in response to a direct user action with the expectation of dismissing the * keyguard. */ public static final int FLAG_GRANT_TRUST_DISMISS_KEYGUARD = 1 << 1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = { FLAG_GRANT_TRUST_INITIATED_BY_USER, FLAG_GRANT_TRUST_DISMISS_KEYGUARD, }) public @interface GrantTrustFlags {} private static final int MSG_UNLOCK_ATTEMPT = 1; private static final int MSG_CONFIGURE = 2; private static final int MSG_TRUST_TIMEOUT = 3; Loading Loading @@ -228,11 +260,35 @@ public class TrustAgentService extends Service { * direct result of user action - such as solving a security challenge. The hint is used * by the system to optimize the experience. Behavior may vary by device and release, so * one should only set this parameter if it meets the above criteria rather than relying on * the behavior of any particular device or release. * the behavior of any particular device or release. Corresponds to * {@link #FLAG_GRANT_TRUST_INITIATED_BY_USER}. * @throws IllegalStateException if the agent is not currently managing trust. * * @deprecated use {@link #grantTrust(CharSequence, long, int)} instead. */ @Deprecated public final void grantTrust( final CharSequence message, final long durationMs, final boolean initiatedByUser) { grantTrust(message, durationMs, initiatedByUser ? FLAG_GRANT_TRUST_INITIATED_BY_USER : 0); } /** * Call to grant trust on the device. * * @param message describes why the device is trusted, e.g. "Trusted by location". * @param durationMs amount of time in milliseconds to keep the device in a trusted state. * Trust for this agent will automatically be revoked when the timeout expires unless * extended by a subsequent call to this function. The timeout is measured from the * invocation of this function as dictated by {@link SystemClock#elapsedRealtime())}. * For security reasons, the value should be no larger than necessary. * The value may be adjusted by the system as necessary to comply with a policy controlled * by the system or {@link DevicePolicyManager} restrictions. See {@link #onTrustTimeout()} * for determining when trust expires. * @param flags TBDocumented * @throws IllegalStateException if the agent is not currently managing trust. */ public final void grantTrust( final CharSequence message, final long durationMs, @GrantTrustFlags final int flags) { synchronized (mLock) { if (!mManagingTrust) { throw new IllegalStateException("Cannot grant trust if agent is not managing trust." Loading @@ -240,7 +296,7 @@ public class TrustAgentService extends Service { } if (mCallback != null) { try { mCallback.grantTrust(message.toString(), durationMs, initiatedByUser); mCallback.grantTrust(message.toString(), durationMs, flags); } catch (RemoteException e) { onError("calling enableTrust()"); } Loading @@ -250,7 +306,7 @@ public class TrustAgentService extends Service { mPendingGrantTrustTask = new Runnable() { @Override public void run() { grantTrust(message, durationMs, initiatedByUser); grantTrust(message, durationMs, flags); } }; } Loading