Files
LihonT/tests/test_manifest_activity.py
cheb0chik 5df4cddf7d LihonT 3 Luna pre-alpha: the streak pet becomes an animal
A pair of people can have a kitten, a puppy or a lion cub in place of TikTok's streak creature: it grows with the days of the
streak (cub, teen, adult, elder), goes grey while the streak is about to burn out, can be dragged in the chat and is also shown
on the big streak screen. An animal is given by a link (lihont.space/pet) that the friend accepts. The drawings are made by
scripts/make_pet_designs.py and served as strips of frames. Also here: the promo video scripts (make_pet_video.py on top of
make_store_video.py), a retry pause for strips that failed to load, stricter checks in the answer to a gift.

Work in progress: the gift service is not switched on for everyone yet and there is no public build with the animals.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 15:14:48 +03:00

71 lines
3.1 KiB
Python

from pathlib import Path
import unittest
from lihont.axml import Axml
from lihont.manifest import ManifestError, add_activity, has_activity
class ManifestActivityTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.apk = Path('OriginalAPKtiktok/com.zhiliaoapp.musically_47.1.3-2024701030_minAPI23(arm64-v8a)(nodpi)_apkmirror.com.apk')
if not cls.apk.exists():
raise unittest.SkipTest('clean TikTok base APK is not available')
def _manifest(self):
from lihont.apkzip import Apk
apk = Apk(str(self.apk))
try:
return Axml.parse(apk.read('AndroidManifest.xml'))
finally:
apk.close()
def test_private_settings_activity_is_non_exported(self):
xml = self._manifest()
name = 'lihont.two.settings.LihonTSettingsActivity'
add_activity(xml, name, 'LihonT', 0x7F120364)
self.assertTrue(has_activity(xml, name))
node = next(n for n in xml.elements('activity') if xml.attr_string(n, 'name') == name)
exported = xml.attr(node, 'exported')
self.assertIsNotNone(exported)
self.assertEqual(0, exported.data)
self.assertEqual(0x7F120364, xml.attr(node, 'theme').data)
# A second parse verifies the binary XML remains valid after appending
# framework attributes and a private activity subtree.
reparsed = Axml.parse(xml.build())
self.assertTrue(has_activity(reparsed, name))
def test_the_store_login_activity_is_exported_without_a_window(self):
xml = self._manifest()
name = 'lihont.two.store.LoginActivity'
add_activity(xml, name, 'LihonT Store', 0x01030055, exported=True)
reparsed = Axml.parse(xml.build())
node = next(n for n in reparsed.elements('activity') if reparsed.attr_string(n, 'name') == name)
self.assertNotEqual(0, reparsed.attr(node, 'exported').data)
self.assertEqual(0x01030055, reparsed.attr(node, 'theme').data)
def test_the_gift_activity_opens_the_pet_links(self):
xml = self._manifest()
name = 'lihont.two.pet.GiftActivity'
add_activity(xml, name, 'LihonT', 0x7F120364, exported=True,
links=(('https', 'lihont.space', '/pet'), ('lihont', 'pet', None)))
reparsed = Axml.parse(xml.build())
self.assertTrue(has_activity(reparsed, name))
schemes = [reparsed.attr_string(n, 'scheme') for n in reparsed.elements('data')]
self.assertIn('https', schemes)
self.assertIn('lihont', schemes)
prefixes = [reparsed.attr_string(n, 'pathPrefix') for n in reparsed.elements('data')]
self.assertIn('/pet', prefixes)
views = [reparsed.attr_string(n, 'name') for n in reparsed.elements('action')]
self.assertIn('android.intent.action.VIEW', views)
def test_launcher_activity_must_explicitly_be_exported(self):
xml = self._manifest()
with self.assertRaises(ManifestError):
add_activity(xml, 'lihont.two.TestLauncher', 'LihonT', 0x7F120364,
affinity='lihont.test', launcher=True)
if __name__ == '__main__':
unittest.main()