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

Commit 2673d4de authored by Thibaut Girka's avatar Thibaut Girka Committed by Marvin W.
Browse files

Fetch droidguard binary depending on architecture (fixes #18)

parent c13242ba
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013-2017 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 org.microg.gms.droidguard;

public class Constants {
    public static final String GMS_PACKAGE_NAME = "com.google.android.gms";
    public static final int GMS_VERSION_CODE = 12688023;
    public static final String GMS_VERSION_NAME_PREFIX = "12.6.88 (040400-{{cl}})";
}
+27 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class DroidguardHelper {
                .isGoogleCn(false)
                .enableInlineVm(true)
                .currentVersion(3)
                .versionNamePrefix(Constants.GMS_VERSION_NAME_PREFIX)
                .versionNamePrefix(gmsVersionNamePrefix(Build.CPU_ABI))
                .cached(getCached(context))
                .arch(getArch())
                .build());
@@ -90,6 +90,31 @@ public class DroidguardHelper {
        return invoke(context, clazz, request.packageName, request.reason, response.byteCode.toByteArray(), request.androidIdLong, request.extras);
    }

    public static int gmsVersionCode(String arch) {
        switch (arch) {
            case "arm64-v8a":
                return 12688023;
            case "x86":
                return 12688026;
            case "x86_64":
                return 12688027;
            default:
                return 12688019;
        }
    }

    public static String gmsVersionNamePrefix(String arch) {
        switch (arch) {
            case "arm64-v8a":
                return "12.6.88 (040400-{{cl}})";
            case "x86":
            case "x86_64":
                return "12.6.88 (040700-{{cl}})";
            default:
                return "12.6.88 (040300-{{cl}})";
        }
    }

    public static byte[] invoke(Context context, Class<?> clazz, String packageName, String type, byte[] byteCode, String androidIdLong, Bundle extras) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException {
        Object instance = clazz
                .getDeclaredConstructor(Context.class, String.class, byte[].class, Object.class)
@@ -253,7 +278,7 @@ public class DroidguardHelper {
        connection.setDoOutput(true);
        connection.setRequestProperty("Content-Type", "application/x-protobuf");
        connection.setRequestProperty("Accept-Encoding", "gzip");
        connection.setRequestProperty("User-Agent", "DroidGuard/" + Constants.GMS_VERSION_CODE);
        connection.setRequestProperty("User-Agent", "DroidGuard/" + gmsVersionCode(Build.CPU_ABI));

        Log.d(TAG, "-- Request --\n" + request);
        OutputStream os = connection.getOutputStream();