From ecc0d1b2c1b07d4c6baecc65c05761753bdf9c25 Mon Sep 17 00:00:00 2001 From: Terry Wang Date: Thu, 17 Oct 2019 17:05:18 -0700 Subject: [PATCH] Add a new system service for app search project Bug: 142567528 Test: manual Change-Id: Iefb426383f94ec89c896065c798b22cfb2977bf3 --- Android.bp | 1 + apex/appsearch/framework/Android.bp | 39 +++++++++++++++++++ .../app/appsearch/AppSearchManager.java | 35 +++++++++++++++++ .../AppSearchManagerFrameworkInitializer.java | 37 ++++++++++++++++++ .../app/appsearch/IAppSearchManager.aidl | 19 +++++++++ apex/appsearch/service/Android.bp | 24 ++++++++++++ .../appsearch/AppSearchManagerService.java | 39 +++++++++++++++++++ api/current.txt | 1 + config/preloaded-classes | 1 + .../android/app/SystemServiceRegistry.java | 2 + core/java/android/content/Context.java | 9 +++++ .../java/com/android/server/SystemServer.java | 7 +++- 12 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 apex/appsearch/framework/Android.bp create mode 100644 apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java create mode 100644 apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java create mode 100644 apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl create mode 100644 apex/appsearch/service/Android.bp create mode 100644 apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java diff --git a/Android.bp b/Android.bp index ea14b9df5dd0..180e1d3c5dea 100644 --- a/Android.bp +++ b/Android.bp @@ -212,6 +212,7 @@ filegroup { name: "framework-non-updatable-sources", srcs: [ // Java/AIDL sources under frameworks/base + ":framework-appsearch-sources", ":framework-blobstore-sources", ":framework-core-sources", ":framework-drm-sources", diff --git a/apex/appsearch/framework/Android.bp b/apex/appsearch/framework/Android.bp new file mode 100644 index 000000000000..0a65f7320d8a --- /dev/null +++ b/apex/appsearch/framework/Android.bp @@ -0,0 +1,39 @@ +// Copyright (C) 2019 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. + +filegroup { + name: "framework-appsearch-sources", + srcs: [ + "java/**/*.java", + "java/**/*.aidl", + ], + path: "java", +} + +java_library { + name: "framework-appsearch", + installable: false, + sdk_version: "core_platform", + srcs: [ + ":framework-appsearch-sources", + ], + aidl: { + export_include_dirs: [ + "java", + ], + }, + libs: [ + "framework-minus-apex", + ], +} diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java new file mode 100644 index 000000000000..a8ee35c129eb --- /dev/null +++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2019 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.appsearch; + +import android.annotation.SystemService; +import android.content.Context; + +/** + * TODO(b/142567528): add comments when implement this class + * @hide + */ +@SystemService(Context.APP_SEARCH_SERVICE) +public class AppSearchManager { + private final IAppSearchManager mService; + /** + * TODO(b/142567528): add comments when implement this class + * @hide + */ + public AppSearchManager(IAppSearchManager service) { + mService = service; + } +} diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java new file mode 100644 index 000000000000..fcebe3d9cf3c --- /dev/null +++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 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.appsearch; + +import android.app.SystemServiceRegistry; +import android.content.Context; + +/** + * This is where the AppSearchManagerService wrapper is registered. + * + * TODO(b/142567528): add comments when implement this class + * @hide + */ +public class AppSearchManagerFrameworkInitializer { + + /** + * TODO(b/142567528): add comments when implement this class + */ + public static void initialize() { + SystemServiceRegistry.registerStaticService( + Context.APP_SEARCH_SERVICE, AppSearchManager.class, + (service) -> new AppSearchManager(IAppSearchManager.Stub.asInterface(service))); + } +} diff --git a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl b/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl new file mode 100644 index 000000000000..f0f4f512d769 --- /dev/null +++ b/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl @@ -0,0 +1,19 @@ +/** + * Copyright 2019, 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.appsearch; +/** {@hide} */ +interface IAppSearchManager { +} diff --git a/apex/appsearch/service/Android.bp b/apex/appsearch/service/Android.bp new file mode 100644 index 000000000000..2821fbef3e36 --- /dev/null +++ b/apex/appsearch/service/Android.bp @@ -0,0 +1,24 @@ +// Copyright (C) 2019 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. +java_library { + name: "appsearch-service", + installable: true, + srcs: [ + "java/**/*.java", + ], + libs: [ + "framework", + "services.core", + ], +} diff --git a/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java b/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java new file mode 100644 index 000000000000..4d44d9d04806 --- /dev/null +++ b/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 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.appsearch; + +import android.app.appsearch.IAppSearchManager; +import android.content.Context; + +import com.android.server.SystemService; + +/** + * TODO(b/142567528): add comments when implement this class + */ +public class AppSearchManagerService extends SystemService { + + public AppSearchManagerService(Context context) { + super(context); + } + + @Override + public void onStart() { + publishBinderService(Context.APP_SEARCH_SERVICE, new Stub()); + } + + private class Stub extends IAppSearchManager.Stub { + } +} diff --git a/api/current.txt b/api/current.txt index 1728c53ec720..f899e40edab4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9927,6 +9927,7 @@ package android.content { field public static final String ALARM_SERVICE = "alarm"; field public static final String APPWIDGET_SERVICE = "appwidget"; 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"; field public static final String BATTERY_SERVICE = "batterymanager"; field public static final int BIND_ABOVE_CLIENT = 8; // 0x8 diff --git a/config/preloaded-classes b/config/preloaded-classes index ab98e5b1f87a..0394a7a489ba 100644 --- a/config/preloaded-classes +++ b/config/preloaded-classes @@ -514,6 +514,7 @@ android.app.admin.SystemUpdateInfo$1 android.app.admin.SystemUpdateInfo android.app.admin.SystemUpdatePolicy$1 android.app.admin.SystemUpdatePolicy +android.app.appsearch.AppSearchManagerFrameworkInitializer android.app.assist.AssistContent$1 android.app.assist.AssistContent android.app.assist.AssistStructure$1 diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index d40261f7452a..5effa1b99813 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -22,6 +22,7 @@ import android.annotation.NonNull; import android.app.ContextImpl.ServiceInitializationState; import android.app.admin.DevicePolicyManager; import android.app.admin.IDevicePolicyManager; +import android.app.appsearch.AppSearchManagerFrameworkInitializer; import android.app.blob.BlobStoreManagerFrameworkInitializer; import android.app.contentsuggestions.ContentSuggestionsManager; import android.app.contentsuggestions.IContentSuggestionsManager; @@ -1263,6 +1264,7 @@ public final class SystemServiceRegistry { JobSchedulerFrameworkInitializer.registerServiceWrappers(); BlobStoreManagerFrameworkInitializer.initialize(); TelephonyFrameworkInitializer.registerServiceWrappers(); + AppSearchManagerFrameworkInitializer.initialize(); } finally { // If any of the above code throws, we're in a pretty bad shape and the process // will likely crash, but we'll reset it just in case there's an exception handler... diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 7703e087bcea..8507316e07f8 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -4897,6 +4897,15 @@ public abstract class Context { @SystemApi public static final String BATTERY_STATS_SERVICE = "batterystats"; + /** + * Use with {@link #getSystemService(String)} to retrieve an + * AppSearchManager for indexing and querying app data managed + * by the system. + * + * @see #getSystemService(String) + */ + public static final String APP_SEARCH_SERVICE = "app_search"; + /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index f1ed1d9d954e..f74f3a638ca0 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -281,7 +281,8 @@ public final class SystemServer { "com.android.server.DeviceIdleController"; private static final String BLOB_STORE_MANAGER_SERVICE_CLASS = "com.android.server.blob.BlobStoreManagerService"; - + private static final String APP_SEARCH_MANAGER_SERVICE_CLASS = + "com.android.server.appsearch.AppSearchManagerService"; private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; private static final String UNCRYPT_PACKAGE_FILE = "/cache/recovery/uncrypt_file"; @@ -2023,6 +2024,10 @@ public final class SystemServer { mSystemServiceManager.startBootPhase(t, SystemService.PHASE_DEVICE_SPECIFIC_SERVICES_READY); t.traceEnd(); + t.traceBegin("AppSearchManagerService"); + mSystemServiceManager.startService(APP_SEARCH_MANAGER_SERVICE_CLASS); + t.traceEnd(); + // These are needed to propagate to the runnable below. final NetworkManagementService networkManagementF = networkManagement; final NetworkStatsService networkStatsF = networkStats;