Fix signature spoofing patch for Android 16 javac compatibility

- Replace bare Bundle with android.os.Bundle (no import in ComputerEngine)
- Replace try-with-resources on ApkAssets with try/finally + explicit
  close() — ApkAssets has close() but does not implement AutoCloseable
This commit is contained in:
2026-06-17 12:34:43 +00:00
parent be30c1affe
commit 3c49ddc277
@@ -1,4 +1,4 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: oxmc <me@oxmc.me>
Date: Wed, 03 Jun 2026 00:00:00 +0000
Subject: [PATCH] Add support for app signature spoofing
@@ -83,20 +83,21 @@ diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/serv
index 3f0c0e1ae..e986335fd 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -1476,6 +1476,52 @@ public class ComputerEngine implements Computer {
@@ -1476,6 +1476,55 @@ public class ComputerEngine implements Computer {
return result;
}
+ private String getFakeSignature(AndroidPackage p) {
+ Bundle meta = p.getMetaData();
+ android.os.Bundle meta = p.getMetaData();
+ if (meta == null) return null;
+ String sig = meta.getString("fake-signature");
+ if (sig != null) return sig;
+ int resId = meta.getInt("fake-signature", 0);
+ if (resId == 0) return null;
+ try {
+ try (android.content.res.ApkAssets apkAssets =
+ android.content.res.ApkAssets.loadFromPath(p.getBaseApkPath())) {
+ android.content.res.ApkAssets apkAssets =
+ android.content.res.ApkAssets.loadFromPath(p.getBaseApkPath());
+ try {
+ android.content.res.AssetManager am =
+ new android.content.res.AssetManager.Builder()
+ .addApkAssets(apkAssets).build();
@@ -104,6 +105,8 @@ index 3f0c0e1ae..e986335fd 100644
+ am, android.content.res.Resources.getSystem().getDisplayMetrics(),
+ android.content.res.Resources.getSystem().getConfiguration());
+ return res.getString(resId);
+ } finally {
+ apkAssets.close();
+ }
+ } catch (Exception e) {
+ Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE",