Skip to content

Commit 40d6bf7

Browse files
berolinuxmar-v-in
authored andcommitted
Add patch for Android O (8.0.0_r4)
This is android_frameworks_base-N.patch rebased to the android-8.0.0_r4 tag. It also expands the description a little to let the user know why a legitimate app might request this permission. Signed-off-by: Bernhard Rosenkränzer <[email protected]>
1 parent f1cdb48 commit 40d6bf7

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
commit 4e9d677b35b9656c22c922c9abca4107ab95c9b4
2+
Author: Bernhard Rosenkränzer <[email protected]>
3+
Date: Tue Aug 29 00:34:27 2017 +0200
4+
5+
Add permission to allow an APK to fake a signature.
6+
7+
This is needed by GmsCore (https://microg.org/) to pretend
8+
the existence of the official Play Services to applications calling
9+
Google APIs.
10+
11+
Forward-ported from https://github.com/microg/android_packages_apps_GmsCore/blob/master/patches/android_frameworks_base-N.patch
12+
13+
Change-Id: I603fd09200432f7e1bf997072188cdfa6da1594f
14+
Signed-off-by: Bernhard Rosenkränzer <[email protected]>
15+
16+
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
17+
index 794d4f8b78b..b3189077256 100644
18+
--- a/core/res/AndroidManifest.xml
19+
+++ b/core/res/AndroidManifest.xml
20+
@@ -2075,6 +2075,13 @@
21+
android:description="@string/permdesc_getPackageSize"
22+
android:protectionLevel="normal" />
23+
24+
+ <!-- @hide Allows an application to change the package signature as
25+
+ seen by applications -->
26+
+ <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
27+
+ android:protectionLevel="dangerous"
28+
+ android:label="@string/permlab_fakePackageSignature"
29+
+ android:description="@string/permdesc_fakePackageSignature" />
30+
+
31+
<!-- @deprecated No longer useful, see
32+
{@link android.content.pm.PackageManager#addPackageToPreferred}
33+
for details. -->
34+
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
35+
index 3613acf44aa..d1636c862c5 100644
36+
--- a/core/res/res/values/config.xml
37+
+++ b/core/res/res/values/config.xml
38+
@@ -1385,6 +1385,8 @@
39+
<string-array name="config_locationProviderPackageNames" translatable="false">
40+
<!-- The standard AOSP fused location provider -->
41+
<item>com.android.location.fused</item>
42+
+ <!-- The (faked) microg fused location provider (a free reimplementation) -->
43+
+ <item>com.google.android.gms</item>
44+
</string-array>
45+
46+
<!-- This string array can be overriden to enable test location providers initially. -->
47+
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
48+
index 3eebe7eb68d..7405386cd49 100644
49+
--- a/core/res/res/values/strings.xml
50+
+++ b/core/res/res/values/strings.xml
51+
@@ -764,6 +764,10 @@
52+
53+
<!-- Permissions -->
54+
55+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
56+
+ <string name="permlab_fakePackageSignature">Spoof package signature</string>
57+
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
58+
+ <string name="permdesc_fakePackageSignature">Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Legitimate uses include an emulator pretending to be what it emulates. Grant this permission with caution only!</string>
59+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
60+
<string name="permlab_statusBar">disable or modify status bar</string>
61+
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
62+
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
63+
index f36b762c5e9..048a057d39c 100644
64+
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
65+
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
66+
@@ -3571,8 +3571,9 @@ public class PackageManagerService extends IPackageManager.Stub
67+
flags |= MATCH_ANY_USER;
68+
}
69+
70+
- PackageInfo packageInfo = PackageParser.generatePackageInfo(p, gids, flags,
71+
- ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId);
72+
+ PackageInfo packageInfo = mayFakeSignature(p, PackageParser.generatePackageInfo(p, gids, flags,
73+
+ ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId),
74+
+ permissions);
75+
76+
if (packageInfo == null) {
77+
return null;
78+
@@ -3584,6 +3585,24 @@ public class PackageManagerService extends IPackageManager.Stub
79+
return packageInfo;
80+
}
81+
82+
+ private PackageInfo mayFakeSignature(PackageParser.Package p, PackageInfo pi,
83+
+ Set<String> permissions) {
84+
+ try {
85+
+ if (permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")
86+
+ && p.applicationInfo.targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1
87+
+ && p.mAppMetaData != null) {
88+
+ String sig = p.mAppMetaData.getString("fake-signature");
89+
+ if (sig != null) {
90+
+ pi.signatures = new Signature[] {new Signature(sig)};
91+
+ }
92+
+ }
93+
+ } catch (Throwable t) {
94+
+ // We should never die because of any failures, this is system code!
95+
+ Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE", t);
96+
+ }
97+
+ return pi;
98+
+ }
99+
+
100+
@Override
101+
public void checkPackageStartable(String packageName, int userId) {
102+
final int callingUid = Binder.getCallingUid();

0 commit comments

Comments
 (0)