diff --git a/.github/scripts/generate_patches_readme.py b/.github/scripts/generate_patches_readme.py index c695edc80..2d7525003 100644 --- a/.github/scripts/generate_patches_readme.py +++ b/.github/scripts/generate_patches_readme.py @@ -37,14 +37,30 @@ with open(json_path, encoding="utf-8") as f: data = json.load(f) -def pkg_emoji(pkg): - """Return a standard package emoji regardless of the package name.""" - return "📦" +# Emoji and label suffix for each form factor. Mobile and unspecified use no suffix. +FORM_FACTORS = { + "TV": ("📺", "Android TV"), + "WEARABLE": ("⌚", "Wear OS"), + "AUTOMOTIVE": ("🚗", "Android Automotive"), +} -# Group patches by package; patches with no compatiblePackages are universal. + +def pkg_emoji(form_factor): + """Return the emoji for a form factor, or a standard package emoji.""" + return FORM_FACTORS.get(form_factor, ("📦", None))[0] + + +def pkg_label(name, form_factor): + """Return the app name, with the form factor appended if it is not mobile.""" + suffix = FORM_FACTORS.get(form_factor, (None, None))[1] + return f"{name} ({suffix})" if suffix else name + + +# Group patches by package and form factor; patches with no compatiblePackages are universal. +# The same package name can be used by different apps for each form factor. # JSON structure: compatiblePackages is a list of objects with -# { packageName, name, targets: [{ version, isExperimental, description }] } -by_pkg = {} # packageName -> { name, emoji, patches, targets } +# { packageName, name, formFactor, targets: [{ version, isExperimental, description }] } +by_pkg = {} # (packageName, formFactor) -> { name, emoji, patches, targets } universal = {} for patch in data["patches"]: @@ -57,16 +73,18 @@ for patch in data["patches"]: for pkg_entry in cp: pkg = pkg_entry["packageName"] name = pkg_entry.get("name") or pkg # fall back to package name if no label - if pkg not in by_pkg: - by_pkg[pkg] = { - "name": name, - "emoji": pkg_emoji(pkg), + form_factor = pkg_entry.get("formFactor") + key = (pkg, form_factor) + if key not in by_pkg: + by_pkg[key] = { + "name": pkg_label(name, form_factor), + "emoji": pkg_emoji(form_factor), "patches": {}, "targets": pkg_entry.get("targets", []), } # Deduplicate patches that appear across multiple packages - if patch["name"] not in by_pkg[pkg]["patches"]: - by_pkg[pkg]["patches"][patch["name"]] = patch + if patch["name"] not in by_pkg[key]["patches"]: + by_pkg[key]["patches"][patch["name"]] = patch def anchor(name): @@ -151,7 +169,7 @@ def build_content(expanded=False): ] # One spoiler per app, in the order they appear in the JSON - for pkg, entry in by_pkg.items(): + for entry in by_pkg.values(): patches = list(entry["patches"].values()) label = f"{entry['emoji']} {entry['name']}" lines.append(spoiler(label, len(patches), entry["targets"], patches_table(patches), expanded)) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7697aac91..1067fae63 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -morphe-patcher = "1.15.1" +morphe-patcher = "2.0.0" #noinspection GradleDependency -smali = "d92701d947" +smali = "4220ae75f7" gson = "2.14.0" [libraries] diff --git a/patches/src/main/kotlin/util/PatchListGenerator.kt b/patches/src/main/kotlin/util/PatchListGenerator.kt index a186b2dc2..de9aa58f2 100644 --- a/patches/src/main/kotlin/util/PatchListGenerator.kt +++ b/patches/src/main/kotlin/util/PatchListGenerator.kt @@ -57,6 +57,7 @@ private fun generatePatchList(version: String, patches: Set>) { // Format as #RRGGBB string for readability; null if not set appIconColor = compat.appIconColor?.let { "#%06X".format(it) }, signatures = compat.signatures, + formFactor = compat.formFactor?.name, targets = compat.targets.map { target -> JsonCompatibility.Target( version = target.version, @@ -139,6 +140,8 @@ private class JsonCompatibility( val appIconColor: String?, /** Valid SHA-256 signatures of the app. */ val signatures: Set?, + /** Device form factor of the app, e.g. MOBILE, TV. Null means all form factors. */ + val formFactor: String?, val targets: List, ) { class Target( diff --git a/settings.gradle.kts b/settings.gradle.kts index 34e41d0ec..5935791d4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,5 +17,5 @@ pluginManagement { } plugins { - id("app.morphe.patches") version "1.3.4" + id("app.morphe.patches") version "2.0.0" }