|
58 | 58 | import org.iiab.controller.rootfs.presentation.RootfsViewModel; |
59 | 59 | import org.iiab.controller.rootfs.presentation.RootfsViewModelFactory; |
60 | 60 | import org.iiab.controller.util.ByteFormatter; |
| 61 | +import org.iiab.controller.util.ProcessRunner; |
61 | 62 |
|
62 | 63 | import org.json.JSONObject; |
63 | 64 |
|
@@ -1086,8 +1087,12 @@ public void onComplete(String destDir) { |
1086 | 1087 | File binDir = new File(requireContext().getFilesDir(), "usr/bin"); |
1087 | 1088 | if (binDir.exists()) { |
1088 | 1089 | try { |
1089 | | - Runtime.getRuntime().exec(new String[]{"chmod", "-R", "755", binDir.getAbsolutePath()}).waitFor(); |
1090 | | - } catch (Exception ignored) { |
| 1090 | + ProcessRunner.Result chmodResult = ProcessRunner.run(new String[]{"chmod", "-R", "755", binDir.getAbsolutePath()}); |
| 1091 | + if (!chmodResult.isSuccess()) { |
| 1092 | + Log.w(TAG, "chmod on usr/bin failed (exit " + chmodResult.exitCode + "): " + chmodResult.output); |
| 1093 | + } |
| 1094 | + } catch (Exception e) { |
| 1095 | + Log.w(TAG, "chmod on usr/bin failed", e); |
1091 | 1096 | } |
1092 | 1097 | } |
1093 | 1098 |
|
@@ -1137,8 +1142,12 @@ public void onError(String error) { |
1137 | 1142 | btnFastInstall.setEnabled(false); |
1138 | 1143 | new Thread(() -> { |
1139 | 1144 | try { |
1140 | | - Runtime.getRuntime().exec(new String[]{"rm", "-rf", debianRootfs.getAbsolutePath()}).waitFor(); |
1141 | | - } catch (Exception ignored) { |
| 1145 | + ProcessRunner.Result wipeResult = ProcessRunner.run(new String[]{"rm", "-rf", debianRootfs.getAbsolutePath()}); |
| 1146 | + if (!wipeResult.isSuccess()) { |
| 1147 | + Log.w(TAG, "rm -rf rootfs (reinstall) failed (exit " + wipeResult.exitCode + "): " + wipeResult.output); |
| 1148 | + } |
| 1149 | + } catch (Exception e) { |
| 1150 | + Log.w(TAG, "rm -rf rootfs (reinstall) failed", e); |
1142 | 1151 | } |
1143 | 1152 | mainAct.runOnUiThread(executeDownload); |
1144 | 1153 | }).start(); |
@@ -1175,8 +1184,10 @@ private void bindDeleteButtonLogic(MainActivity mainAct, File debianRootfs) { |
1175 | 1184 | new Thread(() -> { |
1176 | 1185 | enableSystemProtection(); |
1177 | 1186 | try { |
1178 | | - Process p = Runtime.getRuntime().exec(new String[]{"rm", "-rf", debianRootfs.getAbsolutePath()}); |
1179 | | - p.waitFor(); |
| 1187 | + ProcessRunner.Result wipeResult = ProcessRunner.run(new String[]{"rm", "-rf", debianRootfs.getAbsolutePath()}); |
| 1188 | + if (!wipeResult.isSuccess()) { |
| 1189 | + Log.w(TAG, "rm -rf rootfs (delete) failed (exit " + wipeResult.exitCode + "): " + wipeResult.output); |
| 1190 | + } |
1180 | 1191 | } catch (Exception e) { |
1181 | 1192 | mainAct.runOnUiThread(() -> Snackbar.make(getView(), getString(R.string.install_error_delete, e.getMessage()), Snackbar.LENGTH_LONG).show()); |
1182 | 1193 | } finally { |
@@ -1227,7 +1238,10 @@ private void bindResetButtonLogic(MainActivity mainAct, File debianRootfs) { |
1227 | 1238 | }); |
1228 | 1239 |
|
1229 | 1240 | // 1. WIPE |
1230 | | - Runtime.getRuntime().exec(new String[]{"rm", "-rf", debianRootfs.getAbsolutePath()}).waitFor(); |
| 1241 | + ProcessRunner.Result wipeResult = ProcessRunner.run(new String[]{"rm", "-rf", debianRootfs.getAbsolutePath()}); |
| 1242 | + if (!wipeResult.isSuccess()) { |
| 1243 | + Log.w(TAG, "rm -rf rootfs (vanilla reset) failed (exit " + wipeResult.exitCode + "): " + wipeResult.output); |
| 1244 | + } |
1231 | 1245 | debianRootfs.mkdirs(); |
1232 | 1246 |
|
1233 | 1247 | // 2. DOWNLOAD |
@@ -1880,8 +1894,13 @@ private void bindBackupButtonLogic(MainActivity mainAct, File backupsDir, File i |
1880 | 1894 | String gzipBin = staticGzip.exists() ? staticGzip.getAbsolutePath() : "gzip"; |
1881 | 1895 |
|
1882 | 1896 | String cmd = tarBin + " -cf - -C " + iiabRootDir.getAbsolutePath() + " installed-rootfs | " + gzipBin + " > " + backupFile.getAbsolutePath(); |
1883 | | - Process p = Runtime.getRuntime().exec(new String[]{"/system/bin/sh", "-c", cmd}); |
1884 | | - int exitCode = p.waitFor(); |
| 1897 | + // D12: ProcessRunner drains stderr so a large backup with tar warnings |
| 1898 | + // cannot deadlock on a full pipe buffer. |
| 1899 | + ProcessRunner.Result backupResult = ProcessRunner.run(new String[]{"/system/bin/sh", "-c", cmd}); |
| 1900 | + int exitCode = backupResult.exitCode; |
| 1901 | + if (exitCode != 0) { |
| 1902 | + Log.w(TAG, "Backup pipe failed (exit " + exitCode + "): " + backupResult.output); |
| 1903 | + } |
1885 | 1904 |
|
1886 | 1905 | mainAct.runOnUiThread(() -> { |
1887 | 1906 | if (isBackupInProgress) { |
|
0 commit comments