Merge pull request #676 from AnBui2004/master

4.3.2
This commit is contained in:
An Bui 2026-07-08 22:22:07 +07:00 committed by GitHub
commit 5074600e8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 36 additions and 25 deletions

View file

@ -12,8 +12,8 @@ android {
applicationId "com.vectras.vm"
minSdk minApi
targetSdk targetApi
versionCode 135
versionName "4.3.1"
versionCode 136
versionName "4.3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true

View file

@ -16,6 +16,8 @@ import android.util.Log;
import androidx.core.app.NotificationCompat;
import com.vectras.vm.main.core.MainStartVM;
import com.vectras.vm.manager.VmServiceManager;
import com.vectras.vm.utils.ClipboardUltils;
import com.vectras.vm.utils.DialogUtils;
import com.vectras.vterm.Terminal;
@ -26,7 +28,7 @@ import java.util.Objects;
public class MainService extends Service {
public static String CHANNEL_ID = "Vectras VM Service";
private final int NOTIFICATION_ID = 1;
private final String MACHINE_NAME = "Vectras VM";
public static String vmName = "Vectras VM";
public static String env = null;
private static String TAG = "MainService";
public static MainService service;
@ -48,7 +50,7 @@ public class MainService extends Service {
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.app_name))
.setContentText(MACHINE_NAME + " running in background.")
.setContentText("The virtual machines are running...")
.setSmallIcon(R.drawable.ic_vectras_vm_48)
.addAction(R.drawable.close_24px, getString(R.string.stop), pStopSelf)
.build();
@ -57,7 +59,7 @@ public class MainService extends Service {
if (env != null) {
if (service != null) {
startCommand(env, activityContext);
startCommand(vmName, env, activityContext);
}
} else {
Log.e(TAG, "env is null");
@ -77,10 +79,13 @@ public class MainService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null && Objects.equals(intent.getAction(), STOP_ACTION)) {
VMManager.killallqemuprocesses(this);
stopForeground(true);
stopSelf();
return START_NOT_STICKY;
new Thread(() -> {
VMManager.killallqemuprocesses(this);
new Handler(Looper.getMainLooper()).post(() -> {
stopForeground(true);
stopSelf();
});
}).start();
}
return START_NOT_STICKY;
}
@ -102,7 +107,7 @@ public class MainService extends Service {
}
}
public static void startCommand(String env, Context context) {
public static void startCommand(String vmName, String env, Context context) {
Terminal2 terminal2 = new Terminal2(activityContext);
terminal2.setDefaultShellBash();
terminal2.setStartup("export XDG_RUNTIME_DIR=/tmp && unset PULSE_SERVER");
@ -123,13 +128,18 @@ public class MainService extends Service {
return;
}
new Handler(Looper.getMainLooper()).post(() -> {
if (VMManager.isExecutedCommandError(command, log, context))
return;
if (!(log.trim().isEmpty() || log.trim().equals(MainStartVM.TAG_FINISHED_WITHOUT_ERROR))) {
new Handler(Looper.getMainLooper()).post(() -> {
if (!VMManager.isExecutedCommandError(command, log, context)) {
String finalLog = log.contains(MainStartVM.TAG_FINISHED_WITHOUT_ERROR) ? log.substring(0, log.lastIndexOf(MainStartVM.TAG_FINISHED_WITHOUT_ERROR) - 1) : log;
DialogUtils.twoDialog(context, "Execution Result", log, context.getString(R.string.copy), context.getString(R.string.close), true, R.drawable.round_terminal_24, true,
() -> ClipboardUltils.copyToClipboard(context, log), null, null);
});
DialogUtils.twoDialog(context, vmName, finalLog, context.getString(R.string.copy), context.getString(R.string.close), true, R.drawable.stack_24px, true,
() -> ClipboardUltils.copyToClipboard(context, log), null, null);
}
});
}
VmServiceManager.stopService(context);
}
@Override

View file

@ -666,8 +666,6 @@ public class VMManager {
return false;
}
VmServiceManager.stopService(_activity);
if (_command.contains("qemu-system") && _result.contains("Killed")) {
isQemuStopedWithError = true;
return true;
@ -735,7 +733,7 @@ public class VMManager {
},
null, null);
return false;
} else if (_command.contains("qemu-system") && _result.contains("qemu-system") && !_result.contains("warning:")) {
} else if (!_result.contains(MainStartVM.TAG_FINISHED_WITHOUT_ERROR)) {
//Error code: UNKNOW_ERROR
DialogUtils.oneDialog(_activity, _activity.getString(R.string.problem_has_been_detected), _activity.getString(R.string.vm_could_not_be_run_content) + "\n\n" + _result, R.drawable.error_96px);
_activity.stopService(new Intent(_activity, MainService.class));

View file

@ -35,6 +35,7 @@ import java.io.File;
public class MainStartVM {
public static final String TAG = "HomeStartVM";
public static final String TAG_FINISHED_WITHOUT_ERROR = "This VM has shut down.";
public static boolean skipIDEwithARM64DialogInStartVM = false;
public static boolean breakNow = false;
public static final Handler handlerForLaunch = new Handler(Looper.getMainLooper());
@ -297,7 +298,7 @@ public class MainStartVM {
) {
VMManager.isQemuStopedWithError = false;
String cleanUpCommand = "; rm -r " + Config.getCacheVMPath(vmID);
String cleanUpCommand = " && echo \"" + TAG_FINISHED_WITHOUT_ERROR + "\"\nrm -r " + Config.getCacheVMPath(vmID);
String finalCommand = VMManager.addAudioDevWav(vmID, String.format(runCommandFormat, env + cleanUpCommand));
@ -314,11 +315,12 @@ public class MainStartVM {
}
if (ServiceUtils.isServiceRunning(context, MainService.class)) {
MainService.startCommand(finalCommand, context);
MainService.startCommand(vmName, finalCommand, context);
} else {
Intent serviceIntent = new Intent(context, MainService.class);
MainService.activityContext = context;
MainService.env = finalCommand;
MainService.vmName = vmName;
MainService.CHANNEL_ID = vmName;
if (SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(serviceIntent);

View file

@ -107,6 +107,7 @@ public class Terminal2 {
try {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.redirectErrorStream(true);
String filesDir = Objects.requireNonNull(context.getFilesDir().getAbsolutePath());

View file

@ -5,11 +5,11 @@
"url": "https://github.com/xoureldeen/Vectras-VM-Android/releases",
"Message": "<h2>4.3.0</h2>\nBugs fixed.",
"cancellable": true,
"versionCodeBeta":"135",
"versionNameBeta":"4.3.1",
"versionNameBetas":"4.0.1,4.0.2,4.0.3,4.0.4,4.0.5,4.0.6,4.0.7,4.0.8,4.0.9,4.1.1,4.1.2,4.1.3,4.1.4,4.1.5,4.1.6,4.1.7,4.1.8,4.1.9,4.2.1,4.2.2,4.2.3,4.2.4,4.2.5,4.2.6,4.2.7,4.2.8,4.2.9,4.3.0,4.3.1",
"versionCodeBeta":"136",
"versionNameBeta":"4.3.2",
"versionNameBetas":"4.0.1,4.0.2,4.0.3,4.0.4,4.0.5,4.0.6,4.0.7,4.0.8,4.0.9,4.1.1,4.1.2,4.1.3,4.1.4,4.1.5,4.1.6,4.1.7,4.1.8,4.1.9,4.2.1,4.2.2,4.2.3,4.2.4,4.2.5,4.2.6,4.2.7,4.2.8,4.2.9,4.3.0,4.3.1,4.3.2",
"sizeBeta": "45 MB",
"urlBeta": "https://github.com/AnBui2004/Vectras-VM-Emu-Android/releases",
"MessageBeta": "<h2>4.3.1</h2>Bugs fixed.",
"MessageBeta": "<h2>4.3.2</h2>Bugs fixed.",
"cancellableBeta": true
}