diff --git a/executeshell/.gitignore b/executeshell/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/executeshell/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/executeshell/build.gradle b/executeshell/build.gradle deleted file mode 100644 index e636f55..0000000 --- a/executeshell/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 29 - buildToolsVersion "29.0.0" - defaultConfig { - minSdkVersion 15 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) -} diff --git a/executeshell/proguard-rules.pro b/executeshell/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/executeshell/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/executeshell/src/main/AndroidManifest.xml b/executeshell/src/main/AndroidManifest.xml deleted file mode 100644 index e899de1..0000000 --- a/executeshell/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/executeshell/src/main/java/cn/endureblaze/executeshell/ExecuteShell.java b/executeshell/src/main/java/cn/endureblaze/executeshell/ExecuteShell.java deleted file mode 100644 index 5880047..0000000 --- a/executeshell/src/main/java/cn/endureblaze/executeshell/ExecuteShell.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.endureblaze.executeshell; - -import android.util.Log; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -public final class ExecuteShell -{ - private static final String TAG = "RootCmd"; - private static boolean mHaveRoot = false; - /** - * 判断机器Android是否已经root,即是否获取root权限 - */ - public static boolean haveRoot() - { - if (!mHaveRoot) - { - int ret = execRootCmdSilent("echo test"); // 通过执行测试命令来检测 - if (ret != -1) - { - Log.i(TAG, "have root!"); - mHaveRoot = true; - } - else - { - Log.i(TAG, "not root!"); - } - } - else - { - Log.i(TAG, "mHaveRoot = true, have root!"); - } - return mHaveRoot; - } - - /** - * 执行命令并且输出结果 - */ - public static String execRootCmd(String cmd) - { - String result = ""; - DataOutputStream dos = null; - DataInputStream dis = null; - - try - { - Process p = Runtime.getRuntime().exec("su");// 经过Root处理的android系统即有su命令 - dos = new DataOutputStream(p.getOutputStream()); - dis = new DataInputStream(p.getInputStream()); - - Log.i(TAG, cmd); - dos.writeBytes(cmd + "\n"); - dos.flush(); - dos.writeBytes("exit\n"); - dos.flush(); - String line = null; - while ((line = dis.readLine()) != null) - { - Log.d("result", line); - result += line; - } - p.waitFor(); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (dos != null) - { - try - { - dos.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - if (dis != null) - { - try - { - dis.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - return result; - } - - /** - * 执行命令但不关注结果输出 - */ - public static int execRootCmdSilent(String cmd) - { - int result = -1; - DataOutputStream dos = null; - - try - { - Process p = Runtime.getRuntime().exec("su"); - dos = new DataOutputStream(p.getOutputStream()); - - Log.i(TAG, cmd); - dos.writeBytes(cmd + "\n"); - dos.flush(); - dos.writeBytes("exit\n"); - dos.flush(); - p.waitFor(); - result = p.exitValue(); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (dos != null) - { - try - { - dos.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - return result; - } -} \ No newline at end of file diff --git a/executeshell/src/main/res/values/strings.xml b/executeshell/src/main/res/values/strings.xml deleted file mode 100644 index f2fb39b..0000000 --- a/executeshell/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - executeshell - diff --git a/library/.gitignore b/library/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/library/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/library/build.gradle b/library/build.gradle deleted file mode 100644 index e636f55..0000000 --- a/library/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 29 - buildToolsVersion "29.0.0" - defaultConfig { - minSdkVersion 15 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) -} diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/library/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml deleted file mode 100644 index e899de1..0000000 --- a/library/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/library/src/main/java/cn/endureblaze/executeshell/ExecuteShell.java b/library/src/main/java/cn/endureblaze/executeshell/ExecuteShell.java deleted file mode 100644 index 5880047..0000000 --- a/library/src/main/java/cn/endureblaze/executeshell/ExecuteShell.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.endureblaze.executeshell; - -import android.util.Log; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -public final class ExecuteShell -{ - private static final String TAG = "RootCmd"; - private static boolean mHaveRoot = false; - /** - * 判断机器Android是否已经root,即是否获取root权限 - */ - public static boolean haveRoot() - { - if (!mHaveRoot) - { - int ret = execRootCmdSilent("echo test"); // 通过执行测试命令来检测 - if (ret != -1) - { - Log.i(TAG, "have root!"); - mHaveRoot = true; - } - else - { - Log.i(TAG, "not root!"); - } - } - else - { - Log.i(TAG, "mHaveRoot = true, have root!"); - } - return mHaveRoot; - } - - /** - * 执行命令并且输出结果 - */ - public static String execRootCmd(String cmd) - { - String result = ""; - DataOutputStream dos = null; - DataInputStream dis = null; - - try - { - Process p = Runtime.getRuntime().exec("su");// 经过Root处理的android系统即有su命令 - dos = new DataOutputStream(p.getOutputStream()); - dis = new DataInputStream(p.getInputStream()); - - Log.i(TAG, cmd); - dos.writeBytes(cmd + "\n"); - dos.flush(); - dos.writeBytes("exit\n"); - dos.flush(); - String line = null; - while ((line = dis.readLine()) != null) - { - Log.d("result", line); - result += line; - } - p.waitFor(); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (dos != null) - { - try - { - dos.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - if (dis != null) - { - try - { - dis.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - return result; - } - - /** - * 执行命令但不关注结果输出 - */ - public static int execRootCmdSilent(String cmd) - { - int result = -1; - DataOutputStream dos = null; - - try - { - Process p = Runtime.getRuntime().exec("su"); - dos = new DataOutputStream(p.getOutputStream()); - - Log.i(TAG, cmd); - dos.writeBytes(cmd + "\n"); - dos.flush(); - dos.writeBytes("exit\n"); - dos.flush(); - p.waitFor(); - result = p.exitValue(); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (dos != null) - { - try - { - dos.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - return result; - } -} \ No newline at end of file diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml deleted file mode 100644 index f2fb39b..0000000 --- a/library/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - executeshell -