Files
LihonT/lihont/streak_patch.py
cheb0chik eb4ae1cf25 LihonT 2 Luna pre-release 2
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>
2026-10-25 15:09:30 +03:00

37 lines
1.4 KiB
Python

"""Declare the receiver of the streak keeper's alarm in TikTok's manifest.
The keeper (lihont.two.streak.AutoFlame) wakes at the time the user chose through an alarm, and an alarm needs a
receiver that is named in the manifest. The receiver is not exported: only the alarm the app sets for itself can
reach it. Nothing else is added: no permission is asked (the alarm is the kind that needs none) and no intent filter
is given, so no other app can start it.
"""
from __future__ import annotations
from typing import Dict
from . import manifest as manifest_module
from .axml import Axml
RECEIVER = "lihont.two.streak.AutoFlameReceiver"
class StreakError(ValueError):
pass
def has_receiver(xml: Axml, class_name: str) -> bool:
return any(xml.attr_string(node, "name") == class_name for node in xml.elements("receiver"))
def apply(apk, xml: Axml) -> Dict[str, object]:
"""Add the receiver to the manifest object `xml` and write the manifest into the apk."""
if has_receiver(xml, RECEIVER):
raise StreakError("%s is already declared" % RECEIVER)
receiver = xml.make_element("receiver")
xml.set_attr_string(receiver, "name", RECEIVER)
xml.set_attr_bool(receiver, "exported", False)
xml.insert_into(manifest_module.application(xml), [receiver, xml.close_element(receiver)])
apk.replace("AndroidManifest.xml", xml.build())
return {"receiver": RECEIVER, "exported": False}