-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add patch for Android Q #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,88 @@ | ||||||||
| diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml | ||||||||
| index a3fccd96f22..383c702955f 100644 | ||||||||
| --- a/core/res/AndroidManifest.xml | ||||||||
| +++ b/core/res/AndroidManifest.xml | ||||||||
| @@ -2628,6 +2628,13 @@ | ||||||||
| android:description="@string/permdesc_getPackageSize" | ||||||||
| android:protectionLevel="normal" /> | ||||||||
|
|
||||||||
| + <!-- @hide Allows an application to change the package signature as | ||||||||
| + seen by applications --> | ||||||||
| + <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE" | ||||||||
| + android:protectionLevel="dangerous" | ||||||||
| + android:label="@string/permlab_fakePackageSignature" | ||||||||
| + android:description="@string/permdesc_fakePackageSignature" /> | ||||||||
| + | ||||||||
| <!-- @deprecated No longer useful, see | ||||||||
| {@link android.content.pm.PackageManager#addPackageToPreferred} | ||||||||
| for details. --> | ||||||||
| diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml | ||||||||
| index 0391530c483..5df70cc1bd1 100644 | ||||||||
| --- a/core/res/res/values/config.xml | ||||||||
| +++ b/core/res/res/values/config.xml | ||||||||
| @@ -1855,6 +1855,8 @@ | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| <string-array name="config_locationProviderPackageNames" translatable="false"> | ||||||||
| <!-- The standard AOSP fused location provider --> | ||||||||
| <item>com.android.location.fused</item> | ||||||||
| + <!-- The (faked) microg fused location provider (a free reimplementation) --> | ||||||||
| + <item>com.google.android.gms</item> | ||||||||
| </string-array> | ||||||||
|
|
||||||||
| <!-- This string array can be overriden to enable test location providers initially. --> | ||||||||
| diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml | ||||||||
| index 152b131af8f..f8d87a37064 100644 | ||||||||
| --- a/core/res/res/values/strings.xml | ||||||||
| +++ b/core/res/res/values/strings.xml | ||||||||
| @@ -827,6 +827,11 @@ | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
delete |
||||||||
| <!-- Permissions --> | ||||||||
|
|
||||||||
| + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> | ||||||||
| + <string name="permlab_fakePackageSignature">Spoof package signature</string> | ||||||||
| + <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> | ||||||||
| + <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> | ||||||||
| + | ||||||||
| <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> | ||||||||
| <string name="permlab_statusBar">disable or modify status bar</string> | ||||||||
| <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java | ||||||||
| index 7469e099421..48e78eff9db 100644 | ||||||||
| --- a/services/core/java/com/android/server/pm/PackageManagerService.java | ||||||||
| +++ b/services/core/java/com/android/server/pm/PackageManagerService.java | ||||||||
| @@ -4092,8 +4092,9 @@ public class PackageManagerService extends IPackageManager.Stub | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| final Set<String> permissions = ArrayUtils.isEmpty(p.requestedPermissions) | ||||||||
| ? Collections.emptySet() : permissionsState.getPermissions(userId); | ||||||||
|
|
||||||||
| - PackageInfo packageInfo = PackageParser.generatePackageInfo(p, gids, flags, | ||||||||
| - ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId); | ||||||||
| + PackageInfo packageInfo = mayFakeSignature(p, PackageParser.generatePackageInfo(p, gids, flags, | ||||||||
| + ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId), | ||||||||
| + permissions); | ||||||||
|
|
||||||||
| if (packageInfo == null) { | ||||||||
| return null; | ||||||||
| @@ -4129,6 +4130,24 @@ public class PackageManagerService extends IPackageManager.Stub | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| + private PackageInfo mayFakeSignature(PackageParser.Package p, PackageInfo pi, | ||||||||
| + Set<String> 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); | ||||||||
| + } | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you fix the indentation here? |
||||||||
| + return pi; | ||||||||
| + } | ||||||||
| + | ||||||||
| @Override | ||||||||
| public void checkPackageStartable(String packageName, int userId) { | ||||||||
| final int callingUid = Binder.getCallingUid(); | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.