Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frequently getPackageInfo in RootBeer.isRooted() #218

Open
KiBa1215 opened this issue Oct 31, 2023 · 0 comments
Open

Frequently getPackageInfo in RootBeer.isRooted() #218

KiBa1215 opened this issue Oct 31, 2023 · 0 comments

Comments

@KiBa1215
Copy link

    public boolean isRooted() {
        return detectRootManagementApps() || detectPotentiallyDangerousApps() || checkForBinary(BINARY_SU)
                || checkForDangerousProps() || checkForRWPaths()
                || detectTestKeys() || checkSuExists() || checkForRootNative() || checkForMagiskBinary();
    }

In every detect method will finally call

    /**
     * Check if any package in the list is installed
     * @param packages - list of packages to search for
     * @return true if any of the packages are installed
     */
    private boolean isAnyPackageFromListInstalled(List<String> packages){
        boolean result = false;

        PackageManager pm = mContext.getPackageManager();

        for (String packageName : packages) {
            try {
                // Root app detected
                pm.getPackageInfo(packageName, 0);
                QLog.e(packageName + " ROOT management app detected!");
                result = true;
            } catch (PackageManager.NameNotFoundException e) {
                // Exception thrown, package is not installed into the system
            }
        }

        return result;
    }

pm.getPackageInfo(packageName, 0); this method may be not allowed to be called frequently to some other policies (because it's in a for loop).

Myabe cache an installed app list in RootBeer class, and do some local List operations to check if any package is installed, this would be better?

Thanks!

@KiBa1215 KiBa1215 changed the title Frequently request app installed list in RootBeer.isRooted() Frequently getPackageInfo in RootBeer.isRooted() Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant