Commit Graph

123 Commits

Author SHA1 Message Date
NkBe e640da4f57
feat: 引入輕量級 MicroG 支援與 GMS 請求重導向機制
為 NPatch 引入了原生的 MicroG 整合支援,允許修補後的 Google 應用程式(例如 YouTube)在依賴 Google Play 服務的環境下,透過社群版 MicroG(如 ReVanced GmsCore)正常運作。

詳細改動範圍包含:

* ** UI Manager **
  - 於 `NewPatchScreen` 的修補選項清單中,新增「啟用 MicroG 支援」核取方塊與相容性說明。
  - 更新 `NewPatchViewModel`,透過 `Patcher.kt` 將使用者的 `useMicroG` 選擇狀態以 `--useMicroG` 指令列參數的形式,傳遞給底層修補引擎。

* ** Patcher **
  - 於 `NPatch.java` 中新增對 `--useMicroG` 參數的解析邏輯。
  - 擴充 `modifyManifestFile` 邏輯:當啟用 MicroG 支援時,自動讀取目標應用的原始簽名並轉碼為 Hex 格式。
  - 於 `AndroidManifest.xml` 中動態注入 `fake-signature` 的 `<meta-data>` 節點與 `android.permission.FAKE_PACKAGE_SIGNATURE` 權限,以滿足 MicroG 進行簽名欺騙(Signature Spoofing)時的驗證需求。

* ** Patch Loader **
  - 實作 `GmsRedirector.java` 類別,負責在應用程式執行期間動態攔截並重導向 IPC 通訊:
    1. 掛鉤 `Intent.setPackage`、`Intent.setComponent` 與建構子,將所有指向 `com.google.android.gms` 與 GSF 的意圖,強制導向至設備上已安裝的社群版 MicroG 套件(優先支援 `app.revanced.android.gms` 與 `org.microg.gms`)。
    2. 掛鉤 `ContentResolver`,替換帶有 GMS Authority 的 URI。針對真實 GMS 拋出的 `SecurityException`(憑證拒絕存取)實作了智慧攔截與重試機制。
    3. 掛鉤 `PackageManager.getPackageInfo` 實現動態簽名偽裝,使修補後的應用程式將 MicroG 視為官方正版 GMS。
  - 於 `LSPApplication.java` 的 `onLoad` 階段,依據 `PatchConfig` 設定檔動態喚醒並初始化 `GmsRedirector`。

* ** Share **
  - 更新 `PatchConfig.java` 以儲存與傳遞 `useMicroG` 布林值狀態。
  - 於 `Constants.java` 中定義 `REAL_GMS_PACKAGE_NAME` 常數,供各模組統一呼叫。

Co-Authored-By: MrZhongzq <108169409+MrZhongzq@users.noreply.github.com>
2026-03-08 21:53:41 +08:00
NkBe 43ca1640ab
Fix .so file 16KB alignment in patched APKs:
- Change .so alignment from 4096 to 16384 bytes to comply with
     Android 15+ 16KB page alignment requirements.

