diff options
author | Pedro Loureiro <pedroql@google.com> | 2022-12-12 16:46:50 +0000 |
---|---|---|
committer | Pedro Loureiro <pedroql@google.com> | 2022-12-22 10:29:22 +0000 |
commit | 9d30c1ffd57dc9ba8348458c88b4a684d029669d (patch) | |
tree | 9fd374ac9766d319c0bc36103913fc25e08921d5 | |
parent | e34847f27e1be80e76eeb1a3b33d0cd5152eff6f (diff) | |
download | ConfigInfrastructure-9d30c1ffd57dc9ba8348458c88b4a684d029669d.tar.gz |
Add updatable DeviceConfig Service
This adds a new service that will power the updatable DeviceConfig logic. The current design will take over from the "device_config" service that currently exists in the platform when UpdatableDeviceConfigServiceReadiness.shouldStartUpdatableService returns true. Otherwise the behaviour changes shouldn't be noticeable.
Bug: 261723346
Test: manual
Test: atest CtsDeviceConfigTestCases
Change-Id: I761e62aaf9503964ed848953575788b59c14a304
-rw-r--r-- | framework/Android.bp | 8 | ||||
-rw-r--r-- | framework/api/system-current.txt | 4 | ||||
-rw-r--r-- | framework/java/android/provider/UpdatableDeviceConfigServiceReadiness.java | 31 | ||||
-rw-r--r-- | service/Android.bp | 17 | ||||
-rw-r--r-- | service/api/system-server-current.txt | 11 | ||||
-rw-r--r-- | service/jarjar-rules.txt | 1 | ||||
-rw-r--r-- | service/java/android/provider/HelloService.java | 9 | ||||
-rw-r--r-- | service/java/com/android/server/deviceconfig/DeviceConfigInit.java | 45 | ||||
-rw-r--r-- | service/java/com/android/server/deviceconfig/DeviceConfigShellService.java | 40 |
9 files changed, 151 insertions, 15 deletions
diff --git a/framework/Android.bp b/framework/Android.bp index 7a67d52..106e993 100644 --- a/framework/Android.bp +++ b/framework/Android.bp @@ -26,4 +26,10 @@ java_sdk_library { ], min_sdk_version: "33", sdk_version: "module_current", -}
\ No newline at end of file + libs: [ + "androidx.annotation_annotation", + ], + impl_library_visibility: [ + "//packages/modules/ConfigInfrastructure:__subpackages__" + ], +} diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt index ad23a9b..b0c9812 100644 --- a/framework/api/system-current.txt +++ b/framework/api/system-current.txt @@ -126,5 +126,9 @@ package android.provider { method @NonNull public android.provider.DeviceConfig.Properties.Builder setString(@NonNull String, @Nullable String); } + public final class UpdatableDeviceConfigServiceReadiness { + method public static boolean shouldStartUpdatableService(); + } + } diff --git a/framework/java/android/provider/UpdatableDeviceConfigServiceReadiness.java b/framework/java/android/provider/UpdatableDeviceConfigServiceReadiness.java new file mode 100644 index 0000000..36242d5 --- /dev/null +++ b/framework/java/android/provider/UpdatableDeviceConfigServiceReadiness.java @@ -0,0 +1,31 @@ +package android.provider; + +import androidx.annotation.NonNull; + +import android.annotation.SystemApi; + +/** + * This class reports the readiness of the updatable code to be used. + * @hide + */ +@SystemApi +public final class UpdatableDeviceConfigServiceReadiness { + + private UpdatableDeviceConfigServiceReadiness() { + // do not instantiate + } + + /** + * Returns true if the updatable service (part of mainline) is ready to be used. + * Otherwise the platform shell service should be started. + * + * <p>see {@code com.android.providers.settings.DeviceConfigService} + * <p>see {@code android.provider.DeviceConfig} + * + * @return true if the updatable code should be used + */ + public static boolean shouldStartUpdatableService() { + return false; + } + +} diff --git a/service/Android.bp b/service/Android.bp index d3fa588..83512ba 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -23,13 +23,20 @@ java_sdk_library { "framework-system-server-module-defaults", "framework-system-server-module-optimize-defaults", ], - permitted_packages: [ "android.provider" ], + permitted_packages: [ + "android.provider", + "com.android.server.deviceconfig", + ], apex_available: [ "com.android.configinfrastructure", ], - min_sdk_version: "33", - sdk_version: "module_current", + static_libs: [ + "modules-utils-shell-command-handler", + ], libs: [ - "androidx.annotation_annotation", + "framework-configinfrastructure.impl", ], -}
\ No newline at end of file + min_sdk_version: "33", + sdk_version: "system_server_current", + jarjar_rules: "jarjar-rules.txt", +} diff --git a/service/api/system-server-current.txt b/service/api/system-server-current.txt index d802177..722ace1 100644 --- a/service/api/system-server-current.txt +++ b/service/api/system-server-current.txt @@ -1 +1,12 @@ // Signature format: 2.0 +package com.android.server.deviceconfig { + + public class DeviceConfigInit { + } + + public static class DeviceConfigInit.Lifecycle extends com.android.server.SystemService { + ctor public DeviceConfigInit.Lifecycle(@NonNull android.content.Context); + } + +} + diff --git a/service/jarjar-rules.txt b/service/jarjar-rules.txt new file mode 100644 index 0000000..cf60d8f --- /dev/null +++ b/service/jarjar-rules.txt @@ -0,0 +1 @@ +rule com.android.modules.utils.** com.android.server.deviceconfig.internal.modules.utils.@1 diff --git a/service/java/android/provider/HelloService.java b/service/java/android/provider/HelloService.java deleted file mode 100644 index 235fc1c..0000000 --- a/service/java/android/provider/HelloService.java +++ /dev/null @@ -1,9 +0,0 @@ -package android.provider; - -import androidx.annotation.Keep; - -/** @hide */ -@Keep -public class HelloService{ - -}
\ No newline at end of file diff --git a/service/java/com/android/server/deviceconfig/DeviceConfigInit.java b/service/java/com/android/server/deviceconfig/DeviceConfigInit.java new file mode 100644 index 0000000..dba14ba --- /dev/null +++ b/service/java/com/android/server/deviceconfig/DeviceConfigInit.java @@ -0,0 +1,45 @@ +package com.android.server.deviceconfig; + +import java.io.FileDescriptor; + +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.content.Context; +import android.os.Binder; +import android.provider.UpdatableDeviceConfigServiceReadiness; + +import com.android.server.SystemService; + +/** @hide */ +@SystemApi(client = SystemApi.Client.SYSTEM_SERVER) +public class DeviceConfigInit { + + private DeviceConfigInit() { + // do not instantiate + } + + /** @hide */ + @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) + public static class Lifecycle extends SystemService { + private DeviceConfigShellService mShellService; + + /** @hide */ + @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) + public Lifecycle(@NonNull Context context) { + super(context); + // this service is always instantiated but should only launch subsequent services + // if the module is ready + if (UpdatableDeviceConfigServiceReadiness.shouldStartUpdatableService()) { + mShellService = new DeviceConfigShellService(); + } + } + + /** @hide */ + @Override + public void onStart() { + if (UpdatableDeviceConfigServiceReadiness.shouldStartUpdatableService()) { + publishBinderService("device_config", mShellService); + } + } + } +} diff --git a/service/java/com/android/server/deviceconfig/DeviceConfigShellService.java b/service/java/com/android/server/deviceconfig/DeviceConfigShellService.java new file mode 100644 index 0000000..14ced76 --- /dev/null +++ b/service/java/com/android/server/deviceconfig/DeviceConfigShellService.java @@ -0,0 +1,40 @@ +package com.android.server.deviceconfig; + +import java.io.PrintWriter; + +import android.annotation.NonNull; +import android.os.Binder; +import android.os.ParcelFileDescriptor; + +import com.android.modules.utils.BasicShellCommandHandler; + +/** @hide */ +public class DeviceConfigShellService extends Binder { + + @Override + public int handleShellCommand(@NonNull ParcelFileDescriptor in, + @NonNull ParcelFileDescriptor out, @NonNull ParcelFileDescriptor err, + @NonNull String[] args) { + return (new MyShellCommand()).exec( + this, in.getFileDescriptor(), out.getFileDescriptor(), err.getFileDescriptor(), + args); + } + + static final class MyShellCommand extends BasicShellCommandHandler { + + @Override + public int onCommand(String cmd) { + if (cmd == null || "help".equals(cmd) || "-h".equals(cmd)) { + onHelp(); + return -1; + } + return -1; + } + + @Override + public void onHelp() { + PrintWriter pw = getOutPrintWriter(); + pw.println("Device Config implemented in mainline"); + } + } +} |