Skip to content

同步 dev 的改动#70

Merged
HSSkyBoy merged 12 commits into
masterfrom
main
Apr 27, 2026
Merged

同步 dev 的改动#70
HSSkyBoy merged 12 commits into
masterfrom
main

Conversation

@HSSkyBoy

Copy link
Copy Markdown
Member

No description provided.

NkBe and others added 12 commits March 10, 2026 22:31
整合 SRPatch 的技術棧,引入更強的路徑欺騙與 IO 攔截技術,並調整現有去簽等級定義。

1. 新增 LV3 「IO 重定向」(IO Redirection):
   - 實作 Context 深度欺騙:透過反射修正 ContextImpl 內部的 mAppDir 與 mResDir 欄位。
   - 擴充 PackageInfo 攔截邏輯:在 generatePackageInfo 與 Parcelable.Creator 中同步偽裝 sourceDir 與 publicSourceDir。
   - 啟用 SigBypass 內原本閒置的 replaceApplication 方法,強化 Java 框架層的路徑重定向。

2. 等級架構重構與 CLI 更新:
   - 將原有的 Level 3 (SVC/Seccomp Hook) 推移至 Level 4。
   - 更新 Constants.java 內的等級定義 (LV3: PATH_REDIR, LV4: SVC)。
   - 更新 CLI 參數 --sigbypasslv 的說明文件,明確標註 0-4 各等級定義。
   - 將預設去簽等級從 0 (關閉) 提升至 1 (PM),提升修補成功率。

3. 穩定性優化:
   - 調整 doSigBypass 流程,確保在等級 >= 2 時提早解壓原版 APK,供 Java 與 Native 層同時引用。
  - originalSignature 使用 int 而不是硬編碼 0。
  - 略微優化 bypass_svc。
為了提升去除簽名校驗的效果,將使用 API ≥ 28 才有的屬性,此時單獨支持 API 27 是沒有意義的了
针对防护机制透过系统 API 查询 appComponentFactory 导致 NPatch Stub 暴露的问题,实现动态属性还原机制。

详细变更:
- 在 replaceSignature 解析 npatch metadata 时,同步读取并快取原版的 appComponentFactory 字串。
- 新增 spoofApplicationInfo 方法,将 ApplicationInfo 内的 factory 字串覆写回原版名称。

结合 LV3 的路径重定向,现已可完美防御针对 appComponentFactory 的静态档案读取与动态 API 查询。

绕过 appComponentFactory 检测当使用 lv3/lv4 时将自动生效。

优化构建产物的大小
We change the integration with the core repository (JingMatrix/LSPosed) from manual subproject inclusion to a Gradle composite build.

Key changes include:
- Replaced direct `include` and `projectDir` mappings in `settings.gradle.kts` with `includeBuild("core")`.
- Configured dependency substitutions to map 'vector' module coordinates to the appropriate projects within the included build.
- Updated dependency declarations across all subprojects to use the substituted coordinates.
- Removed `share/lspatch-rules.pro` and the corresponding `afterEvaluate` logic in the root build script, as local testing confirms these additional ProGuard rules are no longer required.
- Remove build of libxposed in GitHub Actions workflow.
- Switch from eager resolution of `runtimeClasspath` to the Provider API's lazy `map` implementation in the jar configuration. This change resolves a `beforeEvaluate` lifecycle error encountered during composite builds, as it prevents the early evaluation of included builds during the configuration phase.

Co-Authored-By: JingMatrix <jingmatrix@gmail.com>
- 實作 Managerless 模式的 Fallback 機制,當 Shizuku 未授權時,降級使用系統原生的 PackageInstaller 進行安裝。
- 重構 `NPackageManager.install` 的 Session 寫入邏輯,現在能正確辨識並流式寫入多個 Split APK 檔案。
- 修正 Android 12 以下版本中,Shizuku 代理安裝時 `installerPackageName` 導致的驗證失敗與崩潰問題。
- 優化安裝結果的非同步回調,正確攔截 `STATUS_PENDING_USER_ACTION` 以喚起系統安裝確認彈窗。

Co-Authored-By: JingMatrix <jingmatrix@gmail.com>
Co-Authored-By: xihan123 <srxqzxs@vip.qq.com>
Support loading native libs packaged as APK entries by extracting the embedded .so to an app-writable code_cache (with dataDir reflection fallback) and loading it, adding FileOutputStream-based extraction and logging. Also fix classloader/Dex element construction and app context creation in LSPApplication by using the correct DexPathList element constructor (dexFile, File) and passing appLoadedApk to createAppContext so the appComponentFactory can be resolved correctly.
patch 開始前會先清掉 tmpApkDir 與 externalCacheDir 內所有舊的修補 .apk,避免上一次殘留的 base/split 被混入本次安裝批次,相關邏輯在 Patcher.kt。
patch 完成後會只收集本次產出的 .apk,先穩定搬到 externalCacheDir,再逐一覆寫同步到 SAF 目錄,確保 Base 與所有 Splits 都完整轉移,且 targetApkFiles 只保留本次有效檔案。
讓 JNI .so 回到可壓縮封裝,避免產出的 APK 因未壓縮 native libs 明顯膨脹
將 lib 載入改為解壓後 System.load 模式,並透過將暫存檔移至 App Cache 路徑解決 Permission denied,同步加強 Debug 紀錄。
…換等關鍵流程寫入 XposedBridge - 在啟用 outputLog 時,讓修補時新增的 debug log 與模組 log 一起輸出到 Media 目錄

- 將初始化、載入模組、Manager / Embedded service 切換等關鍵流程寫入 XposedBridge
- 在啟用 outputLog 時,讓修補時新增的 debug log 與模組 log 一起輸出到 Media 目錄
@HSSkyBoy HSSkyBoy merged commit f5074db into master Apr 27, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant