Merge "Resolve some TODOs in appfunctions" into main
diff --git a/core/java/android/app/appfunctions/AppFunctionManager.java b/core/java/android/app/appfunctions/AppFunctionManager.java
index 4b6f406..b6240a7 100644
--- a/core/java/android/app/appfunctions/AppFunctionManager.java
+++ b/core/java/android/app/appfunctions/AppFunctionManager.java
@@ -54,9 +54,9 @@
*
* @hide
*/
- public AppFunctionManager(IAppFunctionManager mService, Context context) {
- this.mService = mService;
- this.mContext = context;
+ public AppFunctionManager(IAppFunctionManager service, Context context) {
+ mService = service;
+ mContext = context;
}
/**
@@ -114,7 +114,7 @@
}
});
} catch (RemoteException e) {
- e.rethrowFromSystemServer();
+ throw e.rethrowFromSystemServer();
}
}
}
diff --git a/core/java/android/app/appfunctions/IAppFunctionManager.aidl b/core/java/android/app/appfunctions/IAppFunctionManager.aidl
index ef37095..28827bb 100644
--- a/core/java/android/app/appfunctions/IAppFunctionManager.aidl
+++ b/core/java/android/app/appfunctions/IAppFunctionManager.aidl
@@ -31,6 +31,7 @@
* @param request the request to execute an app function.
* @param callback the callback to report the result.
*/
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(anyOf = {android.Manifest.permission.EXECUTE_APP_FUNCTIONS_TRUSTED,android.Manifest.permission.EXECUTE_APP_FUNCTIONS}, conditional = true)")
void executeAppFunction(
in ExecuteAppFunctionAidlRequest request,
in IExecuteAppFunctionCallback callback
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
index 191ec69..6b8e8c7 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
@@ -23,10 +23,6 @@
import android.app.appfunctions.IAppFunctionService;
import android.app.appfunctions.IExecuteAppFunctionCallback;
import android.app.appfunctions.SafeOneTimeExecuteAppFunctionCallback;
-import android.app.appfunctions.ServiceCallHelper;
-import android.app.appfunctions.ServiceCallHelper.RunServiceCallCallback;
-import android.app.appfunctions.ServiceCallHelper.ServiceUsageCompleteListener;
-import android.app.appfunctions.ServiceCallHelperImpl;
import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
@@ -34,6 +30,8 @@
import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.appfunctions.RemoteServiceCaller.RunServiceCallCallback;
+import com.android.server.appfunctions.RemoteServiceCaller.ServiceUsageCompleteListener;
import java.util.Objects;
import java.util.concurrent.LinkedBlockingQueue;
@@ -45,12 +43,12 @@
*/
public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
private static final String TAG = AppFunctionManagerServiceImpl.class.getSimpleName();
- private final ServiceCallHelper<IAppFunctionService> mExternalServiceCallHelper;
+ private final RemoteServiceCaller<IAppFunctionService> mRemoteServiceCaller;
private final CallerValidator mCallerValidator;
private final ServiceHelper mInternalServiceHelper;
public AppFunctionManagerServiceImpl(@NonNull Context context) {
- this(new ServiceCallHelperImpl<>(
+ this(new RemoteServiceCallerImpl<>(
context,
IAppFunctionService.Stub::asInterface, new ThreadPoolExecutor(
/*corePoolSize=*/ Runtime.getRuntime().availableProcessors(),
@@ -63,11 +61,11 @@
}
@VisibleForTesting
- AppFunctionManagerServiceImpl(ServiceCallHelper<IAppFunctionService> serviceCallHelper,
- CallerValidator apiValidator,
+ AppFunctionManagerServiceImpl(RemoteServiceCaller<IAppFunctionService> remoteServiceCaller,
+ CallerValidator callerValidator,
ServiceHelper appFunctionInternalServiceHelper) {
- mExternalServiceCallHelper = Objects.requireNonNull(serviceCallHelper);
- mCallerValidator = Objects.requireNonNull(apiValidator);
+ mRemoteServiceCaller = Objects.requireNonNull(remoteServiceCaller);
+ mCallerValidator = Objects.requireNonNull(callerValidator);
mInternalServiceHelper =
Objects.requireNonNull(appFunctionInternalServiceHelper);
}
@@ -134,7 +132,6 @@
return;
}
- // TODO(b/357551503): Offload call to async executor.
bindAppFunctionServiceUnchecked(requestInternal, serviceIntent, targetUser,
safeExecuteAppFunctionCallback,
/*bindFlags=*/ Context.BIND_AUTO_CREATE,
@@ -148,12 +145,12 @@
@NonNull SafeOneTimeExecuteAppFunctionCallback
safeExecuteAppFunctionCallback,
int bindFlags, long timeoutInMillis) {
- boolean bindServiceResult = mExternalServiceCallHelper.runServiceCall(
+ boolean bindServiceResult = mRemoteServiceCaller.runServiceCall(
serviceIntent,
bindFlags,
timeoutInMillis,
targetUser,
- /*timeOutCallback=*/ new RunServiceCallCallback<IAppFunctionService>() {
+ new RunServiceCallCallback<IAppFunctionService>() {
@Override
public void onServiceConnected(@NonNull IAppFunctionService service,
@NonNull ServiceUsageCompleteListener
diff --git a/core/java/android/app/appfunctions/ServiceCallHelper.java b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
similarity index 96%
rename from core/java/android/app/appfunctions/ServiceCallHelper.java
rename to services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
index cc882bd..98903ae 100644
--- a/core/java/android/app/appfunctions/ServiceCallHelper.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appfunctions;
+package com.android.server.appfunctions;
import android.annotation.NonNull;
import android.content.Intent;
@@ -27,7 +27,7 @@
* @param <T> Class of wrapped service.
* @hide
*/
-public interface ServiceCallHelper<T> {
+public interface RemoteServiceCaller<T> {
/**
* Initiates service binding and executes a provided method when the service connects. Unbinds
diff --git a/core/java/android/app/appfunctions/ServiceCallHelperImpl.java b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
similarity index 89%
rename from core/java/android/app/appfunctions/ServiceCallHelperImpl.java
rename to services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
index 2e58546..c19a027 100644
--- a/core/java/android/app/appfunctions/ServiceCallHelperImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appfunctions;
+package com.android.server.appfunctions;
import android.annotation.NonNull;
import android.content.ComponentName;
@@ -30,27 +30,29 @@
import java.util.function.Function;
/**
- * An implementation of {@link android.app.appfunctions.ServiceCallHelper} that that is based on
+ * An implementation of {@link RemoteServiceCaller} that that is based on
* {@link Context#bindService}.
*
* @param <T> Class of wrapped service.
* @hide
*/
-public class ServiceCallHelperImpl<T> implements ServiceCallHelper<T> {
+public class RemoteServiceCallerImpl<T> implements RemoteServiceCaller<T> {
private static final String TAG = "AppFunctionsServiceCall";
- @NonNull private final Context mContext;
- @NonNull private final Function<IBinder, T> mInterfaceConverter;
+ @NonNull
+ private final Context mContext;
+ @NonNull
+ private final Function<IBinder, T> mInterfaceConverter;
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Executor mExecutor;
/**
* @param interfaceConverter A function responsible for converting an IBinder object into the
- * desired service interface.
- * @param executor An Executor instance to dispatch callback.
- * @param context The system context.
+ * desired service interface.
+ * @param executor An Executor instance to dispatch callback.
+ * @param context The system context.
*/
- public ServiceCallHelperImpl(
+ public RemoteServiceCallerImpl(
@NonNull Context context,
@NonNull Function<IBinder, T> interfaceConverter,
@NonNull Executor executor) {