Loading core/java/android/app/appfunctions/AppFunctionException.java +7 −3 Original line number Diff line number Diff line Loading @@ -162,9 +162,8 @@ public final class AppFunctionException extends Exception implements Parcelable } private AppFunctionException(@NonNull Parcel in) { mErrorCode = in.readInt(); mErrorMessage = in.readString8(); mExtras = Objects.requireNonNull(in.readBundle(getClass().getClassLoader())); this(/* errorCode= */ in.readInt(), /* errorMessage= */ in.readString8(), /* extras= */Objects.requireNonNull(in.readBundle(Bundle.class.getClassLoader()))); } /** Returns one of the {@code ERROR} constants. */ Loading Loading @@ -224,6 +223,11 @@ public final class AppFunctionException extends Exception implements Parcelable dest.writeBundle(mExtras); } @Override public @NonNull String getMessage() { return super.getMessage() + " (code " + mErrorCode + ")"; } /** * Error codes. * Loading services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceShellCommand.java +47 −31 Original line number Diff line number Diff line Loading @@ -108,12 +108,15 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { + ". Defaults to the current user."); pw.println(); if (accessCheckFlagsEnabled()) { pw.println( " grant-app-function-access --agent-package <AGENT_PACKAGE_NAME> " + "--target-package <TARGET_PACKAGE_NAME> [--agent-user <USER_ID>] " + "[--target-user <USER_ID>]"); pw.println(" Grants an agent package access to an app's functions."); pw.println(" --agent-package <AGENT_PACKAGE_NAME>: The agent package to grant access."); pw.println( " --agent-package <AGENT_PACKAGE_NAME>: The agent package to grant access."); pw.println(" --target-package <TARGET_PACKAGE_NAME>: The target package."); pw.println( " --agent-user <USER_ID> (optional): The user ID for the agent package. " Loading @@ -137,9 +140,9 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { pw.println( " --target-user <USER_ID> (optional): The user ID for the target package. " + "Defaults to the current user."); pw.println(); } } @Override public int onCommand(String cmd) { Loading @@ -156,8 +159,14 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { case "set-enabled": return runSetAppFunctionEnabled(); case "grant-app-function-access": if (!accessCheckFlagsEnabled()) { return -1; } return runGrantAppFunctionAccess(); case "revoke-app-function-access": if (!accessCheckFlagsEnabled()) { return -1; } return runRevokeAppFunctionAccess(); default: return handleDefaultCommands(cmd); Loading Loading @@ -388,7 +397,9 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { @Override public void onError(AppFunctionException e) { Log.d(TAG, "onError: ", e); pw.println("Error executing app function: " + e.getErrorCode() + " - " + e); pw.printf( "Error executing app function: %s. See logcat for more details. %n", e); resultCode.set(-1); countDownLatch.countDown(); } Loading Loading @@ -507,4 +518,9 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { default -> throw new IllegalAccessError("Only allow shell or root"); }; } private boolean accessCheckFlagsEnabled() { return android.permission.flags.Flags.appFunctionAccessApiEnabled() && android.permission.flags.Flags.appFunctionAccessServiceEnabled(); } } Loading
core/java/android/app/appfunctions/AppFunctionException.java +7 −3 Original line number Diff line number Diff line Loading @@ -162,9 +162,8 @@ public final class AppFunctionException extends Exception implements Parcelable } private AppFunctionException(@NonNull Parcel in) { mErrorCode = in.readInt(); mErrorMessage = in.readString8(); mExtras = Objects.requireNonNull(in.readBundle(getClass().getClassLoader())); this(/* errorCode= */ in.readInt(), /* errorMessage= */ in.readString8(), /* extras= */Objects.requireNonNull(in.readBundle(Bundle.class.getClassLoader()))); } /** Returns one of the {@code ERROR} constants. */ Loading Loading @@ -224,6 +223,11 @@ public final class AppFunctionException extends Exception implements Parcelable dest.writeBundle(mExtras); } @Override public @NonNull String getMessage() { return super.getMessage() + " (code " + mErrorCode + ")"; } /** * Error codes. * Loading
services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceShellCommand.java +47 −31 Original line number Diff line number Diff line Loading @@ -108,12 +108,15 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { + ". Defaults to the current user."); pw.println(); if (accessCheckFlagsEnabled()) { pw.println( " grant-app-function-access --agent-package <AGENT_PACKAGE_NAME> " + "--target-package <TARGET_PACKAGE_NAME> [--agent-user <USER_ID>] " + "[--target-user <USER_ID>]"); pw.println(" Grants an agent package access to an app's functions."); pw.println(" --agent-package <AGENT_PACKAGE_NAME>: The agent package to grant access."); pw.println( " --agent-package <AGENT_PACKAGE_NAME>: The agent package to grant access."); pw.println(" --target-package <TARGET_PACKAGE_NAME>: The target package."); pw.println( " --agent-user <USER_ID> (optional): The user ID for the agent package. " Loading @@ -137,9 +140,9 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { pw.println( " --target-user <USER_ID> (optional): The user ID for the target package. " + "Defaults to the current user."); pw.println(); } } @Override public int onCommand(String cmd) { Loading @@ -156,8 +159,14 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { case "set-enabled": return runSetAppFunctionEnabled(); case "grant-app-function-access": if (!accessCheckFlagsEnabled()) { return -1; } return runGrantAppFunctionAccess(); case "revoke-app-function-access": if (!accessCheckFlagsEnabled()) { return -1; } return runRevokeAppFunctionAccess(); default: return handleDefaultCommands(cmd); Loading Loading @@ -388,7 +397,9 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { @Override public void onError(AppFunctionException e) { Log.d(TAG, "onError: ", e); pw.println("Error executing app function: " + e.getErrorCode() + " - " + e); pw.printf( "Error executing app function: %s. See logcat for more details. %n", e); resultCode.set(-1); countDownLatch.countDown(); } Loading Loading @@ -507,4 +518,9 @@ public class AppFunctionManagerServiceShellCommand extends ShellCommand { default -> throw new IllegalAccessError("Only allow shell or root"); }; } private boolean accessCheckFlagsEnabled() { return android.permission.flags.Flags.appFunctionAccessApiEnabled() && android.permission.flags.Flags.appFunctionAccessServiceEnabled(); } }