0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-27 05:33:00 +00:00

Add Google Certificates API

This commit is contained in:
Marvin W 2019-06-30 18:34:55 +02:00
parent dc895b4e03
commit bfe649fc36
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
5 changed files with 164 additions and 0 deletions

View file

@ -0,0 +1,3 @@
package com.google.android.gms.common.internal;
parcelable GoogleCertificatesQuery;

View file

@ -0,0 +1,8 @@
package com.google.android.gms.common.internal;
import com.google.android.gms.dynamic.IObjectWrapper;
interface ICertData {
IObjectWrapper getWrappedBytes();
int remoteHashCode();
}

View file

@ -0,0 +1,12 @@
package com.google.android.gms.common.internal;
import com.google.android.gms.common.internal.GoogleCertificatesQuery;
import com.google.android.gms.dynamic.IObjectWrapper;
interface IGoogleCertificatesApi {
IObjectWrapper getGoogleCertficates();
IObjectWrapper getGoogleReleaseCertificates();
boolean isGoogleReleaseSigned(String packageName, IObjectWrapper certData);
boolean isGoogleSigned(String packageName, IObjectWrapper certData);
boolean isGoogleOrPlatformSigned(in GoogleCertificatesQuery query, IObjectWrapper packageManager);
}

View file

@ -0,0 +1,66 @@
/*
* Copyright (C) 2019 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.gms.common.internal;
import android.os.RemoteException;
import com.google.android.gms.dynamic.IObjectWrapper;
import com.google.android.gms.dynamic.ObjectWrapper;
import java.util.Arrays;
public class CertData extends ICertData.Stub {
private final byte[] bytes;
private final int hashCode;
public CertData(byte[] bytes) {
this.bytes = bytes;
if (bytes.length < 25) throw new RuntimeException("CertData to small");
hashCode = Arrays.hashCode(Arrays.copyOfRange(bytes, 0, 25));
}
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ICertData)) return false;
ICertData cert = (ICertData) obj;
try {
if (cert.remoteHashCode() != hashCode()) return false;
return Arrays.equals(ObjectWrapper.unwrapTyped(cert.getWrappedBytes(), byte[].class), getBytes());
} catch (RemoteException e) {
return false;
}
}
public byte[] getBytes() {
return bytes;
}
@Override
public IObjectWrapper getWrappedBytes() throws RemoteException {
return ObjectWrapper.wrap(getBytes());
}
@Override
public int remoteHashCode() throws RemoteException {
return hashCode();
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright (C) 2019 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.gms.common.internal;
import android.os.IBinder;
import android.os.RemoteException;
import com.google.android.gms.dynamic.IObjectWrapper;
import com.google.android.gms.dynamic.ObjectWrapper;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class GoogleCertificatesQuery extends AutoSafeParcelable {
@SafeParceled(1)
private String packageName;
@SafeParceled(2)
private IBinder certDataBinder;
private CertData certData;
@SafeParceled(3)
private boolean allowNonRelease;
public String getPackageName() {
return packageName;
}
public CertData getCertData() {
if (certData == null && certDataBinder != null) {
ICertData iCertData = null;
if (certDataBinder instanceof CertData) {
certData = (CertData) certDataBinder;
} else if (certDataBinder instanceof IObjectWrapper) {
certData = ObjectWrapper.unwrapTyped((IObjectWrapper) certDataBinder, CertData.class);
if (certData == null) {
byte[] bytes = ObjectWrapper.unwrapTyped((IObjectWrapper) certDataBinder, byte[].class);
if (bytes != null) {
certData = new CertData(bytes);
}
}
if (certData == null) {
iCertData = ObjectWrapper.unwrapTyped((IObjectWrapper) certDataBinder, ICertData.class);
}
} else if (certDataBinder instanceof ICertData) {
iCertData = (ICertData) certDataBinder;
}
if (iCertData != null) {
try {
byte[] bytes = ObjectWrapper.unwrapTyped(iCertData.getWrappedBytes(), byte[].class);
if (bytes != null) {
certData = new CertData(bytes);
}
} catch (RemoteException e) {
// Ignore
}
}
}
return certData;
}
public static final Creator<GoogleCertificatesQuery> CREATOR = new AutoCreator<GoogleCertificatesQuery>(GoogleCertificatesQuery.class);
}