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-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationApiClient.java +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ import org.microg.gms.common.api.OnConnectionFailedListener; public class ExposureNotificationApiClient extends GmsClient<INearbyExposureNotificationService> { public ExposureNotificationApiClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener) { super(context, callbacks, connectionFailedListener, GmsService.NEARBY_EXPOSURE.ACTION); super(context, callbacks, connectionFailedListener, GmsService.NEARBY_EXPOSURE.ACTION, true); serviceId = GmsService.NEARBY_EXPOSURE.SERVICE_ID; } Loading 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-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationApiClient.java +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ import org.microg.gms.common.api.OnConnectionFailedListener; public class ExposureNotificationApiClient extends GmsClient<INearbyExposureNotificationService> { public ExposureNotificationApiClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener) { super(context, callbacks, connectionFailedListener, GmsService.NEARBY_EXPOSURE.ACTION); super(context, callbacks, connectionFailedListener, GmsService.NEARBY_EXPOSURE.ACTION, true); serviceId = GmsService.NEARBY_EXPOSURE.SERVICE_ID; } Loading