custom_type: get custom_type from model_sku.json
We add custom_type in model_sku.json, that is used to identify
whitelabel and rebrand projects. We read the information in
gooftool and check whether the whitelabel field in VPD doesn't
exist only for whitelabel projects.
BUG=b:189272466
TEST=manual test on DUT
Change-Id: Ie93d1c3b70cca19b8984566863e6eba81932f1dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/3168836
Tested-by: Isaac Lee <isaaclee@google.com>
Commit-Queue: Isaac Lee <isaaclee@google.com>
Reviewed-by: Kerker Yang <kerker@chromium.org>
Reviewed-by: Shou-Chieh Hsu <shouchieh@chromium.org>
diff --git a/py/gooftool/core.py b/py/gooftool/core.py
index 4f50657..13bc98b 100644
--- a/py/gooftool/core.py
+++ b/py/gooftool/core.py
@@ -899,12 +899,18 @@
"""Write device info into cr50 flash."""
cros_config = cros_config_module.CrosConfig(self._util.shell)
is_whitelabel, whitelabel_tag = cros_config.GetWhiteLabelTag()
+ model_sku_config = config_utils.LoadConfig('model_sku', validate_schema=False)
+ model = cros_config.GetModelName()
+ if model not in model_sku_config['model']:
+ custom_type = ''
+ else:
+ custom_type = model_sku_config['model'][model].get('custom_type', '')
if is_whitelabel:
# If we can't find whitelabel_tag in VPD, this will be None.
vpd_whitelabel_tag = self._vpd.GetValue('whitelabel_tag')
if vpd_whitelabel_tag != whitelabel_tag:
- if vpd_whitelabel_tag is None:
+ if vpd_whitelabel_tag is None and custom_type == 'whitelabel':
# whitelabel_tag is not set in VPD. Technically, this is allowed by
# cros_config. It would be equivalent to whitelabel_tag='' (empty
# string). However, it is ambiguous, we don't know if this is
diff --git a/py/gooftool/cros_config.py b/py/gooftool/cros_config.py
index 39f9a72..8ea5920 100644
--- a/py/gooftool/cros_config.py
+++ b/py/gooftool/cros_config.py
@@ -26,3 +26,7 @@
"""
result = self.GetValue('/identity', 'whitelabel-tag')
return result.success, (result.stdout.strip() if result.stdout else '')
+
+ def GetModelName(self):
+ result = self.GetValue('/', 'name')
+ return result.stdout.strip() if result.stdout else ''