Co-Authored-By: MrZhongzq <108169409+mrzhongzq@users.noreply.github.com>
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
2026-03-06 22:06:32 +08:00
NkBe f2713a342b
Use NestedZip linking with copy fallback
Make APK packaging more robust by conditionally embedding the original APK (based on sigbypassLevel) and opening the source as either a NestedZip or a read-only ZFile. Attempt to add file links via NestedZip.addFileLink for entries, and fall back to copying the entry stream on failure or when source is read-only. Clean up related logic (remove the earlier separate embedding block), improve error messages, and minor reordering (minSdkVersion declaration) to streamline patch processing.
2026-02-10 21:45:38 +08:00
NkBe 7cf0f3a229
refactor: optimize APK processing and cleanup redundant code
Refactored NPatch.java to use NestedZip, optimized dex file counting, and removed unused permission replacement methods. Improved logging and error reporting during the patch process.
2026-02-10 20:02:32 +08:00
NkBe c1480fa121
improve NPatch zip handling
將 android:largeHeap="true" 添加至管理員 manifest 中,防止系統限制 RAM。啟用 ZFileOptions.setNoTimestamps,並將來源 APK 嵌入為唯讀壓縮檔。
2026-02-10 19:26:23 +08:00
NkBe 97a23caa9e
修復 arsc 的正確壓縮和對齊
在 ZFileOptions 中為 .arsc 檔案添加 4 字節對齊規則,並在新增條目時將 resources.arsc 處理為原生程式庫。確保 resources.arsc 的正確對齊。
2026-02-10 18:37:34 +08:00
NkBe 3aa1e26343
Restrict ARCHES to 64-bit ABIs
Remove 32-bit ABIs from NPatch's ARCHES set: only 'arm64-v8a' and 'x86_64' remain.
2026-02-10 14:32:24 +08:00
NkBe f4eacbf2d3
Update core and dependencies
Update to LSPosed v1.11.0
解決了 Android 10 和 OnePlus 裝置上的特定問題,重構 Dex2Oat 以消除缺失符號錯誤並提升可靠性....
https://github.com/JingMatrix/LSPosed/releases/tag/v1.11.0
2026-02-10 14:32:24 +08:00
NkBe 271eb7bd82
feat(sigbypass): SVC Bypass (ARM64) and OpenAt I/O Redirection
導入 ARM64 專用的 SVC/Seccomp 內核級簽名繞過 (Level 3),並全面強化檔案 I/O 重定向機制。
移除非 ARM64 架構的支持
2025-12-22 21:57:33 +08:00
NkBe f215471400
fix(patch): 优化Manifest权限与authority映射
重构了权限和authority的映射逻辑,统一使用targetPackage变量,支持com.google.android前缀不变。

修改部分參考 #37,主要用於修復 #25

Co-Authored-By: areteruhiro <108941410+areteruhiro@users.noreply.github.com>
2025-12-11 22:36:05 +08:00
NkBe 611d77f263
rename provider2mtprovider 2025-12-03 22:32:53 +08:00
NkBe 5aa809dc5a
Refactor:Replace all instances of `lspatch` with `npatch`
嘗試规避關鍵詞檢測
2025-12-02 23:42:23 +08:00
NkBe f03ad9a386
fix: improve asset handling and error checks 2025-11-21 19:33:34 +08:00
NkBe 9588a87814
refactor: improve APK signature block parsing 2025-11-19 21:03:41 +08:00
NkBe 307660038e
refactor: rename lspatch meta key to npatch 2025-10-29 21:38:58 +08:00
NkBe a2b9e529ca
feat: support inject MT Manager DocumentsProvider
Co-Authored-By: Hicores <me@hicore.cc>
2025-10-29 21:38:57 +08:00
NkBe(HSSkyBoy) d644c22ade
feat: support patching with new package name
feat: log APK patch paths in submitPatch

fix: improve temp APK file handling

feat: add newPackageName option

refactor: optimize patch install dialogs

