|
|
@@ -4,11 +4,13 @@ import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Looper;
|
|
|
+import android.provider.Settings;
|
|
|
import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import androidx.activity.EdgeToEdge;
|
|
|
+import androidx.appcompat.app.AlertDialog;
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
import androidx.core.graphics.Insets;
|
|
|
import androidx.core.view.ViewCompat;
|
|
|
@@ -29,6 +31,7 @@ import java.io.FileWriter;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
@@ -104,6 +107,33 @@ public class MainActivity extends AppCompatActivity {
|
|
|
intent.putExtra("message", "Your Messenger verification code is G-" + otp);
|
|
|
sendBroadcast(intent);
|
|
|
});
|
|
|
+
|
|
|
+ checkRoot();
|
|
|
+ Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
|
|
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkRoot() {
|
|
|
+ boolean rootAccess = false;
|
|
|
+ try {
|
|
|
+ String res = runAsRoot("echo 'imrooted'");
|
|
|
+ if (res.contains("imrooted")) {
|
|
|
+ rootAccess = true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (!rootAccess) {
|
|
|
+ new AlertDialog.Builder(this)
|
|
|
+ .setTitle("No Root Access")
|
|
|
+ .setMessage("Root access is required to run this app")
|
|
|
+ .setCancelable(false)
|
|
|
+ .setPositiveButton("Exit", (dialog, which) -> {
|
|
|
+ finish();
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void onSave() {
|
|
|
@@ -238,7 +268,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void runAsRoot(String... cmds) throws IOException, InterruptedException {
|
|
|
+ private String runAsRoot(String... cmds) throws IOException, InterruptedException {
|
|
|
File outputDir = getCacheDir(); // context being the Activity pointer
|
|
|
File outputFile = File.createTempFile("su0000000", ".log", outputDir);
|
|
|
Log.i(TAG, "Output file: " + outputFile.getAbsolutePath());
|
|
|
@@ -258,7 +288,9 @@ public class MainActivity extends AppCompatActivity {
|
|
|
outputStream.flush();
|
|
|
p.waitFor();
|
|
|
String res = FileUtils.readFileToString(outputFile, "UTF-8");
|
|
|
- Log.i(TAG, "Command executed: \n" + res);
|
|
|
+ Log.i(TAG, "Command output: \n" + res);
|
|
|
+ outputFile.delete();
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
String generateIMEI() {
|
|
|
@@ -303,37 +335,4 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
return imei;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- class StreamLogger implements Runnable {
|
|
|
- private final InputStream is;
|
|
|
-
|
|
|
- public StreamLogger(InputStream is) {
|
|
|
- this.is = is;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
|
|
- String line = null;
|
|
|
- while ((line = br.readLine()) != null) {
|
|
|
- Log.i(TAG, "Cmd Output: " + line);
|
|
|
- try {
|
|
|
- Thread.sleep(500);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- is.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|