@@ -0,0 +1,2834 @@
+/*%0A * Copyright (C) 2013 - 2016 Alexander Martinz%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A *%0A * You should have received a copy of the GNU General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0Apackage alexander.martinz.libs.execution;%0A%0Aimport android.support.annotation.Nullable;%0Aimport android.text.TextUtils;%0Aimport android.util.Log;%0A%0Aimport java.io.File;%0A%0Apublic class RootCheck %7B%0A    private static final String TAG = RootCheck.class.getSimpleName();%0A%0A    private static final String%5B%5D PATH_SU = new String%5B%5D%7B%0A            %22/system/bin/su%22, %22/system/xbin/su%22, %22/system/bin/.ext/.su%22, %22/system/xbin/sugote%22,%0A            // %22system less%22 root (supersu)%0A            %22/su/bin/su%22%0A    %7D;%0A%0A    private static Boolean sIsRooted = null;%0A%0A    /**%0A     * @return true if the device is rooted, false if not%0A     * %3Cp/%3E%0A     * The result is cached, for a non cached result, use %7B@link RootCheck#isRooted(boolean)%7D%0A     */%0A    public static boolean isRooted() %7B%0A        return isRooted(false);%0A    %7D%0A%0A    /**%0A     * @param forceRootCheck Whether to use the cached result or force a new check%0A     * @return true if the device is rooted, false if not%0A     */%0A    public static boolean isRooted(boolean forceRootCheck) %7B%0A        if (!forceRootCheck && sIsRooted != null) %7B%0A            return sIsRooted;%0A        %7D%0A%0A        final String suPath = getSuPath();%0A        if (!TextUtils.isEmpty(suPath)) %7B%0A            if (ShellLogger.DEBUG) %7B%0A                Log.d(TAG, String.format(%22Found su path: %25s%22, suPath));%0A            %7D%0A            sIsRooted = true;%0A            return true;%0A        %7D%0A        if (ShellLogger.DEBUG) %7B%0A            Log.d(TAG, %22no binary found, trying with hit and miss%22);%0A        %7D%0A%0A        // fire and forget id, just for fun%0A        RootShell.fireAndForget(%22id%22);%0A%0A        final RootShell rootShell = ShellManager.get().getRootShell();%0A        sIsRooted = (rootShell != null);%0A        if (ShellLogger.DEBUG) %7B%0A            Log.d(TAG, String.format(%22is rooted: %25s%22, sIsRooted));%0A        %7D%0A        return sIsRooted;%0A    %7D%0A%0A    /**%0A     * @return The path of the su binary or null if none found%0A     */%0A    @Nullable public static String getSuPath() %7B%0A        for (final String path : PATH_SU) %7B%0A            if (new File(path).exists()) %7B%0A                return path;%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%7D%0A

Move RootCheck from HardwareLibrary