Loading core/java/android/app/appfunctions/AppFunctionManager.java +22 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemService; import android.annotation.UserHandleAware; import android.app.appfunctions.AppFunctionManagerHelper.AppFunctionNotFoundException; import android.app.appsearch.AppSearchManager; import android.content.Context; import android.os.CancellationSignal; Loading Loading @@ -325,8 +326,28 @@ public final class AppFunctionManager { return; } // Wrap the callback to convert AppFunctionNotFoundException to IllegalArgumentException // to match the documentation. OutcomeReceiver<Boolean, Exception> callbackWithExceptionInterceptor = new OutcomeReceiver<>() { @Override public void onResult(@NonNull Boolean result) { callback.onResult(result); } @Override public void onError(@NonNull Exception exception) { if (exception instanceof AppFunctionNotFoundException) { exception = new IllegalArgumentException(exception); } callback.onError(exception); } }; AppFunctionManagerHelper.isAppFunctionEnabled( functionIdentifier, targetPackage, appSearchManager, executor, callback); functionIdentifier, targetPackage, appSearchManager, executor, callbackWithExceptionInterceptor); } private static class CallbackWrapper extends IAppFunctionEnabledCallback.Stub { Loading core/java/android/app/appfunctions/AppFunctionManagerHelper.java +14 −3 Original line number Diff line number Diff line Loading @@ -60,8 +60,8 @@ public class AppFunctionManagerHelper { * <p>If operation fails, the callback's {@link OutcomeReceiver#onError} is called with errors: * * <ul> * <li>{@link IllegalArgumentException}, if the function is not found or the caller does not * have access to it. * <li>{@link AppFunctionNotFoundException}, if the function is not found or the caller does * not have access to it. * </ul> * * @param functionIdentifier the identifier of the app function to check (unique within the Loading Loading @@ -216,7 +216,7 @@ public class AppFunctionManagerHelper { private static @NonNull Exception failedResultToException( @NonNull AppSearchResult appSearchResult) { return switch (appSearchResult.getResultCode()) { case AppSearchResult.RESULT_INVALID_ARGUMENT -> new IllegalArgumentException( case AppSearchResult.RESULT_INVALID_ARGUMENT -> new AppFunctionNotFoundException( appSearchResult.getErrorMessage()); case AppSearchResult.RESULT_IO_ERROR -> new IOException( appSearchResult.getErrorMessage()); Loading @@ -225,4 +225,15 @@ public class AppFunctionManagerHelper { default -> new IllegalStateException(appSearchResult.getErrorMessage()); }; } /** * Throws when the app function is not found. * * @hide */ public static class AppFunctionNotFoundException extends RuntimeException { private AppFunctionNotFoundException(@NonNull String errorMessage) { super(errorMessage); } } } services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +4 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.annotation.WorkerThread; import android.app.appfunctions.AppFunctionException; import android.app.appfunctions.AppFunctionManager; import android.app.appfunctions.AppFunctionManagerHelper; import android.app.appfunctions.AppFunctionManagerHelper.AppFunctionNotFoundException; import android.app.appfunctions.AppFunctionRuntimeMetadata; import android.app.appfunctions.AppFunctionStaticMetadataHelper; import android.app.appfunctions.ExecuteAppFunctionAidlRequest; Loading Loading @@ -513,7 +514,9 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { e = e.getCause(); } int resultCode = AppFunctionException.ERROR_SYSTEM_ERROR; if (e instanceof AppSearchException appSearchException) { if (e instanceof AppFunctionNotFoundException) { resultCode = AppFunctionException.ERROR_FUNCTION_NOT_FOUND; } else if (e instanceof AppSearchException appSearchException) { resultCode = mapAppSearchResultFailureCodeToExecuteAppFunctionResponse( appSearchException.getResultCode()); Loading Loading
core/java/android/app/appfunctions/AppFunctionManager.java +22 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemService; import android.annotation.UserHandleAware; import android.app.appfunctions.AppFunctionManagerHelper.AppFunctionNotFoundException; import android.app.appsearch.AppSearchManager; import android.content.Context; import android.os.CancellationSignal; Loading Loading @@ -325,8 +326,28 @@ public final class AppFunctionManager { return; } // Wrap the callback to convert AppFunctionNotFoundException to IllegalArgumentException // to match the documentation. OutcomeReceiver<Boolean, Exception> callbackWithExceptionInterceptor = new OutcomeReceiver<>() { @Override public void onResult(@NonNull Boolean result) { callback.onResult(result); } @Override public void onError(@NonNull Exception exception) { if (exception instanceof AppFunctionNotFoundException) { exception = new IllegalArgumentException(exception); } callback.onError(exception); } }; AppFunctionManagerHelper.isAppFunctionEnabled( functionIdentifier, targetPackage, appSearchManager, executor, callback); functionIdentifier, targetPackage, appSearchManager, executor, callbackWithExceptionInterceptor); } private static class CallbackWrapper extends IAppFunctionEnabledCallback.Stub { Loading
core/java/android/app/appfunctions/AppFunctionManagerHelper.java +14 −3 Original line number Diff line number Diff line Loading @@ -60,8 +60,8 @@ public class AppFunctionManagerHelper { * <p>If operation fails, the callback's {@link OutcomeReceiver#onError} is called with errors: * * <ul> * <li>{@link IllegalArgumentException}, if the function is not found or the caller does not * have access to it. * <li>{@link AppFunctionNotFoundException}, if the function is not found or the caller does * not have access to it. * </ul> * * @param functionIdentifier the identifier of the app function to check (unique within the Loading Loading @@ -216,7 +216,7 @@ public class AppFunctionManagerHelper { private static @NonNull Exception failedResultToException( @NonNull AppSearchResult appSearchResult) { return switch (appSearchResult.getResultCode()) { case AppSearchResult.RESULT_INVALID_ARGUMENT -> new IllegalArgumentException( case AppSearchResult.RESULT_INVALID_ARGUMENT -> new AppFunctionNotFoundException( appSearchResult.getErrorMessage()); case AppSearchResult.RESULT_IO_ERROR -> new IOException( appSearchResult.getErrorMessage()); Loading @@ -225,4 +225,15 @@ public class AppFunctionManagerHelper { default -> new IllegalStateException(appSearchResult.getErrorMessage()); }; } /** * Throws when the app function is not found. * * @hide */ public static class AppFunctionNotFoundException extends RuntimeException { private AppFunctionNotFoundException(@NonNull String errorMessage) { super(errorMessage); } } }
services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +4 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.annotation.WorkerThread; import android.app.appfunctions.AppFunctionException; import android.app.appfunctions.AppFunctionManager; import android.app.appfunctions.AppFunctionManagerHelper; import android.app.appfunctions.AppFunctionManagerHelper.AppFunctionNotFoundException; import android.app.appfunctions.AppFunctionRuntimeMetadata; import android.app.appfunctions.AppFunctionStaticMetadataHelper; import android.app.appfunctions.ExecuteAppFunctionAidlRequest; Loading Loading @@ -513,7 +514,9 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { e = e.getCause(); } int resultCode = AppFunctionException.ERROR_SYSTEM_ERROR; if (e instanceof AppSearchException appSearchException) { if (e instanceof AppFunctionNotFoundException) { resultCode = AppFunctionException.ERROR_FUNCTION_NOT_FOUND; } else if (e instanceof AppSearchException appSearchException) { resultCode = mapAppSearchResultFailureCodeToExecuteAppFunctionResponse( appSearchException.getResultCode()); Loading