Files
LihonT/tests/test_manifest_activity.py
cheb0chik 8b7fa5ff57 LihonT 2 Serena alpha
Themes as data: the settings and the rest of TikTok take a look (Stickers, Windows 95, or a theme a plugin brings with the
right ui.theme); the DEBUG recovery mode (Clear cache in Android resets the look and puts the plugins in safe mode); new
plugin functions (name.style, confetti and buzz on a tap); a few memory trims in the chat bubbles; the person list for bubbles
no longer shows screen labels.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 12:32:37 +03:00

47 lines
1.8 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_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()