From 54ec5023fceac789c3a86d5835c25c7c34ac981e Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 18 Jul 2025 18:51:31 +0800 Subject: [PATCH] =?UTF-8?q?release=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 10 ++++++ .../rootless/RootlessSaiPackageInstaller.kt | 4 +-- .../com/android/grape/util/ShellUtil.java | 32 ------------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index da50d8d..38c9d18 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,4 @@ + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) @@ -7,6 +8,15 @@ android { namespace = "com.android.grape" compileSdk = 35 + signingConfigs { + getByName("release") { + storeFile = file("key.jks") + storePassword = "androidgrape" + keyAlias = "key0" + keyPassword = "androidgrape" + } + } + defaultConfig { applicationId = "com.android.grape" minSdk = 23 diff --git a/app/src/main/java/com/android/grape/sai/rootless/RootlessSaiPackageInstaller.kt b/app/src/main/java/com/android/grape/sai/rootless/RootlessSaiPackageInstaller.kt index 7cbbe99..26e2df2 100644 --- a/app/src/main/java/com/android/grape/sai/rootless/RootlessSaiPackageInstaller.kt +++ b/app/src/main/java/com/android/grape/sai/rootless/RootlessSaiPackageInstaller.kt @@ -111,8 +111,8 @@ class RootlessSaiPackageInstaller private constructor(c: Context) : val callbackIntent: Intent = Intent(RootlessSaiPiBroadcastReceiver.ACTION_DELIVER_PI_EVENT) val pendingIntent = PendingIntent.getBroadcast(context, 0, callbackIntent, - 0) - session!!.commit(pendingIntent.intentSender) + PendingIntent.FLAG_IMMUTABLE) + session.commit(pendingIntent.intentSender) } } catch (e: Exception) { Log.w(TAG, e) diff --git a/app/src/main/java/com/android/grape/util/ShellUtil.java b/app/src/main/java/com/android/grape/util/ShellUtil.java index 587224f..b1bec46 100644 --- a/app/src/main/java/com/android/grape/util/ShellUtil.java +++ b/app/src/main/java/com/android/grape/util/ShellUtil.java @@ -100,33 +100,11 @@ public class ShellUtil { public static String execRootCmdAndGetResult(String cmd) { Log.d("ShellUtils", "execRootCmdAndGetResult - Started execution for command: " + cmd); - if (cmd == null || cmd.trim().isEmpty()) { - LogUtils.d(Log.ERROR, "ShellUtils", "Unsafe or empty command. Aborting execution.", null); - throw new IllegalArgumentException("Unsafe or empty command."); - } - // if (!isCommandSafe(cmd)) { // 检查命令的合法性 - // Log.e("ShellUtils", "Detected unsafe command. Aborting execution."); - // throw new IllegalArgumentException("Detected unsafe command."); - // } Process process = null; ExecutorService executor = Executors.newFixedThreadPool(2); try { - Log.d("ShellUtils", "Determining appropriate shell for execution..."); -// if (hasBin("su")) { -// Log.d("ShellUtils", "'su' binary found, using 'su' shell."); -// process = Runtime.getRuntime().exec("su"); -// } else if (hasBin("xu")) { -// Log.d("ShellUtils", "'xu' binary found, using 'xu' shell."); -// process = Runtime.getRuntime().exec("xu"); -// } else if (hasBin("vu")) { -// Log.d("ShellUtils", "'vu' binary found, using 'vu' shell."); -// process = Runtime.getRuntime().exec("vu"); -// } else { -// Log.d("ShellUtils", "No specific binary found, using 'sh' shell."); -// process = Runtime.getRuntime().exec("sh"); -// } process = Runtime.getRuntime().exec("vu"); try (OutputStream os = new BufferedOutputStream(process.getOutputStream()); @@ -134,8 +112,6 @@ public class ShellUtil { InputStream errorStream = process.getErrorStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream, StandardCharsets.UTF_8))) { - - Log.d("ShellUtils", "Starting separate thread to process error stream..."); executor.submit(() -> { String line; try { @@ -146,12 +122,9 @@ public class ShellUtil { LogUtils.d(Log.ERROR, "ShellUtils", "Error while reading process error stream: " + e.getMessage(), e); } }); - - Log.d("ShellUtils", "Writing the command to the shell..."); os.write((cmd + "\n").getBytes()); os.write("exit\n".getBytes()); os.flush(); - Log.d("ShellUtils", "Command written to shell. Waiting for process to complete."); StringBuilder output = new StringBuilder(); String line; @@ -159,8 +132,6 @@ public class ShellUtil { Log.d("ShellUtils", "Shell Output: " + line); output.append(line).append("\n"); } - - Log.d("ShellUtils", "Awaiting process termination..."); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (!process.waitFor(10, TimeUnit.SECONDS)) { LogUtils.d(Log.ERROR, "ShellUtils", "Process execution timed out. Destroying process.", null); @@ -168,7 +139,6 @@ public class ShellUtil { throw new RuntimeException("Shell command execution timeout."); } } else { - Log.d("ShellUtils", "Using manual time tracking method for process termination (API < 26)."); long startTime = System.currentTimeMillis(); while (true) { try { @@ -184,8 +154,6 @@ public class ShellUtil { } } } - - Log.d("ShellUtils", "Process terminated successfully. Returning result."); return output.toString().trim(); } } catch (IOException | InterruptedException e) {