Loading core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -8822,6 +8822,7 @@ package android.app.appfunctions { field @NonNull public static final android.os.Parcelable.Creator<android.app.appfunctions.ExecuteAppFunctionResponse> CREATOR; field public static final String PROPERTY_RETURN_VALUE = "returnValue"; field public static final int RESULT_APP_UNKNOWN_ERROR = 2; // 0x2 field public static final int RESULT_CANCELLED = 7; // 0x7 field public static final int RESULT_DENIED = 1; // 0x1 field public static final int RESULT_DISABLED = 6; // 0x6 field public static final int RESULT_INTERNAL_ERROR = 3; // 0x3 core/java/android/app/appfunctions/ExecuteAppFunctionResponse.java +7 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,12 @@ public final class ExecuteAppFunctionResponse implements Parcelable { /** The caller tried to execute a disabled app function. */ public static final int RESULT_DISABLED = 6; /** * The operation was cancelled. Use this error code to report that a cancellation is done after * receiving a cancellation signal. */ public static final int RESULT_CANCELLED = 7; /** The result code of the app function execution. */ @ResultCode private final int mResultCode; Loading Loading @@ -278,6 +284,7 @@ public final class ExecuteAppFunctionResponse implements Parcelable { RESULT_INVALID_ARGUMENT, RESULT_TIMED_OUT, RESULT_DISABLED, RESULT_CANCELLED }) @Retention(RetentionPolicy.SOURCE) public @interface ResultCode {} Loading core/java/android/app/appfunctions/SafeOneTimeExecuteAppFunctionCallback.java +8 −0 Original line number Diff line number Diff line Loading @@ -72,4 +72,12 @@ public class SafeOneTimeExecuteAppFunctionCallback { mOnDispatchCallback.accept(result); } } /** * Disables this callback. Subsequent calls to {@link #onResult(ExecuteAppFunctionResponse)} * will be ignored. */ public void disable() { mOnResultCalled.set(true); } } services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +10 −0 Original line number Diff line number Diff line Loading @@ -430,6 +430,8 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { serviceIntent, bindFlags, targetUser, mServiceConfig.getExecuteAppFunctionCancellationTimeoutMillis(), cancellationSignal, new RunServiceCallCallback<IAppFunctionService>() { @Override public void onServiceConnected( Loading Loading @@ -470,6 +472,14 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { "Failed to connect to AppFunctionService", /* extras= */ null)); } @Override public void onCancelled() { // Do not forward the result back to the caller once it has been // canceled. The caller does not need a notification and should // proceed after initiating a cancellation. safeExecuteAppFunctionCallback.disable(); } }); if (!bindServiceResult) { Loading services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java +18 −7 Original line number Diff line number Diff line Loading @@ -17,12 +17,13 @@ package com.android.server.appfunctions; import android.annotation.NonNull; import android.content.Intent; import android.os.CancellationSignal; import android.os.UserHandle; /** * Defines a contract for establishing temporary connections to services and executing operations * within a specified timeout. Implementations of this interface provide mechanisms to ensure that * services are properly unbound after the operation completes or a timeout occurs. * Defines a contract for establishing temporary connections to services and executing operations. * Implementations of this interface provide mechanisms to ensure that services are properly unbound * after the operation completes or a cancellation timeout occurs. * * @param <T> Class of wrapped service. */ Loading @@ -30,20 +31,25 @@ public interface RemoteServiceCaller<T> { /** * Initiates service binding and executes a provided method when the service connects. Unbinds * the service after execution or upon timeout. Returns the result of the bindService API. * the service after execution or upon cancellation timeout. Returns the result of the * bindService API. * * <p>When the service connection was made successfully, it's the caller responsibility to * report the usage is completed and can be unbound by calling {@link * ServiceUsageCompleteListener#onCompleted()}. * * <p>This method includes a timeout mechanism to prevent the system from being stuck in a state * where a service is bound indefinitely (for example, if the binder method never returns). This * helps ensure that the calling app does not remain alive unnecessarily. * <p>This method includes a timeout mechanism for cancellation to prevent the system from being * stuck in a state where a service is bound indefinitely. If the app to be bound does not * return the result within `cancellationTimeoutMillis` after the cancellation signal is sent, * this method will unbind the service connection. * * @param intent An Intent object that describes the service that should be bound. * @param bindFlags Flags used to control the binding process See {@link * android.content.Context#bindService}. * @param userHandle The UserHandle of the user for which the service should be bound. * @param cancellationTimeoutMillis The timeout before the service is unbound after a * cancellation signal is issued. * @param cancellationSignal The cancellation signal forwarded to the service. * @param callback A callback to be invoked for various events. See {@link * RunServiceCallCallback}. */ Loading @@ -51,6 +57,8 @@ public interface RemoteServiceCaller<T> { @NonNull Intent intent, int bindFlags, @NonNull UserHandle userHandle, long cancellationTimeoutMillis, @NonNull CancellationSignal cancellationSignal, @NonNull RunServiceCallCallback<T> callback); /** An interface for clients to signal that they have finished using a bound service. */ Loading @@ -73,5 +81,8 @@ public interface RemoteServiceCaller<T> { /** Called when the service connection was failed to establish. */ void onFailedToConnect(); /** Called when the caller has cancelled this remote service call. */ void onCancelled(); } } Loading
core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -8822,6 +8822,7 @@ package android.app.appfunctions { field @NonNull public static final android.os.Parcelable.Creator<android.app.appfunctions.ExecuteAppFunctionResponse> CREATOR; field public static final String PROPERTY_RETURN_VALUE = "returnValue"; field public static final int RESULT_APP_UNKNOWN_ERROR = 2; // 0x2 field public static final int RESULT_CANCELLED = 7; // 0x7 field public static final int RESULT_DENIED = 1; // 0x1 field public static final int RESULT_DISABLED = 6; // 0x6 field public static final int RESULT_INTERNAL_ERROR = 3; // 0x3
core/java/android/app/appfunctions/ExecuteAppFunctionResponse.java +7 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,12 @@ public final class ExecuteAppFunctionResponse implements Parcelable { /** The caller tried to execute a disabled app function. */ public static final int RESULT_DISABLED = 6; /** * The operation was cancelled. Use this error code to report that a cancellation is done after * receiving a cancellation signal. */ public static final int RESULT_CANCELLED = 7; /** The result code of the app function execution. */ @ResultCode private final int mResultCode; Loading Loading @@ -278,6 +284,7 @@ public final class ExecuteAppFunctionResponse implements Parcelable { RESULT_INVALID_ARGUMENT, RESULT_TIMED_OUT, RESULT_DISABLED, RESULT_CANCELLED }) @Retention(RetentionPolicy.SOURCE) public @interface ResultCode {} Loading
core/java/android/app/appfunctions/SafeOneTimeExecuteAppFunctionCallback.java +8 −0 Original line number Diff line number Diff line Loading @@ -72,4 +72,12 @@ public class SafeOneTimeExecuteAppFunctionCallback { mOnDispatchCallback.accept(result); } } /** * Disables this callback. Subsequent calls to {@link #onResult(ExecuteAppFunctionResponse)} * will be ignored. */ public void disable() { mOnResultCalled.set(true); } }
services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +10 −0 Original line number Diff line number Diff line Loading @@ -430,6 +430,8 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { serviceIntent, bindFlags, targetUser, mServiceConfig.getExecuteAppFunctionCancellationTimeoutMillis(), cancellationSignal, new RunServiceCallCallback<IAppFunctionService>() { @Override public void onServiceConnected( Loading Loading @@ -470,6 +472,14 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { "Failed to connect to AppFunctionService", /* extras= */ null)); } @Override public void onCancelled() { // Do not forward the result back to the caller once it has been // canceled. The caller does not need a notification and should // proceed after initiating a cancellation. safeExecuteAppFunctionCallback.disable(); } }); if (!bindServiceResult) { Loading
services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java +18 −7 Original line number Diff line number Diff line Loading @@ -17,12 +17,13 @@ package com.android.server.appfunctions; import android.annotation.NonNull; import android.content.Intent; import android.os.CancellationSignal; import android.os.UserHandle; /** * Defines a contract for establishing temporary connections to services and executing operations * within a specified timeout. Implementations of this interface provide mechanisms to ensure that * services are properly unbound after the operation completes or a timeout occurs. * Defines a contract for establishing temporary connections to services and executing operations. * Implementations of this interface provide mechanisms to ensure that services are properly unbound * after the operation completes or a cancellation timeout occurs. * * @param <T> Class of wrapped service. */ Loading @@ -30,20 +31,25 @@ public interface RemoteServiceCaller<T> { /** * Initiates service binding and executes a provided method when the service connects. Unbinds * the service after execution or upon timeout. Returns the result of the bindService API. * the service after execution or upon cancellation timeout. Returns the result of the * bindService API. * * <p>When the service connection was made successfully, it's the caller responsibility to * report the usage is completed and can be unbound by calling {@link * ServiceUsageCompleteListener#onCompleted()}. * * <p>This method includes a timeout mechanism to prevent the system from being stuck in a state * where a service is bound indefinitely (for example, if the binder method never returns). This * helps ensure that the calling app does not remain alive unnecessarily. * <p>This method includes a timeout mechanism for cancellation to prevent the system from being * stuck in a state where a service is bound indefinitely. If the app to be bound does not * return the result within `cancellationTimeoutMillis` after the cancellation signal is sent, * this method will unbind the service connection. * * @param intent An Intent object that describes the service that should be bound. * @param bindFlags Flags used to control the binding process See {@link * android.content.Context#bindService}. * @param userHandle The UserHandle of the user for which the service should be bound. * @param cancellationTimeoutMillis The timeout before the service is unbound after a * cancellation signal is issued. * @param cancellationSignal The cancellation signal forwarded to the service. * @param callback A callback to be invoked for various events. See {@link * RunServiceCallCallback}. */ Loading @@ -51,6 +57,8 @@ public interface RemoteServiceCaller<T> { @NonNull Intent intent, int bindFlags, @NonNull UserHandle userHandle, long cancellationTimeoutMillis, @NonNull CancellationSignal cancellationSignal, @NonNull RunServiceCallCallback<T> callback); /** An interface for clients to signal that they have finished using a bound service. */ Loading @@ -73,5 +81,8 @@ public interface RemoteServiceCaller<T> { /** Called when the service connection was failed to establish. */ void onFailedToConnect(); /** Called when the caller has cancelled this remote service call. */ void onCancelled(); } }