Add a new(Empty) system service for AppFunctions project
A.K.A: Maestro
Flag: android.app.appfunctions.flags.enable_app_function_manager
BUG: 357551503
Test: Setup device with new service. No crash :).
Change-Id: I27e1782181ecda5f80574b1109c18e1d40608754
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index 4e34b63..59a7cbc 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -21,6 +21,7 @@
// !!! KEEP THIS LIST ALPHABETICAL !!!
"aconfig_mediacodec_flags_java_lib",
"android.adaptiveauth.flags-aconfig-java",
+ "android.app.appfunctions.flags-aconfig-java",
"android.app.contextualsearch.flags-aconfig-java",
"android.app.flags-aconfig-java",
"android.app.ondeviceintelligence-aconfig-java",
@@ -1383,6 +1384,21 @@
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}
+// AppFunctions
+aconfig_declarations {
+ name: "android.app.appfunctions.flags-aconfig",
+ exportable: true,
+ package: "android.app.appfunctions.flags",
+ container: "system",
+ srcs: ["core/java/android/app/appfunctions/flags/flags.aconfig"],
+}
+
+java_aconfig_library {
+ name: "android.app.appfunctions.flags-aconfig-java",
+ aconfig_declarations: "android.app.appfunctions.flags-aconfig",
+ defaults: ["framework-minus-apex-aconfig-java-defaults"],
+}
+
// Adaptive Auth
aconfig_declarations {
name: "android.adaptiveauth.flags-aconfig",
diff --git a/core/api/current.txt b/core/api/current.txt
index ea039a7..36c91758 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -10684,6 +10684,7 @@
field public static final String ACTIVITY_SERVICE = "activity";
field public static final String ALARM_SERVICE = "alarm";
field public static final String APPWIDGET_SERVICE = "appwidget";
+ field @FlaggedApi("android.app.appfunctions.flags.enable_app_function_manager") public static final String APP_FUNCTION_SERVICE = "app_function";
field public static final String APP_OPS_SERVICE = "appops";
field public static final String APP_SEARCH_SERVICE = "app_search";
field public static final String AUDIO_SERVICE = "audio";
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index e73f471..114a2c4 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -16,6 +16,8 @@
package android.app;
+import static android.app.appfunctions.flags.Flags.enableAppFunctionManager;
+
import android.accounts.AccountManager;
import android.accounts.IAccountManager;
import android.adservices.AdServicesFrameworkInitializer;
@@ -28,6 +30,8 @@
import android.app.admin.IDevicePolicyManager;
import android.app.ambientcontext.AmbientContextManager;
import android.app.ambientcontext.IAmbientContextManager;
+import android.app.appfunctions.AppFunctionManager;
+import android.app.appfunctions.IAppFunctionManager;
import android.app.appsearch.AppSearchManagerFrameworkInitializer;
import android.app.blob.BlobStoreManagerFrameworkInitializer;
import android.app.contentsuggestions.ContentSuggestionsManager;
@@ -925,6 +929,21 @@
return new CompanionDeviceManager(service, ctx.getOuterContext());
}});
+ if (enableAppFunctionManager()) {
+ registerService(Context.APP_FUNCTION_SERVICE, AppFunctionManager.class,
+ new CachedServiceFetcher<>() {
+ @Override
+ public AppFunctionManager createService(ContextImpl ctx)
+ throws ServiceNotFoundException {
+ IAppFunctionManager service;
+ //TODO(b/357551503): If the feature not present avoid look up every time
+ service = IAppFunctionManager.Stub.asInterface(
+ ServiceManager.getServiceOrThrow(Context.APP_FUNCTION_SERVICE));
+ return new AppFunctionManager(service, ctx.getOuterContext());
+ }
+ });
+ }
+
registerService(Context.VIRTUAL_DEVICE_SERVICE, VirtualDeviceManager.class,
new CachedServiceFetcher<VirtualDeviceManager>() {
@Override
diff --git a/core/java/android/app/appfunctions/AppFunctionManager.java b/core/java/android/app/appfunctions/AppFunctionManager.java
new file mode 100644
index 0000000..a01e373
--- /dev/null
+++ b/core/java/android/app/appfunctions/AppFunctionManager.java
@@ -0,0 +1,44 @@
+/*
+ * 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.app.appfunctions;
+
+import android.annotation.SystemService;
+import android.content.Context;
+
+/**
+ * Provides app functions related functionalities.
+ *
+ * <p>App function is a specific piece of functionality that an app offers to the system. These
+ * functionalities can be integrated into various system features.
+ *
+ * @hide
+ */
+@SystemService(Context.APP_FUNCTION_SERVICE)
+public final class AppFunctionManager {
+ private final IAppFunctionManager mService;
+ private final Context mContext;
+
+ /**
+ * TODO(b/357551503): add comments when implement this class
+ *
+ * @hide
+ */
+ public AppFunctionManager(IAppFunctionManager mService, Context context) {
+ this.mService = mService;
+ this.mContext = context;
+ }
+}
diff --git a/core/java/android/app/appfunctions/IAppFunctionManager.aidl b/core/java/android/app/appfunctions/IAppFunctionManager.aidl
new file mode 100644
index 0000000..018bc75
--- /dev/null
+++ b/core/java/android/app/appfunctions/IAppFunctionManager.aidl
@@ -0,0 +1,24 @@
+/*
+ * 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.app.appfunctions;
+
+/**
+* Interface between an app and the server implementation service (AppFunctionManagerService).
+* @hide
+*/
+oneway interface IAppFunctionManager {
+}
\ No newline at end of file
diff --git a/core/java/android/app/appfunctions/flags/flags.aconfig b/core/java/android/app/appfunctions/flags/flags.aconfig
new file mode 100644
index 0000000..367effc
--- /dev/null
+++ b/core/java/android/app/appfunctions/flags/flags.aconfig
@@ -0,0 +1,11 @@
+package: "android.app.appfunctions.flags"
+container: "system"
+
+flag {
+ name: "enable_app_function_manager"
+ is_exported: true
+ is_fixed_read_only: true
+ namespace: "machine_learning"
+ description: "This flag the new App Function manager system service."
+ bug: "357551503"
+}
\ No newline at end of file
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 9aebfc8..9dccc9a 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -16,6 +16,7 @@
package android.content;
+import static android.app.appfunctions.flags.Flags.FLAG_ENABLE_APP_FUNCTION_MANAGER;
import static android.content.flags.Flags.FLAG_ENABLE_BIND_PACKAGE_ISOLATED_PROCESS;
import android.annotation.AttrRes;
@@ -51,6 +52,7 @@
import android.app.IServiceConnection;
import android.app.VrManager;
import android.app.ambientcontext.AmbientContextManager;
+import android.app.appfunctions.AppFunctionManager;
import android.app.people.PeopleManager;
import android.app.time.TimeManager;
import android.companion.virtual.VirtualDeviceManager;
@@ -6310,6 +6312,16 @@
/**
* Use with {@link #getSystemService(String)} to retrieve an
+ * {@link AppFunctionManager} for
+ * executing app functions.
+ *
+ * @see #getSystemService(String)
+ */
+ @FlaggedApi(FLAG_ENABLE_APP_FUNCTION_MANAGER)
+ public static final String APP_FUNCTION_SERVICE = "app_function";
+
+ /**
+ * Use with {@link #getSystemService(String)} to retrieve an
* {@link android.content.integrity.AppIntegrityManager}.
* @hide
*/
diff --git a/services/Android.bp b/services/Android.bp
index ded7379..0006455 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -120,6 +120,7 @@
":services.backup-sources",
":services.companion-sources",
":services.contentcapture-sources",
+ ":services.appfunctions-sources",
":services.contentsuggestions-sources",
":services.contextualsearch-sources",
":services.coverage-sources",
@@ -217,6 +218,7 @@
"services.autofill",
"services.backup",
"services.companion",
+ "services.appfunctions",
"services.contentcapture",
"services.contentsuggestions",
"services.contextualsearch",
diff --git a/services/appfunctions/Android.bp b/services/appfunctions/Android.bp
new file mode 100644
index 0000000..f8ee823
--- /dev/null
+++ b/services/appfunctions/Android.bp
@@ -0,0 +1,25 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+filegroup {
+ name: "services.appfunctions-sources",
+ srcs: ["java/**/*.java"],
+ path: "java",
+ visibility: ["//frameworks/base/services"],
+}
+
+java_library_static {
+ name: "services.appfunctions",
+ defaults: ["platform_service_defaults"],
+ srcs: [
+ ":services.appfunctions-sources",
+ "java/**/*.logtags",
+ ],
+ libs: ["services.core"],
+}
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java
new file mode 100644
index 0000000..f30e770
--- /dev/null
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerService.java
@@ -0,0 +1,45 @@
+/*
+ * 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 com.android.server.appfunctions;
+
+import static android.app.appfunctions.flags.Flags.enableAppFunctionManager;
+
+import android.app.appfunctions.IAppFunctionManager;
+import android.content.Context;
+
+import com.android.server.SystemService;
+
+/**
+ * Service that manages app functions.
+ */
+public class AppFunctionManagerService extends SystemService {
+
+ public AppFunctionManagerService(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void onStart() {
+ if (enableAppFunctionManager()) {
+ publishBinderService(Context.APP_FUNCTION_SERVICE, new AppFunctionManagerStub());
+ }
+ }
+
+ private static class AppFunctionManagerStub extends IAppFunctionManager.Stub {
+
+ }
+}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 622c36c..09c54cb 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -16,6 +16,7 @@
package com.android.server;
+import static android.app.appfunctions.flags.Flags.enableAppFunctionManager;
import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH;
@@ -120,6 +121,7 @@
import com.android.server.ambientcontext.AmbientContextManagerService;
import com.android.server.app.GameManagerService;
import com.android.server.appbinding.AppBindingService;
+import com.android.server.appfunctions.AppFunctionManagerService;
import com.android.server.apphibernation.AppHibernationService;
import com.android.server.appop.AppOpMigrationHelper;
import com.android.server.appop.AppOpMigrationHelperImpl;
@@ -1727,6 +1729,12 @@
mSystemServiceManager.startService(LogcatManagerService.class);
t.traceEnd();
+ t.traceBegin("StartAppFunctionManager");
+ if (enableAppFunctionManager()) {
+ mSystemServiceManager.startService(AppFunctionManagerService.class);
+ }
+ t.traceEnd();
+
} catch (Throwable e) {
Slog.e("System", "******************************************");
Slog.e("System", "************ Failure starting core service");