Repository Patch Pipeline
Overview
This repository is an APK reduction and patching workspace for producing “GameHub Lite” from an official GameHub Android APK. The top-level entry point is autopatcher.sh: it takes an APK path, decompiles it with apktool, removes files listed in files_to_remove.txt, overlays extra Lite resources from lite_resources/, applies every patches/*.diff, performs a few hard-coded cleanup fixes, rebuilds the APK, zipaligns it, signs it, and writes GameHub-Lite-<version>-signed.apk next to the script. README.md is the operator-facing route into the same flow: it describes the expected input APK, output naming, required tools, project structure, and the headline transformation from a 114–115 MB official APK to a roughly 51–55 MB Lite build.
The patcher keeps all repository-relative inputs anchored at SCRIPT_DIR in autopatcher.sh. It expects patches/ for unified diffs, files_to_remove.txt as the main deletion manifest, conversion_rules.txt as the fallback deletion list, lite_resources/ for files copied into the decompiled tree, and gamehub-release.keystore for signing. If gamehub-release.keystore is missing, autopatcher.sh creates it with alias key0 and password password123; if patches/ is missing, the script tries to populate it from DIFF_comparison/*.diff and exits if that source does not exist.
The runtime pipeline in autopatcher.sh is ordered deliberately:
check_dependenciesverifiesapktool, Java,zipalign, andapksigner, auto-detecting Android SDK build tools from Homebrew command-line tools or$ANDROID_HOME.decompile_apkremoves any priorwork_temp/decompiledtree and runsapktool d <input.apk> -o work_temp/decompiled -f.remove_bloat_filesdeletes every path in files_to_remove.txt from the decompiled tree. If that file is absent, it falls back to conversion_rules.txt, which only covers a small hand-written set of native libraries, assets, and SDK directories.copy_additional_filescopies all files fromlite_resources/exceptMETA-INF, preserving relative paths so optimized WebP images and additional smali/resources overlay the APK tree.apply_patchesappliesAndroidManifest.xml.difffirst as a critical patch, then every otherpatches/*.diff; each patch is dry-run withpatch -p1 -d <decompiled>before being applied, and failures or missing target files are counted but do not abort the run.copy_additional_classesensuressmali_classes10exists, usingsmali_classes10_new/only as a fallback when the copied Lite resources did not include it.apply_manual_modificationsmakes safety-net edits that must hold even when a diff did not apply: package renaming fromgamehub.orgtogamehub.lite, insertion ofMTDataFilesProvider, removal of Firebase providers if present, aGameDetailActivitydefaulttypefix, cleanup of invalid extension-named entries in res/…/public.xml, and deletion of.bakfiles created bysed.rebuild_apkrunsapktool b, andsign_apkzipaligns, signs with v1/v2/v3 APK signatures, verifies the signature, and renames the aligned artifact toGameHub-Lite-<version>-signed.apk.
Patch files under patches/*.diff are unified diffs between original/... and lite/... paths. File names encode the target path by replacing path separators with double underscores, for example patches/smali_classes4__com__xj__common__user__UserManager.smali.diff targets smali_classes4/com/xj/common/user/UserManager.smali. autopatcher.sh does not parse that filename convention; it extracts the actual target file from the first --- original/... line and applies the diff with patch -p1. The convention is still useful for review routing because it makes the touched smali or resource path visible from the patch filename. patches/AndroidManifest.xml.diff is special-cased and applied before all other patches because it changes the package to gamehub.lite, removes permissions and SDK components, rewrites provider authorities, adds external launcher support via gamehub.lite.LAUNCH_GAME, and removes Firebase/JPush/Alipay/Google telemetry entries.
The major patch groups match the analysis reports. Authentication and API routing are handled by diffs such as patches/smali_classes4__com__xj__common__user__UserManager.smali.diff, which returns fake-token, supplies UID 100000 when none is stored, and makes isLogin() always true, and patches/smali_classes4__com__xj__common__http__EggGameHttpConfig.smali.diff, which redirects all configured GameHub API bases to https://gamehub-api.secureflex.workers.dev/. Social login and carrier login are neutralized by patches such as patches/smali_classes5__com__xj__landscape__launcher__ui__dialog__QrLoginHelper.smali.diff, which rewrites WeChat OAuth URLs to http://127.0.0.1/..., plus manifest removals in patches/AndroidManifest.xml.diff. Tracking SDK calls are either deleted by files_to_remove.txt or stubbed by patches such as patches/smali_classes4__com__umeng__analytics__MobclickAgent.smali.diff and patches/smali_classes2__cn__jpush__android__api__JPushInterface.smali.diff, which collapse large SDK entry points to no-op methods. External launcher compatibility comes from the manifest export and intent filter in patches/AndroidManifest.xml.diff, plus patches/smali_classes5__com__xj__landscape__launcher__ui__gamedetail__GameDetailActivity.smali.diff, which defaults the type extra to "0" to avoid number parsing failures.
files_to_remove.txt is the authoritative reduction manifest for the automated run. It starts with high-impact assets and native libraries such as assets/auth_intro_timberline.webm, assets/NotoColorEmojiCompat.ttf, lib/arm64-v8a/libjingle_peerconnection_so.so, lib/arm64-v8a/libcrashsdk.so, and lib/arm64-v8a/libumeng-spy.so, then continues into a very large list of drawable/resource paths and SDK artifacts. conversion_rules.txt is intentionally much smaller and is only used when files_to_remove.txt is missing; it names representative telemetry libraries, auth videos/assets, and SDK directories such as Google measurement, Firebase auth, Google Cast, reCAPTCHA, and UMeng analytics.
The top-level reports document why the inputs exist and route reviewers to the right artifact. BLOAT_REMOVAL_ANALYSIS.md explains the size-reduction rationale behind removals in files_to_remove.txt: native libraries, auth videos/assets, resource files, and smali SDK directories. COMPREHENSIVE_SECURITY_ANALYSIS_REPORT.md documents the larger reverse-engineering campaign behind the patch set, including permission removals, auth bypass in UserManager.smali, manifest component removals, telemetry SDK stubbing, and manual replication steps. GAMEHUB_API_ANALYSIS.md explains the external API target used by EggGameHttpConfig.smali.diff: a Cloudflare Worker at https://gamehub-api.secureflex.workers.dev backed by GitHub static API files and selective proxying/sanitization for endpoints that still need upstream data.
This doc owns and should be used to route changes to the repository-level patching surface: edits to README.md, autopatcher.sh, files_to_remove.txt, conversion_rules.txt, the three top-level analysis reports, or any patches/*.diff should be reviewed as changes to this pipeline. It does not own the copied binary/resource payloads such as lite_resources/ or the decompiled APK internals themselves, but it explains how top-level lists and diffs drive those files into the generated APK.
Coupling
- If a target path changes inside any
patches/*.diff, verify both the diff header and the encoded patch filename. autopatcher.sh applies patches using the--- original/...header, not the filename, but reviewers rely on the double-underscore filename convention to understand which decompiled path a patch owns. - If files_to_remove.txt removes classes or providers from Firebase, JPush, UMeng, Alipay, Google services, or carrier-auth SDKs, also verify
patches/AndroidManifest.xml.diffand the relevant stub patches. Manifest entries that still reference removed classes will crash during app start; stub patches such asMobclickAgent.smali.diffandJPushInterface.smali.diffpreserve call sites that cannot be fully deleted. - If
patches/smali_classes4__com__xj__common__http__EggGameHttpConfig.smali.diffchanges the API base URL, also update GAMEHUB_API_ANALYSIS.md and the README.md self-hosting guidance. The APK-side endpoint rewrite and the documented Cloudflare Worker/static API architecture are a single contract. - If
patches/smali_classes4__com__xj__common__user__UserManager.smali.diffchanges token, UID, or login behavior, also update COMPREHENSIVE_SECURITY_ANALYSIS_REPORT.md and any API-worker assumptions documented in GAMEHUB_API_ANALYSIS.md. The reports currently describe a shared fake authentication model and the worker-side privacy trade-off. - If
patches/AndroidManifest.xml.diffchanges the package name or provider authorities, check autopatcher.sh manual fixes for duplicated or stale package rewrites. The script can still performgamehub.orgtogamehub.litereplacement and insertgamehub.lite.MTDataFilesProvidereven when the manifest patch partially applies. - If external launcher support changes, verify both
patches/AndroidManifest.xml.diffandpatches/smali_classes5__com__xj__landscape__launcher__ui__gamedetail__GameDetailActivity.smali.diff. The exportedgamehub.lite.LAUNCH_GAMEactivity needs thetypedefaulting fix so launcher intents without that extra do not trigger the documentedNumberFormatExceptionpath. - If files_to_remove.txt is regenerated, keep conversion_rules.txt either intentionally minimal or update it as a true fallback. autopatcher.sh silently switches to conversion_rules.txt only when the complete list is missing, so divergence can produce a much less private APK without changing the main path.
Risks
- autopatcher.sh treats patch failures as warnings and continues to rebuild. If a critical privacy or auth patch under
patches/*.difffails against a new GameHub version, the output APK can still be signed while silently retaining upstream behavior;apply_patchesonly reports success/failure counts and special-casesAndroidManifest.xml.diffwithout aborting on failure. - autopatcher.sh extracts each target path from the first line of a diff using
head,sed, andawk. If a patch header format changes from the existing--- original/<path>convention, the script can skip or mis-target the patch even when the encoded filename still looks correct. patches/AndroidManifest.xml.diffand autopatcher.sh both mutate manifest-level concerns. If a GameHub update changes surrounding XML enough for the diff to fail, the manual fallback only covers a subset of the manifest changes; removed permissions, exported launcher intent filters, provider authority rewrites, and telemetry component deletions may not all be preserved.- files_to_remove.txt deletes thousands of resource and SDK paths before patches are applied. If a later patch or manual fix still references one of those removed resources/classes, the build may fail or the app may crash at runtime; the risk is documented by the removal strategy in BLOAT_REMOVAL_ANALYSIS.md and the manifest cleanup in COMPREHENSIVE_SECURITY_ANALYSIS_REPORT.md.
- The signing defaults in autopatcher.sh are fixed (
gamehub-release.keystore, aliaskey0, passwordpassword123). If the generated APK is distributed beyond local testing, that predictable key material weakens release identity and update trust.