RootedDevice
Step->(1) // rooted library
implementation 'com.scottyab:rootbeer-lib:0.0.9'
Step->(2)***********************************************
public class RootDetectionUtil {
public static boolean isDeviceRooted(Context context) {
// Check for root access using RootBeer
RootBeer rootBeer = new RootBeer(context);
if (rootBeer.isRooted()) {
return true;
}
// Check for the presence of known root-related files and binaries
if (checkForRootFiles() || checkForRootBinaries()) {
return true;
}
return false;
}
private static boolean checkForRootFiles() {
// Check for the presence of known root-related files
String[] rootFiles = {"/system/app/Superuser.apk", "/system/xbin/su", "/system/bin/su"};
for (String file : rootFiles) {
File rootFile = new File(file);
if (rootFile.exists()) {
return true;
}
}
return false;
}
private static boolean checkForRootBinaries() {
// Check for the presence of known root-related binaries
String[] rootBinaries = {"su", "busybox", "magisk", "supersu"};
for (String binary : rootBinaries) {
String binaryPath = "/system/xbin/" + binary;
File binaryFile = new File(binaryPath);
if (binaryFile.exists()) {
return true;
}
}
return false;
}
}
Step->(3)*********************************************
public class DeveloperModeChecker {
public static boolean isDeveloperModeEnabled(Context context) {
// Check if the developer mode setting is enabled
int developerModeSetting = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
// Additionally, check if the USB debugging setting is enabled
int usbDebuggingSetting = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.ADB_ENABLED, 0);
// If either developer mode or USB debugging is enabled, return true
return developerModeSetting != 0 || usbDebuggingSetting != 0;
}
}
Step->(4)*********************************************Call login Activity
// Check for root access using the utility class
if (RootDetectionUtil.isDeviceRooted(LoginActivity.this) || DeveloperModeChecker.isDeveloperModeEnabled(LoginActivity.this)) {
// Device is rooted or potentially compromised
// Show a message or take appropriate action
Toast.makeText(LoginActivity.this, "Device Is Rooted", Toast.LENGTH_SHORT).show();
finish();
}

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home