1 /* 2 * Copyright 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.appfunctions.internal 18 19 import androidx.appfunctions.AppFunctionManagerCompat 20 import androidx.appfunctions.ExecuteAppFunctionRequest 21 import androidx.appfunctions.ExecuteAppFunctionResponse 22 23 /** Provides the backend to the [android.app.appfunctions.AppFunctionManager] API. */ 24 internal interface AppFunctionManagerApi { 25 /** 26 * Execute the app function. 27 * 28 * @param request the app function details and the arguments. 29 * @return the result of the attempt to execute the function. 30 */ executeAppFunctionnull31 suspend fun executeAppFunction( 32 request: ExecuteAppFunctionRequest, 33 ): ExecuteAppFunctionResponse 34 35 /** 36 * Checks if [functionId] in [packageName] is enabled. 37 * 38 * @param packageName The package name of the owner of [functionId]. 39 * @param functionId The identifier of the app function. 40 * @throws IllegalArgumentException If the [functionId] is not available under [packageName]. 41 */ 42 suspend fun isAppFunctionEnabled(packageName: String, functionId: String): Boolean 43 44 /** 45 * Sets [newEnabledState] to an app function [functionId] owned by the calling package. 46 * 47 * @param functionId The identifier of the app function. 48 * @param newEnabledState The new state of the app function. 49 * @throws IllegalArgumentException If the [functionId] is not available. 50 */ 51 suspend fun setAppFunctionEnabled( 52 functionId: String, 53 @AppFunctionManagerCompat.EnabledState newEnabledState: Int, 54 ) 55 } 56