From 2629fe09c28a4b01f839c4f97fd84f3f2672c6bc Mon Sep 17 00:00:00 2001 From: S1m Date: Thu, 16 May 2024 17:48:40 +0000 Subject: [PATCH] Use packageName if targetting app embedding a library --- .../gms/common/MultiConnectionKeeper.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java index a820dd8ccd..2e256af677 100644 --- a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java +++ b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java @@ -38,6 +38,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import static android.os.Build.VERSION.SDK_INT; @@ -130,27 +131,17 @@ private String getTargetPackageWithoutPref() { } catch (PackageManager.NameNotFoundException e) { Log.d(TAG, USER_MICROG_PACKAGE_NAME + " not found"); } - return null; + return context.getPackageName(); } private String getTargetPackage() { SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); - final String SELF = "SELF"; String target; if ((target = prefs.getString(PREF_TARGET, null)) != null) { - switch (target) { - case GMS_PACKAGE_NAME: - case USER_MICROG_PACKAGE_NAME: - return target; - case SELF: - return null; - } - } - if ((target = getTargetPackageWithoutPref()) == null ) { - prefs.edit().putString(PREF_TARGET, SELF).apply(); - } else { - prefs.edit().putString(PREF_TARGET, target).apply(); + return target; } + target = getTargetPackageWithoutPref(); + prefs.edit().putString(PREF_TARGET, target).apply(); return target; } @@ -251,7 +242,7 @@ public Connection(String actionString, boolean requireMicrog) { private Intent getIntent() { Intent intent; ResolveInfo resolveInfo; - if (targetPackage != null) { + if (!Objects.equals(targetPackage, context.getPackageName())) { intent = new Intent(actionString).setPackage(targetPackage); if ((resolveInfo = context.getPackageManager().resolveService(intent, 0)) != null) { if (requireMicrog && !isMicrog(resolveInfo)) {