public class MainActivity extends AppCompatActivity {
private static final String BINARY_SU = "su";
private RootBeer rootBeer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rootBeer = new RootBeer(this);
// rootBeer.setLogging(true); // Enable logging
// if (isRooted()) {
// Log.d("RootCheck", "Device is rooted");
// } else {
// Log.d("RootCheck", "This device is not rooted");
// }
detectRootManagementApps();
detectPotentiallyDangerousApps();
checkForBinary(BINARY_SU);
checkForDangerousProps();
checkForRWPaths();
detectTestKeys();
checkSuExists();
checkForRootNative();
checkForMagiskBinary();
}
public boolean isRooted() {
return detectRootManagementApps() || detectPotentiallyDangerousApps() || checkForBinary(BINARY_SU)
|| checkForDangerousProps() || checkForRWPaths()
|| detectTestKeys() || checkSuExists() || checkForRootNative() || checkForMagiskBinary();
}
private boolean detectRootManagementApps() {
boolean result = rootBeer.detectRootManagementApps();
Log.d(getClass().getName(), "detectRootManagementApps: " + result);
return result;
}
private boolean detectPotentiallyDangerousApps() {
boolean result = rootBeer.detectPotentiallyDangerousApps();
Log.d(getClass().getName(), "detectPotentiallyDangerousApps: " + result);
return result;
}
private boolean checkForBinary(String binaryName) {
boolean result = rootBeer.checkForBinary(binaryName);
Log.d(getClass().getName(), "checkForBinary (" + binaryName + "): " + result);
return result;
}
private boolean checkForDangerousProps() {
boolean result = rootBeer.checkForDangerousProps();
Log.d(getClass().getName(), "checkForDangerousProps: " + result);
return result;
}
private boolean checkForRWPaths() {
boolean result = rootBeer.checkForRWPaths();
Log.d(getClass().getName(), "checkForRWPaths: " + result);
return result;
}
private boolean detectTestKeys() {
boolean result = rootBeer.detectTestKeys();
Log.d(getClass().getName(), "detectTestKeys: " + result);
return result;
}
private boolean checkSuExists() {
boolean result = rootBeer.checkSuExists();
Log.d(getClass().getName(), "checkSuExists: " + result);
return result;
}
private boolean checkForRootNative() {
boolean result = rootBeer.checkForRootNative();
Log.d(getClass().getName(), "checkForRootNative: " + result);
return result;
}
private boolean checkForMagiskBinary() {
boolean result = rootBeer.checkForMagiskBinary();
Log.d(getClass().getName(), "checkForMagiskBinary: " + result);
return result;
}
dependencies {
implementation 'com.scottyab:rootbeer-lib:0.1.0'
D/com.pos.rootbeer.MainActivity: detectRootManagementApps: false
D/com.pos.rootbeer.MainActivity: detectPotentiallyDangerousApps: false
D/com.pos.rootbeer.MainActivity: checkForBinary (su): false
D/com.pos.rootbeer.MainActivity: checkForDangerousProps: false
D/com.pos.rootbeer.MainActivity: checkForRWPaths: false
D/com.pos.rootbeer.MainActivity: detectTestKeys: false
D/com.pos.rootbeer.MainActivity: checkSuExists: false
D/com.pos.rootbeer.MainActivity: checkForRootNative: false
D/com.pos.rootbeer.MainActivity: checkForMagiskBinary: false