LifeMate — Personal, Family & Learning Companion
test/personal-recovery-acceptance
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | """Inspect the binary manifest of the never-distributed recovery QA APK.""" |
| 2 | import argparse |
| 3 | import hashlib |
| 4 | import json |
| 5 | from pathlib import Path |
| 6 | from zipfile import ZipFile |
| 7 | |
| 8 | from check_apk_manifest import manifest_tags |
| 9 | |
| 10 | PACKAGE = 'ir.lifeguide.app.personal' |
| 11 | LABEL = 'آزمون بازیابی' |
| 12 | |
| 13 | |
| 14 | def check(apk, expected_code=None): |
| 15 | apk = Path(apk) |
| 16 | with ZipFile(apk) as archive: |
| 17 | tags = manifest_tags(archive.read('AndroidManifest.xml')) |
| 18 | |
| 19 | def one(name): |
| 20 | matches = [attributes for tag, attributes in tags if tag == name] |
| 21 | if len(matches) != 1: |
| 22 | raise ValueError('Missing or ambiguous QA manifest element') |
| 23 | return matches[0] |
| 24 | |
| 25 | manifest, application, sdk = one('manifest'), one('application'), one('uses-sdk') |
| 26 | code = manifest.get('versionCode') |
| 27 | if (manifest.get('package') != PACKAGE or type(code) is not int or code not in (10, 11) |
| 28 | or (expected_code is not None and code != expected_code) |
| 29 | or manifest.get('versionName') != f'0.7.2-recovery-qa.{code}' |
| 30 | or application.get('label') != LABEL): |
| 31 | raise ValueError('Expected the separate synthetic recovery QA edition') |
| 32 | if (application.get('debuggable') is not True |
| 33 | or application.get('allowBackup') is not False |
| 34 | or application.get('usesCleartextTraffic') is not False): |
| 35 | raise ValueError('QA debug, backup and network gates are required') |
| 36 | if sdk.get('minSdkVersion') != 24 or sdk.get('targetSdkVersion') != 36: |
| 37 | raise ValueError('Unexpected QA SDK versions') |
| 38 | required = {'android.permission.' + permission for permission in |
| 39 | ('POST_NOTIFICATIONS', 'RECEIVE_BOOT_COMPLETED', 'SCHEDULE_EXACT_ALARM')} |
| 40 | allowed = required | {PACKAGE + '.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION'} |
| 41 | permissions = {a.get('name') for tag, a in tags if tag.startswith('uses-permission')} |
| 42 | if not required <= permissions <= allowed: |
| 43 | raise ValueError('Unexpected QA permissions; INTERNET is forbidden') |
| 44 | activities = [a for tag, a in tags if tag == 'activity'] |
| 45 | if not any(a.get('name') == 'ir.lifeguide.app.MainActivity' and |
| 46 | a.get('exported') is True for a in activities): |
| 47 | raise ValueError('QA must resolve the existing fully qualified activity') |
| 48 | receivers = [a for tag, a in tags if tag == 'receiver'] |
| 49 | # Exact system-protected dependency also observed in the delivered old APK. |
| 50 | # This does not permit another exported receiver or relax the reminder gate. |
| 51 | protected_profile_installer = { |
| 52 | 'name': 'androidx.profileinstaller.ProfileInstallReceiver', |
| 53 | 'permission': 'android.permission.DUMP', 'enabled': True, |
| 54 | 'exported': True, 'directBootAware': False, |
| 55 | } |
| 56 | if (not any(a.get('name') == 'ir.lifeguide.app.LocalReminderReceiver' |
| 57 | and a.get('exported') is False for a in receivers) |
| 58 | or any(a.get('exported') is True and a != protected_profile_installer |
| 59 | for a in receivers)): |
| 60 | raise ValueError('QA reminder receivers must remain private') |
| 61 | markers = [a for tag, a in tags if tag == 'meta-data' |
| 62 | and a.get('name') == 'ir.lifeguide.PERSONAL_RECOVERY_QA'] |
| 63 | if len(markers) != 1 or markers[0].get('value') is not True: |
| 64 | raise ValueError('Explicit synthetic recovery QA marker is required') |
| 65 | return {'result': 'PASS', 'package': PACKAGE, 'label': LABEL, |
| 66 | 'versionCode': code, 'versionName': manifest['versionName'], |
| 67 | 'debuggable': True, 'allowBackup': False, 'usesCleartextTraffic': False, |
| 68 | 'internetPermission': False, 'permissions': sorted(permissions), |
| 69 | 'minSdkVersion': 24, 'targetSdkVersion': 36, 'syntheticOnly': True, |
| 70 | 'sha256': hashlib.sha256(apk.read_bytes()).hexdigest(), |
| 71 | 'limitations': 'Never distribute. Signature and Android lifecycle checked separately.'} |
| 72 | |
| 73 | |
| 74 | if __name__ == '__main__': |
| 75 | parser = argparse.ArgumentParser(description=__doc__) |
| 76 | parser.add_argument('apk', type=Path) |
| 77 | parser.add_argument('--expected-code', type=int, choices=(10, 11)) |
| 78 | options = parser.parse_args() |
| 79 | print(json.dumps(check(options.apk, options.expected_code), ensure_ascii=False, indent=2)) |