From 23dcad5007ed98ec17b03d5f7d8be4fba1292d9b Mon Sep 17 00:00:00 2001 From: Michal Olech Date: Wed, 28 Oct 2020 12:20:50 +0100 Subject: [PATCH] [CEC Configuration] Move master configuration from '/product/etc' to '/system/etc' Master configuration should actually be available for all Android devices. Bug: 168020131 Bug: 174349652 Test: atest HdmiCecConfig; also flashed and smoke tested a device Change-Id: I79dee4798a4d2405505f58e89d78b152cdc82fd7 --- Android.bp | 3 +- services/core/Android.bp | 6 +++ .../android/server/hdmi/HdmiCecConfig.java | 28 +++++------ .../com/android/server/hdmi/cec_config.xml | 49 +++++++++++++++++++ 4 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 services/core/java/com/android/server/hdmi/cec_config.xml diff --git a/Android.bp b/Android.bp index 949373317097..b1eb4a5ff247 100644 --- a/Android.bp +++ b/Android.bp @@ -604,8 +604,9 @@ java_defaults { ], required: [ "framework-platform-compat-config", - // TODO: remove gps_debug and protolog.conf.json when the build system propagates "required" properly. + // TODO: remove gps_debug, cec_config.xml and protolog.conf.json when the build system propagates "required" properly. "gps_debug.conf", + "cec_config.xml", "icu4j-platform-compat-config", "libcore-platform-compat-config", "protolog.conf.json.gz", diff --git a/services/core/Android.bp b/services/core/Android.bp index 17e3456e565b..252fd63ae83c 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -110,6 +110,7 @@ java_library_static { ], required: [ + "cec_config.xml", "gps_debug.conf", "protolog.conf.json.gz", ], @@ -171,6 +172,11 @@ java_library_host { srcs: ["java/com/android/server/notification/SmallHash.java"] } +prebuilt_etc { + name: "cec_config.xml", + src: "java/com/android/server/hdmi/cec_config.xml", +} + prebuilt_etc { name: "gps_debug.conf", src: "java/com/android/server/location/gnss/gps_debug.conf", diff --git a/services/core/java/com/android/server/hdmi/HdmiCecConfig.java b/services/core/java/com/android/server/hdmi/HdmiCecConfig.java index 98d130f1ef69..371fd3d33090 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecConfig.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecConfig.java @@ -85,7 +85,7 @@ public class HdmiCecConfig { @NonNull private final Context mContext; @NonNull private final StorageAdapter mStorageAdapter; - @Nullable private final CecSettings mProductConfig; + @Nullable private final CecSettings mSystemConfig; @Nullable private final CecSettings mVendorOverride; /** @@ -162,14 +162,14 @@ public class HdmiCecConfig { @VisibleForTesting HdmiCecConfig(@NonNull Context context, @NonNull StorageAdapter storageAdapter, - @Nullable CecSettings productConfig, + @Nullable CecSettings systemConfig, @Nullable CecSettings vendorOverride) { mContext = context; mStorageAdapter = storageAdapter; - mProductConfig = productConfig; + mSystemConfig = systemConfig; mVendorOverride = vendorOverride; - if (mProductConfig == null) { - Slog.i(TAG, "CEC master configuration XML missing."); + if (mSystemConfig == null) { + Slog.i(TAG, "CEC system configuration XML missing."); } if (mVendorOverride == null) { Slog.i(TAG, "CEC OEM configuration override XML missing."); @@ -178,7 +178,7 @@ public class HdmiCecConfig { HdmiCecConfig(@NonNull Context context) { this(context, new StorageAdapter(context), - readSettingsFromFile(Environment.buildPath(Environment.getProductDirectory(), + readSettingsFromFile(Environment.buildPath(Environment.getRootDirectory(), ETC_DIR, CONFIG_FILE)), readSettingsFromFile(Environment.buildPath(Environment.getVendorDirectory(), ETC_DIR, CONFIG_FILE))); @@ -226,7 +226,7 @@ public class HdmiCecConfig { @Nullable private Setting getSetting(@NonNull String name) { - if (mProductConfig == null) { + if (mSystemConfig == null) { return null; } if (mVendorOverride != null) { @@ -237,8 +237,8 @@ public class HdmiCecConfig { } } } - // If not found, try the product config. - for (Setting setting : mProductConfig.getSetting()) { + // If not found, try the system config. + for (Setting setting : mSystemConfig.getSetting()) { if (setting.getName().equals(name)) { return setting; } @@ -322,11 +322,11 @@ public class HdmiCecConfig { * Returns a list of all settings based on the XML metadata. */ public @CecSettingName List getAllSettings() { - if (mProductConfig == null) { + if (mSystemConfig == null) { return new ArrayList(); } List allSettings = new ArrayList(); - for (Setting setting : mProductConfig.getSetting()) { + for (Setting setting : mSystemConfig.getSetting()) { allSettings.add(setting.getName()); } return allSettings; @@ -336,12 +336,12 @@ public class HdmiCecConfig { * Returns a list of user-modifiable settings based on the XML metadata. */ public @CecSettingName List getUserSettings() { - if (mProductConfig == null) { + if (mSystemConfig == null) { return new ArrayList(); } Set userSettings = new HashSet(); - // First read from the product config. - for (Setting setting : mProductConfig.getSetting()) { + // First read from the system config. + for (Setting setting : mSystemConfig.getSetting()) { if (setting.getUserConfigurable()) { userSettings.add(setting.getName()); } diff --git a/services/core/java/com/android/server/hdmi/cec_config.xml b/services/core/java/com/android/server/hdmi/cec_config.xml new file mode 100644 index 000000000000..480e0ec040a8 --- /dev/null +++ b/services/core/java/com/android/server/hdmi/cec_config.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +