Streak widget from 1x1 to 4x4 with an animated flame (orange while lit, grey when not), a streak keeper that writes the chosen message once a day to the chosen chats (off until switched on), avatar shapes, widgets and the keeper kept per account, Material 3 tonal surfaces instead of black (AMOLED keeps pure black), launcher previews of our own, and the mod runtime in a dex of its own. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
"""Every framework attribute id in lihont.axml.ATTR_IDS is the one android.jar defines (a wrong id is silently ignored by Android)."""
|
|
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from lihont.axml import ATTR_IDS
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SOURCE = """
|
|
import java.io.File;
|
|
import java.net.URL;
|
|
import java.net.URLClassLoader;
|
|
|
|
public class Ids {
|
|
public static void main(String[] args) throws Exception {
|
|
URLClassLoader loader = new URLClassLoader(new URL[] {new File(args[0]).toURI().toURL()}, null);
|
|
Class<?> attr = loader.loadClass("android.R$attr");
|
|
for (int i = 1; i < args.length; i++) {
|
|
System.out.println(args[i] + " " + attr.getField(args[i]).getInt(null));
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
|
|
|
|
class AttributeIdsTest(unittest.TestCase):
|
|
def test_every_id_matches_android_jar(self):
|
|
javac, java = shutil.which("javac"), shutil.which("java")
|
|
jar = ROOT / "tools" / "android.jar"
|
|
if not javac or not java or not jar.is_file():
|
|
self.skipTest("needs a JDK and tools/android.jar")
|
|
with tempfile.TemporaryDirectory(prefix="lihont-attrs-") as out:
|
|
Path(out, "Ids.java").write_text(SOURCE, encoding="utf-8")
|
|
subprocess.run([javac, "-d", out, str(Path(out, "Ids.java"))], check=True, capture_output=True)
|
|
env = dict(os.environ)
|
|
env.pop("JAVA_TOOL_OPTIONS", None)
|
|
result = subprocess.run([java, "-cp", out, "Ids", str(jar)] + sorted(ATTR_IDS),
|
|
capture_output=True, text=True, timeout=60, env=env)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
defined = {line.split()[0]: int(line.split()[1]) & 0xFFFFFFFF for line in result.stdout.splitlines()}
|
|
wrong = {name: (hex(ATTR_IDS[name]), hex(defined[name])) for name in ATTR_IDS if ATTR_IDS[name] != defined[name]}
|
|
self.assertEqual({}, wrong, "ids that differ from android.jar: " + repr(wrong))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|