Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 050afb8f authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Update base

parent 0bdcb131
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -29,16 +29,19 @@ import com.google.android.gms.common.internal.IGmsServiceBroker;

import org.microg.gms.common.GmsService;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.EnumSet;

public abstract class BaseService extends LifecycleService {
    private final IGmsServiceBroker broker;
    private final EnumSet<GmsService> services;
    protected final String TAG;

    public BaseService(String tag, GmsService supportedService, GmsService... supportedServices) {
        this.TAG = tag;
        EnumSet<GmsService> services = EnumSet.of(supportedService);
        services = EnumSet.of(supportedService);
        services.addAll(Arrays.asList(supportedServices));
        broker = new AbstractGmsServiceBroker(services) {
            @Override
@@ -61,5 +64,10 @@ public abstract class BaseService extends LifecycleService {
        return broker.asBinder();
    }

    @Override
    protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        writer.println(TAG + " providing services " + services.toString());
    }

    public abstract void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException;
}
+37 −0
Original line number Diff line number Diff line
@@ -137,6 +137,30 @@ public class PackageUtils {
        return null;
    }

    @Nullable
    public static byte[] firstSignatureDigestBytes(Context context, String packageName) {
        return firstSignatureDigestBytes(context.getPackageManager(), packageName);
    }

    @Nullable
    public static byte[] firstSignatureDigestBytes(PackageManager packageManager, String packageName) {
        final PackageInfo info;
        try {
            info = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
        } catch (PackageManager.NameNotFoundException e) {
            return null;
        }
        if (info != null && info.signatures != null && info.signatures.length > 0) {
            for (Signature sig : info.signatures) {
                byte[] digest = sha1bytes(sig.toByteArray());
                if (digest != null) {
                    return digest;
                }
            }
        }
        return null;
    }

    @Nullable
    public static String getCallingPackage(Context context) {
        int callingUid = Binder.getCallingUid(), callingPid = Binder.getCallingPid();
@@ -311,6 +335,19 @@ public class PackageUtils {
        return null;
    }

    public static byte[] sha1bytes(byte[] bytes) {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("SHA1");
        } catch (final NoSuchAlgorithmException e) {
            return null;
        }
        if (md != null) {
            return md.digest(bytes);
        }
        return null;
    }

    public static int versionCode(Context context, String packageName) {
        try {
            return context.getPackageManager().getPackageInfo(packageName, 0).versionCode;
+6 −3
Original line number Diff line number Diff line
@@ -6,16 +6,19 @@
package org.microg.gms.utils

import android.os.Binder
import android.os.IBinder
import android.os.Parcel
import android.util.Log

fun warnOnTransactionIssues(tag: String, code: Int, reply: Parcel?, flags: Int, base: () -> Boolean): Boolean {
private const val TAG = "BinderUtils"

fun IBinder.warnOnTransactionIssues(code: Int, reply: Parcel?, flags: Int, base: () -> Boolean): Boolean {
    if (base.invoke()) {
        if ((flags and Binder.FLAG_ONEWAY) > 0 && (reply?.dataSize() ?: 0) > 0) {
            Log.w(tag, "onTransact[$code] is oneway, but returned data")
            Log.w(TAG, "Method $code in $interfaceDescriptor is oneway, but returned data")
        }
        return true
    }
    Log.w(tag, "onTransact[$code] is not processed.")
    Log.w(TAG, "Unknown method $code in $interfaceDescriptor, skipping")
    return (flags and Binder.FLAG_ONEWAY) > 0 // Don't return false on oneway transaction to suppress warning
}
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ open class PackageManagerWrapper(private val wrapped: PackageManager) : PackageM
        return wrapped.getPermissionInfo(permName, flags)
    }

    override fun queryPermissionsByGroup(permissionGroup: String, flags: Int): MutableList<PermissionInfo> {
    override fun queryPermissionsByGroup(permissionGroup: String?, flags: Int): MutableList<PermissionInfo> {
        return wrapped.queryPermissionsByGroup(permissionGroup, flags)
    }

+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public abstract class GmsClient<I extends IInterface> implements ApiClient {

    @Override
    public synchronized boolean isConnected() {
        return state == ConnectionState.CONNECTED || state == ConnectionState.PSEUDO_CONNECTED;
        return (state == ConnectionState.CONNECTED && serviceInterface != null && serviceInterface.asBinder().isBinderAlive() ) || state == ConnectionState.PSEUDO_CONNECTED;
    }

    @Override
Loading