feat: support rename packagename
Co-Authored-By: javaeryang <27242250+javaeryang@users.noreply.github.com>
2025-10-08 15:47:16 +08:00
NkBe(HSSkyBoy) 07b100ea2f
refactor: rename lspatched to npatched 2025-10-08 15:47:15 +08:00
NkBe(HSSkyBoy) 7613e7de10
feat: add output log to media
底層實現了日誌檔案寫入。為管理器新增了 outputLog 選項,可以將日誌輸出到 Android/media 目錄。
2025-10-06 23:27:30 +08:00
NkBe fed6e4afcf
Lower minSdkVersion 2025-09-05 23:48:04 +08:00
xihan123 b83152323a
Allow uers to chose if inject loader dex (#19)
If we always inject loader dex, then modules with third party libraries might fail to find library classes since the default class loader is alway used before the the loader of the module package.

Therefore, it is better to treat packages with isolated services as special cases.
2024-11-20 19:38:48 +01:00
JingMatrix 4a7cc257a7 Use axml (ManifestEditor) lib from LSPosed
By doing so, we no longer need org.slf4j.* classes

ManifestEditor will now check atrribute types, so we choose correctly
the type of minSdkVersion.
2024-05-19 01:08:22 +02:00
JingMatrix 69438162cd Skip split apks when possible
When the split apks are loaded by appComponentFactory, we skip patching
them to reduce the file size.
2023-12-28 13:29:27 +01:00
JingMatrix 89b71ebe0a Put original dex files in patched APK
Count the number of dex files and rename classes.dex correctly.
Skip loading lspatch.so when currentActivityThread is null.
2023-12-28 13:29:27 +01:00
5ec1cff 531acdb924
use version catalog (#256) 2023-11-08 02:07:20 +08:00
Howard Wu 941726d559
Core upgrade (#213)
Co-authored-by: LoveSy <shana@zju.edu.cn>
2023-06-29 02:17:00 +08:00
Js0n 3acc9086b1
fix: only add QUERY_ALL_PACKAGES permission when useManager is true (#195) 2023-05-10 22:50:51 +08:00
Harshit Shah 4d8bafd74f
Remove mandatory original signature check (#185)
We are unnecessary fetching original signature even when signature
bypass level is not greater than 0. Due to which some apps which were
not signed were failing to be patched with error "get original signature
failed".
2023-04-21 21:21:25 +08:00
Harshit Shah 5d8645d201
Fixing Manifest Parsing - Shifting from axmlprinter to axmlparser (#180)
**Description:**
Some apps were failing with reason `Failed to parse Manifest file`
Turns out that `AxmlResourceParser` from `android4Me` is very outdated
and does not work well in all cases.
Hence have removed `axmlprinter` and migrated code to use `AxmlParser`
from `ManifestEditor` by `WindySha`.
2023-04-09 22:58:48 +08:00
Js0n e62da55614
feat: set minimum sdk to Android 9 if original value is lower (#167) 2023-01-28 11:53:55 +08:00
Nullptr 2ace2660b4
Fix modules missing after update loader for integrated mode 2022-11-13 22:43:39 +08:00
Nullptr 5876d4a0a0
Update dependencies & Fix UI previewing 2022-11-05 12:00:25 +08:00
Nullptr 5db7ecf7bd
No need to add loader dex and so for local mode 2022-10-21 19:26:08 +08:00
Nullptr f8888b81e8
Support bootstrapping loader dynamically for local mode (#118) 2022-10-21 15:24:16 +08:00
Nullptr 2e2c818de6
Drop v1 signature & UI improvement 2022-09-06 21:20:06 +08:00
NonNonStop b1691a95e2
Add ManifestEditor assets (#107) 2022-09-04 19:29:02 +08:00
LoveSy c956fbea51
Compare AXML attribute name by resource ID
Close #105

Co-Authored-by: nonnonstop <42905588+nonnonstop@users.noreply.github.com>
2022-09-04 16:21:08 +08:00
Nullptr 95f006682c
Update core and dependencies 2022-09-02 10:30:34 +08:00
Nullptr 279e95b57b
Support upgrade loader version 2022-07-05 21:54:13 +08:00
Nullptr 0ef34fa633
Add .apk suffix 2022-07-05 19:10:29 +08:00
Nullptr 6924c6a3b5
CI (#57)
* CI

* Add patch info to metadata

* Allow select local apks to patch

* Fix wrong indent
2022-05-10 11:39:04 +08:00
Nullptr 5d3f0ec9f7 Implement install patched app & Refactor UI 2022-05-05 21:07:45 +08:00
Nullptr 774afca739 Update proguard 2022-04-06 11:17:19 +08:00
Nullptr 02d6752895 Support custom keystore 2022-03-27 16:59:42 +08:00
Nullptr 7905b343dc ServiceClient 2022-03-23 22:36:19 +08:00
Nullptr b89b425a53 Switch into mainline core branch 2022-03-17 19:52:05 +08:00
Nullptr 397faf7ab4 Change output file name 2022-03-06 17:36:43 +08:00
Nullptr 4dd6369e1a Use git commit count as verCode 2022-03-04 13:29:46 +08:00
Nullptr 5a16a34cd8 Fix null classloader 2022-03-04 13:28:48 +08:00
Ketal 1096ba6658
Support get apk sign v2 info (#40) 2022-02-23 22:13:27 +08:00