• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Functions related to brand configs.
2
3See proto definitions for descriptions of arguments.
4"""
5
6# Needed to load from @proto. Add @unused to silence lint.
7load("//config/util/bindings/proto.star", "protos")
8load(
9    "@proto//chromiumos/config/api/software/brand_config.proto",
10    bc_pb = "chromiumos.config.api.software",
11)
12load(
13    "@proto//chromiumos/config/api/device_brand_id.proto",
14    db_id_pb = "chromiumos.config.api",
15)
16
17def _create(
18        device_brand_id,
19        wallpaper = None,
20        regulatory_label = None,
21        whitelabel_tag = None,
22        help_content_id = None,
23        cloud_gaming_device = None,
24        feature_device_type = None,
25        custom_label_tag = None):
26    """Builds a BrandConfig proto.
27
28    Args:
29        device_brand_id: A DeviceBrandId proto that is used to select a
30            BrandConfig at runtime. Required.
31        wallpaper: Base filename of the default wallpaper to show.
32        regulatory_label: See chromeos-config readme
33        whitelabel_tag: "whitelabel_tag" value set in the VPD, used to select a
34            BrandConfig at runtime. Deprecated, please use custom_label_tag instead.
35        help_content_id: help content identifier
36        cloud_gaming_device: whether devices using this BrandConfig should
37            enable cloud gaming features
38        custom_label_tag: "whitelabel_tag" is deprecated and renamed to "custom_label_tag".
39            See https://chromeos.google.com/partner/dlm/docs/factory/vpd.html#field-custom_label_tag.
40
41    Returns:
42        A BrandConfig proto.
43    """
44    if whitelabel_tag != None and custom_label_tag != None:
45        fail("whitelabel_tag and custom_label_tag both exist, please use only custom_label_tag.")
46    scan_config = None
47    if whitelabel_tag or feature_device_type or custom_label_tag != None:
48        scan_config = db_id_pb.DeviceBrandId.ScanConfig(
49            whitelabel_tag = whitelabel_tag,
50            feature_device_type = feature_device_type,
51            custom_label_tag = custom_label_tag,
52        )
53    return bc_pb.BrandConfig(
54        brand_id = device_brand_id,
55        wallpaper = wallpaper,
56        scan_config = scan_config,
57        regulatory_label = regulatory_label,
58        help_content_id = help_content_id,
59        cloud_gaming_device = cloud_gaming_device,
60    )
61
62_FEATURE_DEVICE_TYPE = struct(
63    OFF = db_id_pb.DeviceBrandId.ScanConfig.OFF,
64    LEGACY = db_id_pb.DeviceBrandId.ScanConfig.LEGACY,
65    ON = db_id_pb.DeviceBrandId.ScanConfig.ON,
66)
67
68brand_config = struct(
69    create = _create,
70    feature_device_type = _FEATURE_DEVICE_TYPE,
71)
72