From 7357f8c0c8a6bdc09555ab47dae83f28346b8470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 22 Jun 2016 15:04:56 +0200 Subject: [PATCH 1/1] Add signature Spoofing permission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is needed by GmsCore (https://microg.org/) to pretend the existence of the official Play Services to applications calling Google APIs. Signed-off-by: BenoƮt Mauduit --- core/res/AndroidManifest.xml | 7 +++++++ core/res/res/values/config.xml | 2 ++ core/res/res/values/strings.xml | 5 +++++ .../android/server/pm/PackageManagerService.java | 23 ++++++++++++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index ea0e39c..a936983 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1654,6 +1654,13 @@ android:description="@string/permdesc_getPackageSize" android:protectionLevel="normal" /> + + + diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index c7846cf..916d8a5 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1298,6 +1298,8 @@ com.android.location.fused + + com.google.android.gms diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 58135db..e65367a 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -616,6 +616,11 @@ + Spoof package signature + + Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Grant this permission with caution only! + + disable or modify status bar Allows the app to disable the status bar or add and remove system icons. diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 0493180..35f49d7 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -2816,8 +2816,27 @@ public class PackageManagerService extends IPackageManager.Stub { final Set permissions = permissionsState.getPermissions(userId); final PackageUserState state = ps.readUserState(userId); - return PackageParser.generatePackageInfo(p, gids, flags, - ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId); + return mayFakeSignature(p, PackageParser.generatePackageInfo(p, gids, flags, + ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId), + permissions); + } + + private PackageInfo mayFakeSignature(PackageParser.Package p, PackageInfo pi, + Set permissions) { + try { + if (permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE") + && p.applicationInfo.targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1 + && p.mAppMetaData != null) { + String sig = p.mAppMetaData.getString("fake-signature"); + if (sig != null) { + pi.signatures = new Signature[] {new Signature(sig)}; + } + } + } catch (Throwable t) { + // We should never die because of any failures, this is system code! + Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE", t); + } + return pi; } @Override -- 2.8.1