mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-30 22:45:47 +01:00
Update base
This commit is contained in:
parent
0bdcb1319b
commit
050afb8f87
@ -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;
|
||||
}
|
||||
|
@ -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,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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -7,6 +7,7 @@ package org.microg.gms.common.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.DeadObjectException;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.api.Api;
|
||||
|
@ -32,11 +32,11 @@ import org.microg.safeparcel.SafeParceled;
|
||||
@PublicApi
|
||||
public final class Status extends AutoSafeParcelable implements Result {
|
||||
@PublicApi(exclude = true)
|
||||
public static final Status INTERNAL_ERROR = new Status(CommonStatusCodes.INTERNAL_ERROR);
|
||||
public static final Status INTERNAL_ERROR = new Status(CommonStatusCodes.INTERNAL_ERROR, "Internal error");
|
||||
@PublicApi(exclude = true)
|
||||
public static final Status CANCELED = new Status(CommonStatusCodes.CANCELED);
|
||||
public static final Status CANCELED = new Status(CommonStatusCodes.CANCELED, "Cancelled");
|
||||
@PublicApi(exclude = true)
|
||||
public static final Status SUCCESS = new Status(CommonStatusCodes.SUCCESS);
|
||||
public static final Status SUCCESS = new Status(CommonStatusCodes.SUCCESS, "Success");
|
||||
|
||||
@SafeParceled(1000)
|
||||
private int versionCode = 1;
|
||||
|
@ -57,6 +57,10 @@ public class GetServiceRequest extends AutoSafeParcelable {
|
||||
private boolean field12;
|
||||
@Field(13)
|
||||
private int field13;
|
||||
@Field(14)
|
||||
private boolean field14;
|
||||
@Field(15)
|
||||
private String field15;
|
||||
|
||||
private GetServiceRequest() {
|
||||
serviceId = -1;
|
||||
|
@ -33,7 +33,7 @@ public enum GmsService {
|
||||
ADDRESS(12, "com.google.android.gms.identity.service.BIND"),
|
||||
CAR(13, "com.google.android.gms.car.service.START"),
|
||||
WEARABLE(14, "com.google.android.gms.wearable.BIND"),
|
||||
AUTH(16, "com.google.android.gms.auth.service.START"),
|
||||
AUTH_PROXY(16, "com.google.android.gms.auth.service.START"),
|
||||
FITNESS(17, "com.google.android.gms.fitness.GoogleFitnessService.START"),
|
||||
REMINDERS(18, "com.google.android.gms.reminders.service.START"),
|
||||
LIGHTWEIGHT_INDEX(19, "com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE"),
|
||||
@ -103,9 +103,12 @@ public enum GmsService {
|
||||
APP_INDEXING(113),
|
||||
GASS(116, "com.google.android.gms.gass.START"),
|
||||
WORK_ACCOUNT(120),
|
||||
INSTANT_APPS(121, "com.google.android.gms.instantapps.START"),
|
||||
CAST_FIRSTPATY(122, "com.google.android.gms.cast.firstparty.START"),
|
||||
AD_CACHE(123, "com.google.android.gms.ads.service.CACHE"),
|
||||
CRYPT_AUTH(129, "com.google.android.gms.auth.cryptauth.cryptauthservice.START"),
|
||||
DYNAMIC_LINKS(131, "com.google.firebase.dynamiclinks.service.START"),
|
||||
FONTS(132, "com.google.android.gms.fonts.service.START"),
|
||||
ROMANESCO(135, "com.google.android.gms.romanesco.service.START"),
|
||||
TRAINER(139, "com.google.android.gms.learning.trainer.START"),
|
||||
FIDO2_REGULAR(148, "com.google.android.gms.fido.fido2.regular.START"),
|
||||
@ -116,14 +119,19 @@ public enum GmsService {
|
||||
AUDIT(154, "com.google.android.gms.audit.service.START"),
|
||||
SYSTEM_UPDATE(157, "com.google.android.gms.update.START_API_SERVICE"),
|
||||
USER_LOCATION(163, "com.google.android.gms.userlocation.service.START"),
|
||||
AD_HTTP(166, "com.google.android.gms.ads.service.HTTP"),
|
||||
LANGUAGE_PROFILE(167, "com.google.android.gms.languageprofile.service.START"),
|
||||
MDNS(168, "com.google.android.gms.mdns.service.START"),
|
||||
FIDO2_ZEROPARTY(180, "com.google.android.gms.fido.fido2.zeroparty.START"),
|
||||
G1_RESTORE(181, "com.google.android.gms.backup.G1_RESTORE"),
|
||||
G1_BACKUP(182, "com.google.android.gms.backup.G1_BACKUP"),
|
||||
PAYSE(188, "com.google.android.gms.payse.service.BIND"),
|
||||
RCS(189, "com.google.android.gms.rcs.START"),
|
||||
CARRIER_AUTH(191, "com.google.android.gms.carrierauth.service.START"),
|
||||
SYSTEM_UPDATE_SINGLE_UESR(192, "com.google.android.gms.update.START_SINGLE_USER_API_SERVICE"),
|
||||
APP_USAGE(193, "com.google.android.gms.appusage.service.START"),
|
||||
NEARBY_SHARING_2(194, "com.google.android.gms.nearby.sharing.START_SERVICE"),
|
||||
AD_CONSENT_LOOKUP(195, "com.google.android.gms.ads.service.CONSENT_LOOKUP"),
|
||||
PHONE_INTERNAL(197, "com.google.android.gms.auth.api.phone.service.InternalService.START"),
|
||||
PAY(198, "com.google.android.gms.pay.service.BIND"),
|
||||
ASTERISM(199, "com.google.android.gms.asterism.service.START"),
|
||||
@ -137,12 +145,22 @@ public enum GmsService {
|
||||
SCHEDULER(218, "com.google.android.gms.scheduler.ACTION_PROXY_SCHEDULE"),
|
||||
AUTHORIZATION(219, "com.google.android.gms.auth.api.identity.service.authorization.START"),
|
||||
FACS_SYNC(220, "com.google.android.gms.facs.internal.service.START"),
|
||||
CONFIG_SYNC(221, "com.google.android.gms.auth.config.service.START"),
|
||||
AUTH_CONFIG_SYNC(221, "com.google.android.gms.auth.config.service.START"),
|
||||
CREDENTIAL_SAVING(223, "com.google.android.gms.auth.api.identity.service.credentialsaving.START"),
|
||||
GOOGLE_AUTH(224, "com.google.android.gms.auth.account.authapi.START"),
|
||||
ENTERPRISE_LOADER(225, "com.google.android.gms.enterprise.loader.service.START"),
|
||||
THUNDERBIRD(226, "com.google.android.gms.thunderbird.service.START"),
|
||||
NEARBY_EXPOSURE(236, "com.google.android.gms.nearby.exposurenotification.START"),
|
||||
GMS_COMPLIANCE(257, "com.google.android.gms.gmscompliance.service.START"),
|
||||
FIDO_SOURCE_DEVICE(262, "com.google.android.gms.fido.sourcedevice.service.START"),
|
||||
FAST_PAIR(265, "com.google.android.gms.nearby.fastpair.START"),
|
||||
MATCHSTICK_LIGHTER(268, "com.google.android.gms.matchstick.lighter.service.START"),
|
||||
FIDO_TARGET_DEVICE_INTERNAL(269, "com.google.android.gms.fido.targetdevice.internal_service.START"),
|
||||
TELEMETRY(270, "com.google.android.gms.common.telemetry.service.START"),
|
||||
SECOND_DEVICE_AUTH(275, "com.google.android.gms.setup.auth.SecondDeviceAuth.START"),
|
||||
LOCATION_SHARING_REPORTER(277, "com.google.android.gms.locationsharingreporter.service.START"),
|
||||
OCR(279, "com.google.android.gms.ocr.service.START"),
|
||||
OCR_INTERNAL(281, "com.google.android.gms.ocr.service.internal.START"),
|
||||
;
|
||||
|
||||
public int SERVICE_ID;
|
||||
|
Loading…
Reference in New Issue
Block a user