Loading api/system-current.txt +4 −4 Original line number Diff line number Diff line Loading @@ -6322,8 +6322,8 @@ package android.service.attention { ctor public AttentionService(); method public final void disableSelf(); method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onCancelAttentionCheck(int); method public abstract void onCheckAttention(int, @NonNull android.service.attention.AttentionService.AttentionCallback); method public abstract void onCancelAttentionCheck(@NonNull android.service.attention.AttentionService.AttentionCallback); method public abstract void onCheckAttention(@NonNull android.service.attention.AttentionService.AttentionCallback); field public static final int ATTENTION_FAILURE_CAMERA_PERMISSION_ABSENT = 6; // 0x6 field public static final int ATTENTION_FAILURE_CANCELLED = 3; // 0x3 field public static final int ATTENTION_FAILURE_PREEMPTED = 4; // 0x4 Loading @@ -6335,8 +6335,8 @@ package android.service.attention { } public static final class AttentionService.AttentionCallback { method public void onFailure(int, int); method public void onSuccess(int, int, long); method public void onFailure(int); method public void onSuccess(int, long); } } Loading core/java/android/attention/AttentionManagerInternal.java +6 −12 Original line number Diff line number Diff line Loading @@ -30,25 +30,21 @@ public abstract class AttentionManagerInternal { /** * Checks whether user attention is at the screen and calls in the provided callback. * * @param requestCode a code associated with the attention check request; this code would be * used to call back in {@link AttentionCallbackInternal#onSuccess} and * {@link AttentionCallbackInternal#onFailure} * @param timeoutMillis a budget for the attention check; if it takes longer - {@link * AttentionCallbackInternal#onFailure} would be called with the {@link * android.service.attention.AttentionService#ATTENTION_FAILURE_TIMED_OUT} * code * @param callback a callback for when the attention check has completed * @return {@code true} if the attention check should succeed; {@false} otherwise. * @return {@code true} if the attention check should succeed. */ public abstract boolean checkAttention(int requestCode, long timeoutMillis, AttentionCallbackInternal callback); public abstract boolean checkAttention(long timeoutMillis, AttentionCallbackInternal callback); /** * Cancels the specified attention check in case it's no longer needed. * * @param requestCode a code provided during {@link #checkAttention} * @param callback a callback that was used in {@link #checkAttention} */ public abstract void cancelAttentionCheck(int requestCode); public abstract void cancelAttentionCheck(AttentionCallbackInternal callback); /** * Disables the dependants. Loading @@ -62,19 +58,17 @@ public abstract class AttentionManagerInternal { /** * Provides the result of the attention check, if the check was successful. * * @param requestCode a code provided in {@link #checkAttention} * @param result an int with the result of the check * @param timestamp a {@code SystemClock.uptimeMillis()} timestamp associated with the * attention check */ public abstract void onSuccess(int requestCode, int result, long timestamp); public abstract void onSuccess(int result, long timestamp); /** * Provides the explanation for why the attention check had failed. * * @param requestCode a code provided in {@link #checkAttention} * @param error an int with the reason for failure */ public abstract void onFailure(int requestCode, int error); public abstract void onFailure(int error); } } core/java/android/service/attention/AttentionService.java +27 −18 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ import java.lang.annotation.RetentionPolicy; * The system's default AttentionService implementation is configured in * {@code config_AttentionComponent}. If this config has no value, a stub is returned. * * See: {@link AttentionManagerService}. * See: {@link com.android.server.attention.AttentionManagerService}. * * <pre> * {@literal Loading Loading @@ -109,15 +109,16 @@ public abstract class AttentionService extends Service { /** {@inheritDoc} */ @Override public void checkAttention(int requestCode, IAttentionCallback callback) { public void checkAttention(IAttentionCallback callback) { Preconditions.checkNotNull(callback); AttentionService.this.onCheckAttention(requestCode, new AttentionCallback(callback)); AttentionService.this.onCheckAttention(new AttentionCallback(callback)); } /** {@inheritDoc} */ @Override public void cancelAttentionCheck(int requestCode) { AttentionService.this.onCancelAttentionCheck(requestCode); public void cancelAttentionCheck(IAttentionCallback callback) { Preconditions.checkNotNull(callback); AttentionService.this.onCancelAttentionCheck(new AttentionCallback(callback)); } }; Loading Loading @@ -146,35 +147,43 @@ public abstract class AttentionService extends Service { /** * Checks the user attention and calls into the provided callback. * * @param requestCode an identifier that could be used to cancel the request * @param callback the callback to return the result to */ public abstract void onCheckAttention(int requestCode, @NonNull AttentionCallback callback); public abstract void onCheckAttention(@NonNull AttentionCallback callback); /** Cancels the attention check for a given request code. */ public abstract void onCancelAttentionCheck(int requestCode); /** * Cancels pending work for a given callback. * * Implementation must call back with a failure code of {@link #ATTENTION_FAILURE_CANCELLED}. */ public abstract void onCancelAttentionCheck(@NonNull AttentionCallback callback); /** Callbacks for AttentionService results. */ public static final class AttentionCallback { private final IAttentionCallback mCallback; @NonNull private final IAttentionCallback mCallback; private AttentionCallback(IAttentionCallback callback) { private AttentionCallback(@NonNull IAttentionCallback callback) { mCallback = callback; } /** Returns the result. */ public void onSuccess(int requestCode, @AttentionSuccessCodes int result, long timestamp) { /** * Signals a success and provides the result code. * * @param timestamp of when the attention signal was computed; system throttles the requests * so this is useful to know how fresh the result is. */ public void onSuccess(@AttentionSuccessCodes int result, long timestamp) { try { mCallback.onSuccess(requestCode, result, timestamp); mCallback.onSuccess(result, timestamp); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } /** Signals a failure. */ public void onFailure(int requestCode, @AttentionFailureCodes int error) { /** Signals a failure and provides the error code. */ public void onFailure(@AttentionFailureCodes int error) { try { mCallback.onFailure(requestCode, error); mCallback.onFailure(error); } catch (RemoteException e) { e.rethrowFromSystemServer(); } Loading core/java/android/service/attention/IAttentionCallback.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,6 @@ package android.service.attention; * @hide */ oneway interface IAttentionCallback { void onSuccess(int requestCode, int result, long timestamp); void onFailure(int requestCode, int error); void onSuccess(int result, long timestamp); void onFailure(int error); } core/java/android/service/attention/IAttentionService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,6 @@ import android.service.attention.IAttentionCallback; * @hide */ oneway interface IAttentionService { void checkAttention(int requestCode, IAttentionCallback callback); void cancelAttentionCheck(int requestCode); void checkAttention(IAttentionCallback callback); void cancelAttentionCheck(IAttentionCallback callback); } No newline at end of file Loading
api/system-current.txt +4 −4 Original line number Diff line number Diff line Loading @@ -6322,8 +6322,8 @@ package android.service.attention { ctor public AttentionService(); method public final void disableSelf(); method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onCancelAttentionCheck(int); method public abstract void onCheckAttention(int, @NonNull android.service.attention.AttentionService.AttentionCallback); method public abstract void onCancelAttentionCheck(@NonNull android.service.attention.AttentionService.AttentionCallback); method public abstract void onCheckAttention(@NonNull android.service.attention.AttentionService.AttentionCallback); field public static final int ATTENTION_FAILURE_CAMERA_PERMISSION_ABSENT = 6; // 0x6 field public static final int ATTENTION_FAILURE_CANCELLED = 3; // 0x3 field public static final int ATTENTION_FAILURE_PREEMPTED = 4; // 0x4 Loading @@ -6335,8 +6335,8 @@ package android.service.attention { } public static final class AttentionService.AttentionCallback { method public void onFailure(int, int); method public void onSuccess(int, int, long); method public void onFailure(int); method public void onSuccess(int, long); } } Loading
core/java/android/attention/AttentionManagerInternal.java +6 −12 Original line number Diff line number Diff line Loading @@ -30,25 +30,21 @@ public abstract class AttentionManagerInternal { /** * Checks whether user attention is at the screen and calls in the provided callback. * * @param requestCode a code associated with the attention check request; this code would be * used to call back in {@link AttentionCallbackInternal#onSuccess} and * {@link AttentionCallbackInternal#onFailure} * @param timeoutMillis a budget for the attention check; if it takes longer - {@link * AttentionCallbackInternal#onFailure} would be called with the {@link * android.service.attention.AttentionService#ATTENTION_FAILURE_TIMED_OUT} * code * @param callback a callback for when the attention check has completed * @return {@code true} if the attention check should succeed; {@false} otherwise. * @return {@code true} if the attention check should succeed. */ public abstract boolean checkAttention(int requestCode, long timeoutMillis, AttentionCallbackInternal callback); public abstract boolean checkAttention(long timeoutMillis, AttentionCallbackInternal callback); /** * Cancels the specified attention check in case it's no longer needed. * * @param requestCode a code provided during {@link #checkAttention} * @param callback a callback that was used in {@link #checkAttention} */ public abstract void cancelAttentionCheck(int requestCode); public abstract void cancelAttentionCheck(AttentionCallbackInternal callback); /** * Disables the dependants. Loading @@ -62,19 +58,17 @@ public abstract class AttentionManagerInternal { /** * Provides the result of the attention check, if the check was successful. * * @param requestCode a code provided in {@link #checkAttention} * @param result an int with the result of the check * @param timestamp a {@code SystemClock.uptimeMillis()} timestamp associated with the * attention check */ public abstract void onSuccess(int requestCode, int result, long timestamp); public abstract void onSuccess(int result, long timestamp); /** * Provides the explanation for why the attention check had failed. * * @param requestCode a code provided in {@link #checkAttention} * @param error an int with the reason for failure */ public abstract void onFailure(int requestCode, int error); public abstract void onFailure(int error); } }
core/java/android/service/attention/AttentionService.java +27 −18 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ import java.lang.annotation.RetentionPolicy; * The system's default AttentionService implementation is configured in * {@code config_AttentionComponent}. If this config has no value, a stub is returned. * * See: {@link AttentionManagerService}. * See: {@link com.android.server.attention.AttentionManagerService}. * * <pre> * {@literal Loading Loading @@ -109,15 +109,16 @@ public abstract class AttentionService extends Service { /** {@inheritDoc} */ @Override public void checkAttention(int requestCode, IAttentionCallback callback) { public void checkAttention(IAttentionCallback callback) { Preconditions.checkNotNull(callback); AttentionService.this.onCheckAttention(requestCode, new AttentionCallback(callback)); AttentionService.this.onCheckAttention(new AttentionCallback(callback)); } /** {@inheritDoc} */ @Override public void cancelAttentionCheck(int requestCode) { AttentionService.this.onCancelAttentionCheck(requestCode); public void cancelAttentionCheck(IAttentionCallback callback) { Preconditions.checkNotNull(callback); AttentionService.this.onCancelAttentionCheck(new AttentionCallback(callback)); } }; Loading Loading @@ -146,35 +147,43 @@ public abstract class AttentionService extends Service { /** * Checks the user attention and calls into the provided callback. * * @param requestCode an identifier that could be used to cancel the request * @param callback the callback to return the result to */ public abstract void onCheckAttention(int requestCode, @NonNull AttentionCallback callback); public abstract void onCheckAttention(@NonNull AttentionCallback callback); /** Cancels the attention check for a given request code. */ public abstract void onCancelAttentionCheck(int requestCode); /** * Cancels pending work for a given callback. * * Implementation must call back with a failure code of {@link #ATTENTION_FAILURE_CANCELLED}. */ public abstract void onCancelAttentionCheck(@NonNull AttentionCallback callback); /** Callbacks for AttentionService results. */ public static final class AttentionCallback { private final IAttentionCallback mCallback; @NonNull private final IAttentionCallback mCallback; private AttentionCallback(IAttentionCallback callback) { private AttentionCallback(@NonNull IAttentionCallback callback) { mCallback = callback; } /** Returns the result. */ public void onSuccess(int requestCode, @AttentionSuccessCodes int result, long timestamp) { /** * Signals a success and provides the result code. * * @param timestamp of when the attention signal was computed; system throttles the requests * so this is useful to know how fresh the result is. */ public void onSuccess(@AttentionSuccessCodes int result, long timestamp) { try { mCallback.onSuccess(requestCode, result, timestamp); mCallback.onSuccess(result, timestamp); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } /** Signals a failure. */ public void onFailure(int requestCode, @AttentionFailureCodes int error) { /** Signals a failure and provides the error code. */ public void onFailure(@AttentionFailureCodes int error) { try { mCallback.onFailure(requestCode, error); mCallback.onFailure(error); } catch (RemoteException e) { e.rethrowFromSystemServer(); } Loading
core/java/android/service/attention/IAttentionCallback.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,6 @@ package android.service.attention; * @hide */ oneway interface IAttentionCallback { void onSuccess(int requestCode, int result, long timestamp); void onFailure(int requestCode, int error); void onSuccess(int result, long timestamp); void onFailure(int error); }
core/java/android/service/attention/IAttentionService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,6 @@ import android.service.attention.IAttentionCallback; * @hide */ oneway interface IAttentionService { void checkAttention(int requestCode, IAttentionCallback callback); void cancelAttentionCheck(int requestCode); void checkAttention(IAttentionCallback callback); void cancelAttentionCheck(IAttentionCallback callback); } No newline at end of file