pmb: introduce deviceinfo_chassis (MR 1933)

"Chassis" defines the what kind of device a device is. Currently the
following standardized types exist:

  "desktop", "laptop", "convertible", "server", "tablet", "handset",
  "watch", "embedded", "vm", "container"

This property is exposed by org.freedesktop.hostname1 (e.g.
openrc-settingsd) and can be used by applications for example to display
appropriate strings instead of "About this phone" for non-phone devices.
This commit is contained in:
Luca Weiss 2020-05-03 18:14:42 +02:00 committed by Oliver Smith
parent c5d0f76005
commit 6bb7f022b1
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
4 changed files with 32 additions and 3 deletions

View File

@ -44,6 +44,15 @@ def ask_for_year(args):
validation_regex=r'^[1-9]\d{3,}$')
def ask_for_chassis(args):
types = pmb.config.deviceinfo_chassis_types
logging.info("What type of device is it?")
logging.info("Valid types are: " + ", ".join(types))
return pmb.helpers.cli.ask(args, "Chassis", None, None, True,
validation_regex='|'.join(types), complete=types)
def ask_for_keyboard(args):
return pmb.helpers.cli.confirm(args, "Does the device have a hardware keyboard?")
@ -120,7 +129,7 @@ def generate_deviceinfo_fastboot_content(args, bootimg=None):
def generate_deviceinfo(args, pkgname, name, manufacturer, year, arch,
has_keyboard, has_external_storage,
chassis, has_keyboard, has_external_storage,
flash_method, bootimg=None):
codename = "-".join(pkgname.split("-")[1:])
# Note: New variables must be added to pmb/config/__init__.py as well
@ -138,6 +147,7 @@ def generate_deviceinfo(args, pkgname, name, manufacturer, year, arch,
deviceinfo_arch="{arch}"
# Device related
deviceinfo_chassis="{chassis}"
deviceinfo_keyboard="{"true" if has_keyboard else "false"}"
deviceinfo_external_storage="{"true" if has_external_storage else "false"}"
deviceinfo_screen_width="800"
@ -232,6 +242,7 @@ def generate(args, pkgname):
manufacturer = ask_for_manufacturer(args)
name = ask_for_name(args, manufacturer)
year = ask_for_year(args)
chassis = ask_for_chassis(args)
has_keyboard = ask_for_keyboard(args)
has_external_storage = ask_for_external_storage(args)
flash_method = ask_for_flash_method(args)
@ -240,6 +251,6 @@ def generate(args, pkgname):
bootimg = ask_for_bootimg(args)
generate_deviceinfo(args, pkgname, name, manufacturer, year, arch,
has_keyboard, has_external_storage,
chassis, has_keyboard, has_external_storage,
flash_method, bootimg)
generate_apkbuild(args, pkgname, name, arch, flash_method)

View File

@ -304,6 +304,7 @@ deviceinfo_attributes = [
"arch",
# device
"chassis",
"keyboard",
"external_storage",
"screen_width",
@ -348,6 +349,20 @@ deviceinfo_attributes = [
"keymaps",
]
# Valid types for the 'chassis' atribute in deviceinfo
# See https://www.freedesktop.org/software/systemd/man/machine-info.html
deviceinfo_chassis_types = [
"desktop",
"laptop",
"convertible",
"server",
"tablet",
"handset",
"watch",
"embedded",
"vm"
]
#
# INITFS
#

View File

@ -54,7 +54,7 @@ def generate(args, monkeypatch, answers):
"""
# Patched function
def fake_ask(args, question="Continue?", choices=["y", "n"], default="n",
lowercase_answer=True, validation_regex=None):
lowercase_answer=True, validation_regex=None, complete=None):
for substr, answer in answers.items():
if substr in question:
logging.info(question + ": " + answer)
@ -117,6 +117,7 @@ def test_aportgen_device_wizard(args, monkeypatch):
"Manufacturer": "Testsuite",
"Name": "Testsuite Testdevice",
"Year": "1337",
"Chassis": "handset",
"Type": "isorec",
}
@ -137,6 +138,7 @@ def test_aportgen_device_wizard(args, monkeypatch):
assert deviceinfo["manufacturer"] == answers["Manufacturer"]
assert deviceinfo["arch"] == "armhf"
assert deviceinfo["year"] == "1337"
assert deviceinfo["chassis"] == "handset"
assert deviceinfo["keyboard"] == "false"
assert deviceinfo["external_storage"] == "true"
assert deviceinfo["flash_method"] == "heimdall-isorec"

View File

@ -12,6 +12,7 @@ deviceinfo_flash_method="fastboot"
deviceinfo_arch="armhf"
# Device related
deviceinfo_chassis="handset"
deviceinfo_keyboard="false"
deviceinfo_screen_width="768"
deviceinfo_screen_height="1280"