opengapps/aosp_build

Need to patch DefaultPermissionGrantPolicy.java for GApps on 6.0

Closed this issue · 16 comments

If we build gapps in aosp 6.0 source tree, a patch should be applied as Notes-for-Android-6.0 saying

cd frameworks/base
curl https://github.com/TeamExodus/frameworks_base/commit/9c36be651e83fb039a262682839bd920b033007a.patch | patch -p1
acr92 commented

People probably won't read a notice...we can add a compile check to see if the file contains some content we expect.

But...there must be a better way of doing this...I doubt Google uses that patch...usually they just add stuff to an XML file and that fixes everything.

Google benefits that they sign their ROM with the same key as they sign their apps, which automatically grants the permissions to their GApps. (at least that is how I understand it)

acr92 commented

Hmm, what about Samsung, Sony etc?

On Thu, 14 Jan 2016 22:13 mfonville notifications@github.com wrote:

Google benefits that they sign their ROM with the same key as they sign
their apps, which automatically grants the permissions to their GApps. (at
leas that is how I understand it)


Reply to this email directly or view it on GitHub
#12 (comment)
.

We have no clue. We expect that they set these permissions explicit in their source, but we should indeed investigate your comment opengapps/opengapps#93 (comment)

I have a problem with building AOSP 6.0 for Nexus 5 and including opengapps. I created a post on xda too: http://forum.xda-developers.com/showpost.php?p=65355535&postcount=1993

Is everyone having the same issue with pure AOSP builds? From what I understood, on AOSP including the patch from first comment should do the trick and I did it but I still have issues.

That completely did the trick :) Thanks for helping me

acr92 commented

Great. I guess we should add that to our overlays since it's always needed.

fonic commented

The patch linked by jcppkkk is outdated. Until this is added to OpenGApps, here are two patches that work flawlessly with the current Android AOSP 6.0 master branch as of 03/20/16.

# cd ${ANDROID_BUILD_TOP}
# patch -p1 < opengapps_default_permissions.patch
# patch -p1 < opengapps_location_provider.patch

opengapps_default_permissions.patch.txt
opengapps_location_provider.patch.txt

Do you really need the first patch?
I have no issue without this on Marshmallow.

Adding the location provider to the overlay should be enough for Android to accept Google's signature and apply those permissions automatically.

acr92 commented

Adding gms as location provider should be the only thing necessary.

fonic commented

Thanks for the hint! I haven't tested it yet without the first patch.

Editing config.xml file is enough for working Google Play Services, but if you want to grant other permissions to packages. Use Notes for Android 6.0 patch with minor modifications.

PackageParser.Package getDefaultProviderAuthorityPackageLPr(String authority, int userId) will always return null. So grantRuntimePermissionsLPw(PackageParser.Package pkg, Set<String> permissions, int userId) is not executed.

Instead of using PackageParser.Package getDefaultProviderAuthorityPackageLPr(String authority, int userId) function, use PackageParser.Package getPackageLPr(String packageName) function. It will return PackageParser.Package object properly. So granting permissions will be executed.

@Blystad @bomin-kim @fonic I want to add android.permission.INTERACT_ACROSS_USERS permission to com.google.android.gms package. I'm working on Android 4.4.4, and there is no DefaultPermissionGrantPolicy; So patches doesn't work for me. How to edit config.xml file to add such a this permission?
I asked something like this for my problem on SO: Link

acr92 commented

Why do you want to add the permission? What error do you see?

All Google Apps runs as a shared user id, so INTERACT_ACROSS_USERS shouldn't be necessary.