Jelly bean

This commit is contained in:
An Bui 2024-11-06 21:29:16 +07:00
parent b10f8fed0a
commit 36aebcfddb
7 changed files with 76 additions and 14 deletions

View file

@ -352,7 +352,7 @@ public class SplashActivity extends AppCompatActivity implements Runnable {
} else {
startActivity(new Intent(this, SetupQemuActivity.class));
//For Android 14+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
if (Build.VERSION.SDK_INT >= 34) {
MainSettingsManager.setVmUi(this, "VNC");
}
}

View file

@ -444,16 +444,16 @@ public class VectrasApp extends Application {
} else {
if (request) {
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
alertDialog.setTitle(activity.getString(R.string.allow_permissions));
alertDialog.setMessage(activity.getString(R.string.you_need_to_grant_permission_to_access_the_storage_before_use));
alertDialog.setTitle(activity.getResources().getString(R.string.allow_permissions));
alertDialog.setMessage(activity.getResources().getString(R.string.you_need_to_grant_permission_to_access_the_storage_before_use));
alertDialog.setCancelable(false);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getContext().getString(R.string.allow), new DialogInterface.OnClickListener() {
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, activity.getResources().getString(R.string.allow), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (activity.shouldShowRequestPermissionRationale(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + activity.getPackageName()));
activity.startActivity(intent);
Toast.makeText(activity, R.string.find_and_allow_access_to_storage_in_settings, Toast.LENGTH_LONG).show();
Toast.makeText(activity, activity.getResources().getString(R.string.find_and_allow_access_to_storage_in_settings), Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000);
}

View file

@ -3,6 +3,7 @@ package com.vectras.vterm;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
@ -10,7 +11,7 @@ import android.util.Log;
import androidx.appcompat.app.AlertDialog;
import com.termux.app.TermuxService;
import com.termux.app.TermuxService;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@ -27,6 +28,7 @@ import com.vectras.qemu.MainVNCActivity;
import com.vectras.vm.MainActivity;
import com.vectras.vm.MainService;
import com.vectras.vm.R;
import com.vectras.vm.SplashActivity;
import com.vectras.vm.VectrasApp;
public class Terminal {
@ -62,6 +64,58 @@ public class Terminal {
private void showDialog(String message, Activity activity, String usercommand) {
if (!usercommand.contains("qemu-system") || message.contains("Killed"))
return;
//Error code: PROOT_IS_MISSING_0
if (message.contains("proot\": error=2,")) {
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
alertDialog.setTitle(activity.getResources().getString(R.string.problem_has_been_detected));
alertDialog.setMessage(activity.getResources().getString(R.string.error_PROOT_IS_MISSING_0));
alertDialog.setCancelable(false);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, activity.getResources().getString(R.string.continuetext), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MainActivity.isActivate = false;
VectrasApp.deleteDirectory(activity.getFilesDir().getAbsolutePath() + "/data");
VectrasApp.deleteDirectory(activity.getFilesDir().getAbsolutePath() + "/distro");
VectrasApp.deleteDirectory(activity.getFilesDir().getAbsolutePath() + "/usr");
Intent intent = new Intent();
intent.setClass(activity, SplashActivity.class);
activity.startActivity(intent);
activity.finish();
return;
}
});
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, activity.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
return;
} else if (message.contains(") exists") && message.contains("drive with bus")) {
//Error code: DRIVE_INDEX_0_EXISTS
VectrasApp.oneDialog(activity.getResources().getString(R.string.problem_has_been_detected), activity.getResources().getString(R.string.error_DRIVE_INDEX_0_EXISTS), true, false, activity);
return;
} else if (message.contains("gtk initialization failed") || message.contains("x11 not available")) {
//Error code: X11_NOT_AVAILABLE
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
alertDialog.setTitle(activity.getResources().getString(R.string.problem_has_been_detected));
alertDialog.setMessage(activity.getResources().getString(R.string.error_X11_NOT_AVAILABLE));
alertDialog.setCancelable(false);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, activity.getResources().getString(R.string.continuetext), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MainSettingsManager.setVmUi(activity, "VNC");
VectrasApp.oneDialog(activity.getResources().getString(R.string.done), activity.getResources().getString(R.string.switched_to_VNC), true, false, activity);
return;
}
});
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, activity.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
return;
}
AlertDialog dialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
dialog.setTitle("Execution Result");
dialog.setMessage(message);
@ -99,7 +153,7 @@ public class Terminal {
processBuilder.environment().put("HOME", "/root");
processBuilder.environment().put("USER", user);
//processBuilder.environment().put("PATH", "/bin:/usr/bin:/sbin:/usr/sbin");
//processBuilder.environment().put("PATH", "/bin:/usr/bin:/sbin:/usr/sbin");
//processBuilder.environment().put("LD_LIBRARY_PATH", TermuxService.PREFIX_PATH + "/lib");
processBuilder.environment().put("TERM", "xterm-256color");
processBuilder.environment().put("TMPDIR", tmpDir.getAbsolutePath());
@ -117,11 +171,11 @@ public class Terminal {
"-r", filesDir + "/distro", // Path to the rootfs
"-b", "/dev",
"-b", "/proc",
"-b", "/sys",
"-b", "/sys",
"-b", "/data/data/com.vectras.vm/files/distro/root:/dev/shm",
"-b", "/sdcard",
"-b", "/storage",
"-b", "/data",
"-b", "/data",
"-b", "/data/data/com.vectras.vm/files/usr/tmp:/tmp",
"-w", "/root",
"/bin/sh",