microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
7.63k stars 1.61k forks source link

patch to accept a network location provider outside of /system #1556

Open fbellet opened 2 years ago

fbellet commented 2 years ago

Hi!

When building a custom rom (lineage 18.1), with the goal to add microg as a regular user package (from f-droid for example), I had to apply a supplementary patch to frameworks/base, to make it accept network location providers outside of /system (the spoofing signature patches from lineageos4microg /docker-lineage-cicd were not enough).

So, in my case, I had to add this patch from UnifiedNlp/patches/android_frameworks_base-N.patch to my custom rom, and slightly adapt it for R. (it applied just fine for Q, IIRC).

Maybe this could be more explicitly advertised in the documentation ?

klemens commented 2 years ago

@fbellet: Thanks for then hint, I face the same problem and will give it a try. I guess you just removed the MATCH_SYSTEM_ONLY flag in the register and onBestServiceChanged methods?

fbellet commented 2 years ago

Yes, exactly.

klemens commented 2 years ago

I can now also confirm that with the following patch network locations work just fine with microg installed as a normal application on Android 11 (Lineage-based rom with the signature spoofing patches from lineageos4microg/docker-lineage-cicd):

diff --git a/services/core/java/com/android/server/ServiceWatcher.java b/services/core/java/com/android/server/ServiceWatcher.java
index b1b5ec01df6a..3923e1b6cf9a 100644
--- a/services/core/java/com/android/server/ServiceWatcher.java
+++ b/services/core/java/com/android/server/ServiceWatcher.java
@@ -220,7 +220,7 @@ public class ServiceWatcher implements ServiceConnection {
      */
     public boolean register() {
         if (mContext.getPackageManager().queryIntentServicesAsUser(mIntent,
-                MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE | MATCH_SYSTEM_ONLY,
+                MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
                 UserHandle.USER_SYSTEM).isEmpty()) {
             return false;
         }
@@ -295,7 +295,7 @@ public class ServiceWatcher implements ServiceConnection {

         List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentServicesAsUser(
                 mIntent,
-                GET_META_DATA | MATCH_DIRECT_BOOT_AUTO | MATCH_SYSTEM_ONLY,
+                GET_META_DATA | MATCH_DIRECT_BOOT_AUTO,
                 mCurrentUserId);

         ServiceInfo bestServiceInfo = ServiceInfo.NONE;