Loading build.gradle +5 −6 Original line number Diff line number Diff line Loading @@ -5,18 +5,17 @@ buildscript { ext.cronetVersion = '102.5005.125' ext.nlpVersion = '2.0-alpha10' ext.safeParcelVersion = '1.7.0' ext.safeParcelVersion = '1.7.1' ext.wearableVersion = '0.1.1' ext.kotlinVersion = '1.7.10' ext.coroutineVersion = '1.6.4' ext.annotationVersion = '1.5.0' ext.appcompatVersion = '1.4.2' ext.appcompatVersion = '1.6.1' ext.biometricVersion = '1.1.0' ext.coreVersion = '1.8.0' ext.fragmentVersion = '1.5.1' ext.coreVersion = '1.9.0' ext.fragmentVersion = '1.5.5' ext.lifecycleVersion = '2.5.1' ext.loaderVersion = '1.1.0' ext.mediarouterVersion = '1.3.1' Loading @@ -36,7 +35,7 @@ buildscript { ext.androidMinSdk = 21 ext.androidTargetSdk = 29 ext.androidCompileSdk = 31 ext.androidCompileSdk = 33 repositories { mavenCentral() Loading play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt +63 −36 Original line number Diff line number Diff line Loading @@ -67,19 +67,29 @@ object ProfileManager { PROFILE_AUTO -> false PROFILE_REAL -> false PROFILE_NATIVE -> true else -> getProfileXml(context, profile)?.use { var next = it.next() else -> { val parser = getProfileXml(context, profile) if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { XmlPullParser.START_TAG -> when (parser.name) { "profile" -> { return@use it.getAttributeBooleanValue(null, "auto", false) return@runCatching parser.getAttributeBooleanValue(null, "auto", false) } } } next = it.next() next = parser.next() } } finally { parser.close() } false } else { false } } } == true } }.getOrDefault(false) Loading @@ -90,20 +100,25 @@ object ProfileManager { if (profileResId == 0) return realData val resultData = mutableMapOf<String, String>() resultData.putAll(realData) getProfileXml(context, profile)?.use { var next = it.next() val parser = getProfileXml(context, profile) if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { XmlPullParser.START_TAG -> when (parser.name) { "data" -> { val key = it.getAttributeValue(null, "key") val value = it.getAttributeValue(null, "value") val key = parser.getAttributeValue(null, "key") val value = parser.getAttributeValue(null, "value") resultData[key] = value Log.d(TAG, "Overwrite from profile: $key = $value") } } } next = it.next() next = parser.next() } } finally { parser.close() } } return resultData Loading Loading @@ -151,15 +166,20 @@ object ProfileManager { // From profile try { getProfileXml(context, profile)?.use { var next = it.next() val parser = getProfileXml(context, profile) if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { "serial" -> return it.getAttributeValue(null, "template") XmlPullParser.START_TAG -> when (parser.name) { "serial" -> return parser.getAttributeValue(null, "template") } } next = parser.next() } next = it.next() } finally { parser.close() } } } catch (e: Exception) { Loading Loading @@ -274,19 +294,26 @@ object ProfileManager { fun getProfileName(context: Context, profile: String): String? = getProfileName { getProfileXml(context, profile) } private fun getProfileName(parserCreator: () -> XmlResourceParser?): String? = parserCreator()?.use { var next = it.next() private fun getProfileName(parserCreator: () -> XmlResourceParser?): String? { val parser = parserCreator() if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { XmlPullParser.START_TAG -> when (parser.name) { "profile" -> { return@use it.getAttributeValue(null, "name") return parser.getAttributeValue(null, "name") } } } next = parser.next() } } finally { parser.close() } next = it.next() } null return null } fun setProfile(context: Context, profile: String?) { Loading play-services-base/src/main/java/org/microg/gms/common/GmsClient.java +8 −2 Original line number Diff line number Diff line Loading @@ -46,17 +46,23 @@ public abstract class GmsClient<I extends IInterface> implements ApiClient { protected ConnectionState state = ConnectionState.NOT_CONNECTED; private ServiceConnection serviceConnection; private I serviceInterface; private String actionString; private final String actionString; private final boolean requireMicrog; protected int serviceId = -1; protected Account account = null; protected Bundle extras = new Bundle(); public GmsClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener, String actionString) { this(context, callbacks, connectionFailedListener, actionString, false); } public GmsClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener, String actionString, boolean requireMicrog) { this.context = context; this.callbacks = callbacks; this.connectionFailedListener = connectionFailedListener; this.actionString = actionString; this.requireMicrog = requireMicrog; } protected void onConnectedToBroker(IGmsServiceBroker broker, GmsCallbacks callbacks) throws RemoteException { Loading Loading @@ -84,7 +90,7 @@ public abstract class GmsClient<I extends IInterface> implements ApiClient { MultiConnectionKeeper.getInstance(context).unbind(actionString, serviceConnection); } serviceConnection = new GmsServiceConnection(); if (!MultiConnectionKeeper.getInstance(context).bind(actionString, serviceConnection)) { if (!MultiConnectionKeeper.getInstance(context).bind(actionString, serviceConnection, requireMicrog)) { state = ConnectionState.ERROR; handleConnectionFailed(); } Loading play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java +38 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,10 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PermissionInfo; import android.content.pm.ResolveInfo; import android.os.IBinder; import android.util.Log; Loading Loading @@ -52,7 +56,11 @@ public class MultiConnectionKeeper { } public synchronized boolean bind(String action, ServiceConnection connection) { Log.d(TAG, "bind(" + action + ", " + connection + ")"); return bind(action, connection, false); } public synchronized boolean bind(String action, ServiceConnection connection, boolean requireMicrog) { Log.d(TAG, "bind(" + action + ", " + connection + ", " + requireMicrog + ")"); Connection con = connections.get(action); if (con != null) { if (!con.forwardsConnection(connection)) { Loading @@ -61,7 +69,7 @@ public class MultiConnectionKeeper { con.bind(); } } else { con = new Connection(action); con = new Connection(action, requireMicrog); con.addConnectionForward(connection); con.bind(); connections.put(action, con); Loading @@ -83,6 +91,7 @@ public class MultiConnectionKeeper { public class Connection { private final String actionString; private final boolean requireMicrog; private final Set<ServiceConnection> connectionForwards = new HashSet<ServiceConnection>(); private boolean bound = false; private boolean connected = false; Loading Loading @@ -116,7 +125,12 @@ public class MultiConnectionKeeper { }; public Connection(String actionString) { this(actionString, false); } public Connection(String actionString, boolean requireMicrog) { this.actionString = actionString; this.requireMicrog = requireMicrog; } @SuppressLint("InlinedApi") Loading @@ -125,7 +139,8 @@ public class MultiConnectionKeeper { Intent gmsIntent = new Intent(actionString).setPackage(GMS_PACKAGE_NAME); Intent selfIntent = new Intent(actionString).setPackage(context.getPackageName()); Intent intent; if (context.getPackageManager().resolveService(gmsIntent, 0) == null) { ResolveInfo resolveInfo; if ((resolveInfo = context.getPackageManager().resolveService(gmsIntent, 0)) == null) { Log.w(TAG, "No GMS service found for " + actionString); if (context.getPackageManager().resolveService(selfIntent, 0) != null) { Log.d(TAG, "Found service for " + actionString + " in self package, using it instead"); Loading @@ -133,6 +148,14 @@ public class MultiConnectionKeeper { } else { return; } } else if (requireMicrog && !isMicrog(resolveInfo)) { Log.w(TAG, "GMS service found for " + actionString + " but looks not like microG"); if (context.getPackageManager().resolveService(selfIntent, 0) != null) { Log.d(TAG, "Found service for " + actionString + " in self package, using it instead"); intent = selfIntent; } else { intent = gmsIntent; } } else { intent = gmsIntent; } Loading @@ -146,6 +169,17 @@ public class MultiConnectionKeeper { } } public boolean isMicrog(ResolveInfo resolveInfo) { if (resolveInfo == null || resolveInfo.serviceInfo == null) return false; if (resolveInfo.serviceInfo.name.startsWith("org.microg.")) return true; try { PermissionInfo info = context.getPackageManager().getPermissionInfo("org.microg.gms.EXTENDED_ACCESS", 0); return info.packageName.equals(resolveInfo.serviceInfo.packageName); } catch (PackageManager.NameNotFoundException e) { return false; } } public boolean isBound() { return bound; } Loading play-services-basement/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java +3 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ import java.util.Arrays; public class GetServiceRequest extends AutoSafeParcelable { @Field(1) private int versionCode = 4; private int versionCode = 6; @Field(2) public final int serviceId; @Field(3) Loading @@ -48,6 +48,7 @@ public class GetServiceRequest extends AutoSafeParcelable { @Field(8) public Account account; @Field(9) @Deprecated private long field9; @Field(10) public Feature[] defaultFeatures; Loading @@ -60,7 +61,7 @@ public class GetServiceRequest extends AutoSafeParcelable { @Field(14) private boolean field14; @Field(15) private String field15; private String attributionTag; private GetServiceRequest() { serviceId = -1; Loading Loading
build.gradle +5 −6 Original line number Diff line number Diff line Loading @@ -5,18 +5,17 @@ buildscript { ext.cronetVersion = '102.5005.125' ext.nlpVersion = '2.0-alpha10' ext.safeParcelVersion = '1.7.0' ext.safeParcelVersion = '1.7.1' ext.wearableVersion = '0.1.1' ext.kotlinVersion = '1.7.10' ext.coroutineVersion = '1.6.4' ext.annotationVersion = '1.5.0' ext.appcompatVersion = '1.4.2' ext.appcompatVersion = '1.6.1' ext.biometricVersion = '1.1.0' ext.coreVersion = '1.8.0' ext.fragmentVersion = '1.5.1' ext.coreVersion = '1.9.0' ext.fragmentVersion = '1.5.5' ext.lifecycleVersion = '2.5.1' ext.loaderVersion = '1.1.0' ext.mediarouterVersion = '1.3.1' Loading @@ -36,7 +35,7 @@ buildscript { ext.androidMinSdk = 21 ext.androidTargetSdk = 29 ext.androidCompileSdk = 31 ext.androidCompileSdk = 33 repositories { mavenCentral() Loading
play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt +63 −36 Original line number Diff line number Diff line Loading @@ -67,19 +67,29 @@ object ProfileManager { PROFILE_AUTO -> false PROFILE_REAL -> false PROFILE_NATIVE -> true else -> getProfileXml(context, profile)?.use { var next = it.next() else -> { val parser = getProfileXml(context, profile) if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { XmlPullParser.START_TAG -> when (parser.name) { "profile" -> { return@use it.getAttributeBooleanValue(null, "auto", false) return@runCatching parser.getAttributeBooleanValue(null, "auto", false) } } } next = it.next() next = parser.next() } } finally { parser.close() } false } else { false } } } == true } }.getOrDefault(false) Loading @@ -90,20 +100,25 @@ object ProfileManager { if (profileResId == 0) return realData val resultData = mutableMapOf<String, String>() resultData.putAll(realData) getProfileXml(context, profile)?.use { var next = it.next() val parser = getProfileXml(context, profile) if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { XmlPullParser.START_TAG -> when (parser.name) { "data" -> { val key = it.getAttributeValue(null, "key") val value = it.getAttributeValue(null, "value") val key = parser.getAttributeValue(null, "key") val value = parser.getAttributeValue(null, "value") resultData[key] = value Log.d(TAG, "Overwrite from profile: $key = $value") } } } next = it.next() next = parser.next() } } finally { parser.close() } } return resultData Loading Loading @@ -151,15 +166,20 @@ object ProfileManager { // From profile try { getProfileXml(context, profile)?.use { var next = it.next() val parser = getProfileXml(context, profile) if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { "serial" -> return it.getAttributeValue(null, "template") XmlPullParser.START_TAG -> when (parser.name) { "serial" -> return parser.getAttributeValue(null, "template") } } next = parser.next() } next = it.next() } finally { parser.close() } } } catch (e: Exception) { Loading Loading @@ -274,19 +294,26 @@ object ProfileManager { fun getProfileName(context: Context, profile: String): String? = getProfileName { getProfileXml(context, profile) } private fun getProfileName(parserCreator: () -> XmlResourceParser?): String? = parserCreator()?.use { var next = it.next() private fun getProfileName(parserCreator: () -> XmlResourceParser?): String? { val parser = parserCreator() if (parser != null) { try { var next = parser.next() while (next != XmlPullParser.END_DOCUMENT) { when (next) { XmlPullParser.START_TAG -> when (it.name) { XmlPullParser.START_TAG -> when (parser.name) { "profile" -> { return@use it.getAttributeValue(null, "name") return parser.getAttributeValue(null, "name") } } } next = parser.next() } } finally { parser.close() } next = it.next() } null return null } fun setProfile(context: Context, profile: String?) { Loading
play-services-base/src/main/java/org/microg/gms/common/GmsClient.java +8 −2 Original line number Diff line number Diff line Loading @@ -46,17 +46,23 @@ public abstract class GmsClient<I extends IInterface> implements ApiClient { protected ConnectionState state = ConnectionState.NOT_CONNECTED; private ServiceConnection serviceConnection; private I serviceInterface; private String actionString; private final String actionString; private final boolean requireMicrog; protected int serviceId = -1; protected Account account = null; protected Bundle extras = new Bundle(); public GmsClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener, String actionString) { this(context, callbacks, connectionFailedListener, actionString, false); } public GmsClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener, String actionString, boolean requireMicrog) { this.context = context; this.callbacks = callbacks; this.connectionFailedListener = connectionFailedListener; this.actionString = actionString; this.requireMicrog = requireMicrog; } protected void onConnectedToBroker(IGmsServiceBroker broker, GmsCallbacks callbacks) throws RemoteException { Loading Loading @@ -84,7 +90,7 @@ public abstract class GmsClient<I extends IInterface> implements ApiClient { MultiConnectionKeeper.getInstance(context).unbind(actionString, serviceConnection); } serviceConnection = new GmsServiceConnection(); if (!MultiConnectionKeeper.getInstance(context).bind(actionString, serviceConnection)) { if (!MultiConnectionKeeper.getInstance(context).bind(actionString, serviceConnection, requireMicrog)) { state = ConnectionState.ERROR; handleConnectionFailed(); } Loading
play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java +38 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,10 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PermissionInfo; import android.content.pm.ResolveInfo; import android.os.IBinder; import android.util.Log; Loading Loading @@ -52,7 +56,11 @@ public class MultiConnectionKeeper { } public synchronized boolean bind(String action, ServiceConnection connection) { Log.d(TAG, "bind(" + action + ", " + connection + ")"); return bind(action, connection, false); } public synchronized boolean bind(String action, ServiceConnection connection, boolean requireMicrog) { Log.d(TAG, "bind(" + action + ", " + connection + ", " + requireMicrog + ")"); Connection con = connections.get(action); if (con != null) { if (!con.forwardsConnection(connection)) { Loading @@ -61,7 +69,7 @@ public class MultiConnectionKeeper { con.bind(); } } else { con = new Connection(action); con = new Connection(action, requireMicrog); con.addConnectionForward(connection); con.bind(); connections.put(action, con); Loading @@ -83,6 +91,7 @@ public class MultiConnectionKeeper { public class Connection { private final String actionString; private final boolean requireMicrog; private final Set<ServiceConnection> connectionForwards = new HashSet<ServiceConnection>(); private boolean bound = false; private boolean connected = false; Loading Loading @@ -116,7 +125,12 @@ public class MultiConnectionKeeper { }; public Connection(String actionString) { this(actionString, false); } public Connection(String actionString, boolean requireMicrog) { this.actionString = actionString; this.requireMicrog = requireMicrog; } @SuppressLint("InlinedApi") Loading @@ -125,7 +139,8 @@ public class MultiConnectionKeeper { Intent gmsIntent = new Intent(actionString).setPackage(GMS_PACKAGE_NAME); Intent selfIntent = new Intent(actionString).setPackage(context.getPackageName()); Intent intent; if (context.getPackageManager().resolveService(gmsIntent, 0) == null) { ResolveInfo resolveInfo; if ((resolveInfo = context.getPackageManager().resolveService(gmsIntent, 0)) == null) { Log.w(TAG, "No GMS service found for " + actionString); if (context.getPackageManager().resolveService(selfIntent, 0) != null) { Log.d(TAG, "Found service for " + actionString + " in self package, using it instead"); Loading @@ -133,6 +148,14 @@ public class MultiConnectionKeeper { } else { return; } } else if (requireMicrog && !isMicrog(resolveInfo)) { Log.w(TAG, "GMS service found for " + actionString + " but looks not like microG"); if (context.getPackageManager().resolveService(selfIntent, 0) != null) { Log.d(TAG, "Found service for " + actionString + " in self package, using it instead"); intent = selfIntent; } else { intent = gmsIntent; } } else { intent = gmsIntent; } Loading @@ -146,6 +169,17 @@ public class MultiConnectionKeeper { } } public boolean isMicrog(ResolveInfo resolveInfo) { if (resolveInfo == null || resolveInfo.serviceInfo == null) return false; if (resolveInfo.serviceInfo.name.startsWith("org.microg.")) return true; try { PermissionInfo info = context.getPackageManager().getPermissionInfo("org.microg.gms.EXTENDED_ACCESS", 0); return info.packageName.equals(resolveInfo.serviceInfo.packageName); } catch (PackageManager.NameNotFoundException e) { return false; } } public boolean isBound() { return bound; } Loading
play-services-basement/src/main/java/com/google/android/gms/common/internal/GetServiceRequest.java +3 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ import java.util.Arrays; public class GetServiceRequest extends AutoSafeParcelable { @Field(1) private int versionCode = 4; private int versionCode = 6; @Field(2) public final int serviceId; @Field(3) Loading @@ -48,6 +48,7 @@ public class GetServiceRequest extends AutoSafeParcelable { @Field(8) public Account account; @Field(9) @Deprecated private long field9; @Field(10) public Feature[] defaultFeatures; Loading @@ -60,7 +61,7 @@ public class GetServiceRequest extends AutoSafeParcelable { @Field(14) private boolean field14; @Field(15) private String field15; private String attributionTag; private GetServiceRequest() { serviceId = -1; Loading