Skip to content

FilipFan/AppFunctionsPilot

Repository files navigation

App Functions Pilot ✨

This project demonstrates the capabilities of App Functions, a new feature introduced in Android 16 (API level 36). App Functions allow applications to expose their functionalities to the Android system, enabling cross-app orchestration. By leveraging this framework, developers can integrate large language models (LLMs) to create agentic experiences with tool-calling capabilities.

This repository contains two sample applications that illustrate a function-calling workflow, using the androidx.appfunctions Jetpack library:

Agent App: Demonstrates how to discover functions registered by other apps, parse their declarations, and invoke them to retrieve results.

Tool App: Shows how to register and expose an app's own functions, making them available for other apps (like the Agent) to call.

Installation

Prerequisites

Ensure the following flag is enabled on your device or emulator:

adb shell aflags list | grep "enable_app_functions_schema_parser"

If this flag is not set to enabled, you will need to modify the USE_CONTENT_PROVIDER variable to true in the following file: agent/src/main/java/dev/filipfan/appfunctionspilot/agent/MainViewModel.kt.

Note

Using USE_CONTENT_PROVIDER=true serves as a workaround for devices that don't support dynamic parsing. However, this method may return incomplete data, such as functions with missing descriptions; starting from version 1.0.0-alpha08, this approach no longer supports function calling. This reflects a limitation of the androidx.appfunctions library.

Tool App

You can install the tool app directly using ADB:

adb install tool-debug.apk

Agent App

The agent app requires the android.permission.EXECUTE_APP_FUNCTIONS permission. On most devices running Android 16 (android-16.0.0_r4 or earlier), this is a protected permission granted only to privileged system applications.

  1. Verify Permission Protection Level

Before installation, check the protection level of this permission on your test device or emulator:

adb shell pm list permissions -f | grep -A 5 "EXECUTE_APP_FUNCTIONS"
  • If the level is normal: You can install the app directly via adb install agent-debug.apk.
  • If the level is privileged: Choose one of the following two options to grant the permission.
  1. Granting Privileged Permission

Option A: Using Instrumentation

This method uses Android's Instrumentation mechanism to bypass permission restriction. It does not require root access.

  1. Install the Agent app normally:
    adb install agent-debug.apk
  2. Launch the app using the provided script:
    ./start_agent.sh

Important

You must use this script to launch the app. Opening it from the launcher icon will not grant the required privileged permissions.

Option B: Privileged Installation

This method installs the app as a system-privileged package. It requires a rooted device or emulator with remount capabilities.

Step 1: Disable Permission Enforcement Modify the build.prop file to disable privileged permission enforcement:

adb root
adb remount
adb shell "sed -i 's/ro.control_privapp_permissions=enforce/ro.control_privapp_permissions=log/g' /vendor/build.prop"

Step 2: Install as a Privileged App Push the APK to the privileged apps directory:

adb push agent-debug.apk /system/priv-app
adb reboot

Note

After the initial privileged installation, you can update the agent app using a standard adb install command, provided its permissions in the manifest do not change.

References

About

A sample that showcases Android App Functions use cases.

Topics

Resources

License

Stars

Watchers

Forks

Contributors