Bitrise是否继续集成植根于模拟器?

时间:2019-02-04 19:45:58

标签: android kotlin continuous-integration root bitrise

我们的应用程序使用与Bitrise的持续集成来构建和运行自动化UI测试。我们需要实施有根的设备检查,而这些检查现在未通过测​​试,而且似乎已将其模拟器检测为有根。任何有经验的人都知道如何解决这个问题,难道他们也正在使用植根设备吗?在网络上找不到有关它的信息。我们正在使用的支票是这样的:

    /** @author Kevin Kowalewski */
public class RootUtil {
    public static boolean isDeviceRooted() {
        return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
    }

    private static boolean checkRootMethod1() {
        String buildTags = android.os.Build.TAGS;
        return buildTags != null && buildTags.contains("test-keys");
    }

    private static boolean checkRootMethod2() {
        String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
                "/system/bin/failsafe/su", "/data/local/su", "/su/bin/su"};
        for (String path : paths) {
            if (new File(path).exists()) return true;
        }
        return false;
    }

    private static boolean checkRootMethod3() {
        Process process = null;
        try {
            process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
            BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
            if (in.readLine() != null) return true;
            return false;
        } catch (Throwable t) {
            return false;
        } finally {
            if (process != null) process.destroy();
        }
    }
}

0 个答案:

没有答案