Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14e446fa authored by Oluwarotimi Adesina's avatar Oluwarotimi Adesina
Browse files

Provide caller signingInfo on execute app function

Flag: android.app.appfunctions.flags.enable_app_function_manager
Test: Will Update CTS
Bug: 386324561

Change-Id: Ia6929eca9342d0abf180b6b8b7e46f4c3baf176e
parent a39afd3f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8905,7 +8905,7 @@ package android.app.appfunctions {
  @FlaggedApi("android.app.appfunctions.flags.enable_app_function_manager") public abstract class AppFunctionService extends android.app.Service {
    ctor public AppFunctionService();
    method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method @MainThread public abstract void onExecuteFunction(@NonNull android.app.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse,android.app.appfunctions.AppFunctionException>);
    method @MainThread public abstract void onExecuteFunction(@NonNull android.app.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.content.pm.SigningInfo, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse,android.app.appfunctions.AppFunctionException>);
    field @NonNull public static final String SERVICE_INTERFACE = "android.app.appfunctions.AppFunctionService";
  }
+19 −13
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.annotation.SdkConstant;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.SigningInfo;
import android.os.Binder;
import android.os.CancellationSignal;
import android.os.IBinder;
@@ -78,10 +79,10 @@ public abstract class AppFunctionService extends Service {
        void perform(
                @NonNull ExecuteAppFunctionRequest request,
                @NonNull String callingPackage,
                @NonNull SigningInfo callingPackageSigningInfo,
                @NonNull CancellationSignal cancellationSignal,
                @NonNull
                        OutcomeReceiver<ExecuteAppFunctionResponse, AppFunctionException>
                                callback);
                        OutcomeReceiver<ExecuteAppFunctionResponse, AppFunctionException> callback);
    }

    /** @hide */
@@ -93,6 +94,7 @@ public abstract class AppFunctionService extends Service {
            public void executeAppFunction(
                    @NonNull ExecuteAppFunctionRequest request,
                    @NonNull String callingPackage,
                    @NonNull SigningInfo callingPackageSigningInfo,
                    @NonNull ICancellationCallback cancellationCallback,
                    @NonNull IExecuteAppFunctionCallback callback) {
                if (context.checkCallingPermission(BIND_APP_FUNCTION_SERVICE)
@@ -105,6 +107,7 @@ public abstract class AppFunctionService extends Service {
                    onExecuteFunction.perform(
                            request,
                            callingPackage,
                            callingPackageSigningInfo,
                            buildCancellationSignal(cancellationCallback),
                            new OutcomeReceiver<>() {
                                @Override
@@ -154,15 +157,17 @@ public abstract class AppFunctionService extends Service {
    /**
     * Called by the system to execute a specific app function.
     *
     * <p>This method is triggered when the system requests your AppFunctionService to handle a
     * particular function you have registered and made available.
     * <p>This method is the entry point for handling all app function requests in an app. When the
     * system needs your AppFunctionService to perform a function, it will invoke this method.
     *
     * <p>To ensure proper routing of function requests, assign a unique identifier to each
     * function. This identifier doesn't need to be globally unique, but it must be unique within
     * your app. For example, a function to order food could be identified as "orderFood". In most
     * cases this identifier should come from the ID automatically generated by the AppFunctions
     * SDK. You can determine the specific function to invoke by calling {@link
     * ExecuteAppFunctionRequest#getFunctionIdentifier()}.
     * <p>Each function you've registered is identified by a unique identifier. This identifier
     * doesn't need to be globally unique, but it must be unique within your app. For example, a
     * function to order food could be identified as "orderFood". In most cases, this identifier is
     * automatically generated by the AppFunctions SDK.
     *
     * <p>You can determine which function to execute by calling {@link
     * ExecuteAppFunctionRequest#getFunctionIdentifier()}. This allows your service to route the
     * incoming request to the appropriate logic for handling the specific function.
     *
     * <p>This method is always triggered in the main thread. You should run heavy tasks on a worker
     * thread and dispatch the result with the given callback. You should always report back the
@@ -173,6 +178,8 @@ public abstract class AppFunctionService extends Service {
     *
     * @param request The function execution request.
     * @param callingPackage The package name of the app that is requesting the execution.
     * @param callingPackageSigningInfo The signing information of the app that is requesting the
     *     execution.
     * @param cancellationSignal A signal to cancel the execution.
     * @param callback A callback to report back the result or error.
     */
@@ -180,10 +187,9 @@ public abstract class AppFunctionService extends Service {
    public abstract void onExecuteFunction(
            @NonNull ExecuteAppFunctionRequest request,
            @NonNull String callingPackage,
            @NonNull SigningInfo callingPackageSigningInfo,
            @NonNull CancellationSignal cancellationSignal,
            @NonNull
                    OutcomeReceiver<ExecuteAppFunctionResponse, AppFunctionException>
                            callback);
            @NonNull OutcomeReceiver<ExecuteAppFunctionResponse, AppFunctionException> callback);

    /**
     * Returns result codes from throwable.
+3 −0
Original line number Diff line number Diff line
@@ -35,12 +35,15 @@ oneway interface IAppFunctionService {
     *
     * @param request  the function execution request.
     * @param callingPackage The package name of the app that is requesting the execution.
     * @param callingPackageSigningInfo The signing information of the app that is requesting the
     *      execution.
     * @param cancellationCallback a callback to send back the cancellation transport.
     * @param callback a callback to report back the result.
     */
    void executeAppFunction(
        in ExecuteAppFunctionRequest request,
        in String callingPackage,
        in android.content.pm.SigningInfo callingPackageSigningInfo,
        in ICancellationCallback cancellationCallback,
        in IExecuteAppFunctionCallback callback
    );
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package android.content.pm;

parcelable SigningInfo;
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ package com.android.extensions.appfunctions {
  public abstract class AppFunctionService extends android.app.Service {
    ctor public AppFunctionService();
    method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method @MainThread public abstract void onExecuteFunction(@NonNull com.android.extensions.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<com.android.extensions.appfunctions.ExecuteAppFunctionResponse,com.android.extensions.appfunctions.AppFunctionException>);
    method @MainThread public void onExecuteFunction(@NonNull com.android.extensions.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.content.pm.SigningInfo, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<com.android.extensions.appfunctions.ExecuteAppFunctionResponse,com.android.extensions.appfunctions.AppFunctionException>);
    method @Deprecated @MainThread public abstract void onExecuteFunction(@NonNull com.android.extensions.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<com.android.extensions.appfunctions.ExecuteAppFunctionResponse,com.android.extensions.appfunctions.AppFunctionException>);
    field @NonNull public static final String BIND_APP_FUNCTION_SERVICE = "android.permission.BIND_APP_FUNCTION_SERVICE";
    field @NonNull public static final String SERVICE_INTERFACE = "android.app.appfunctions.AppFunctionService";
  }
Loading