mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-05-02 16:20:30 +00:00
Thunderbird
This commit is contained in:
parent
e5f4935df9
commit
96f29f8e40
16 changed files with 165 additions and 346 deletions
|
|
@ -17,10 +17,12 @@ import android.os.Bundle;
|
|||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.EditTextPreference;
|
||||
|
|
@ -68,6 +70,21 @@ public class MainSettingsManager extends AppCompatActivity
|
|||
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(mToolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
SwitchCompat enableuseVNC = (SwitchCompat) findViewById(R.id.useVNC);
|
||||
|
||||
enableuseVNC.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
MainSettingsManager.setVmUi(activity, "VNC");
|
||||
} else {
|
||||
MainSettingsManager.setVmUi(activity, "X11");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
enableuseVNC.setChecked(MainSettingsManager.getVmUi(activity) == "VNC");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -332,10 +349,10 @@ public class MainSettingsManager extends AppCompatActivity
|
|||
|
||||
public static class VncPreferencesFragment extends PreferenceFragmentCompat
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ public class AppConfig {
|
|||
|
||||
public static String getSetupFiles() {
|
||||
String abi = Build.SUPPORTED_ABIS[0];
|
||||
return releaseUrl + vectrasVersion + "/packages/vectras-vm-" + abi + ".tar.gz";
|
||||
//return releaseUrl + vectrasVersion + "/packages/vectras-vm-" + abi + ".tar.gz";
|
||||
return "https://nguyenbaoanbui-f8a71.web.app/vectrasvm/vectras-vm-" + abi + ".tar.gz";
|
||||
}
|
||||
|
||||
public static final String romsJson(Activity activity) {
|
||||
|
|
@ -64,4 +65,4 @@ public class AppConfig {
|
|||
public static final String sharedFolder = maindirpath + "SharedFolder/";
|
||||
public static final String downloadsFolder = maindirpath + "Downloads/";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -112,6 +112,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
public TextView usedRam;
|
||||
public TextView freeRam;
|
||||
private final Timer _timer = new Timer();
|
||||
private SharedPreferences getAppConfigData;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
|
|
@ -120,6 +121,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
RamInfo.activity = this;
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
getAppConfigData = getSharedPreferences("appconfig", MODE_PRIVATE);
|
||||
VectrasApp.saveappconfig(getApplicationContext());
|
||||
|
||||
setupFolders();
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) activity.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
|
@ -152,9 +156,16 @@ public class MainActivity extends AppCompatActivity {
|
|||
public void onClick(View v) {
|
||||
// Stop the service
|
||||
MainService.stopService();
|
||||
|
||||
Terminal vterm = new Terminal(activity);
|
||||
vterm.executeShellCommand("killall qemu-system-*", false, activity);
|
||||
if (MainSettingsManager.getVmUi(activity).equals("X11")) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(getApplicationContext(),SplashActivity.class);
|
||||
startActivity(intent);
|
||||
Terminal vterm = new Terminal(activity);
|
||||
vterm.executeShellCommand("chmod -x /home/run.sh && pkill -SIGKILL -u root", false, activity);
|
||||
} else {
|
||||
Terminal vterm = new Terminal(activity);
|
||||
vterm.executeShellCommand("killall qemu-system-*", false, activity);
|
||||
}
|
||||
|
||||
extViewerLayout.setVisibility(View.GONE);
|
||||
appbar.setExpanded(false);
|
||||
|
|
@ -641,11 +652,13 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
public static void loadDataVbi() {
|
||||
|
||||
data = new ArrayList<>();
|
||||
|
||||
try {
|
||||
SharedPreferences dataAppConfig = activity.getSharedPreferences("appconfig", activity.MODE_PRIVATE);
|
||||
|
||||
jArray = new JSONArray(FileUtils.readFromFile(MainActivity.activity, new File(AppConfig.maindirpath
|
||||
jArray = new JSONArray(FileUtils.readFromFile(MainActivity.activity, new File(dataAppConfig.getString("maindirpath","")
|
||||
+ "roms-data.json")));
|
||||
|
||||
// Extract data from json and store into ArrayList as class objects
|
||||
|
|
@ -712,7 +725,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
alertDialog.setMessage("All running VMs will be forcibly shut down.");
|
||||
alertDialog.setCancelable(true);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Kill all", (dialog, which) -> {
|
||||
VectrasApp.killallqemuprocesses(getApplicationContext());
|
||||
VectrasApp.killallqemuprocesses(activity);
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> {
|
||||
|
||||
|
|
@ -778,6 +791,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
progressDialog.setMessage("Booting up...");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
if (MainSettingsManager.getVmUi(activity).equals("X11")) {
|
||||
VectrasApp.createrunsh(env, activity);
|
||||
} else {
|
||||
VectrasApp.disablerunsh(activity);
|
||||
}
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
|
|
@ -830,7 +848,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, 2000);
|
||||
String[] params = env.split("\\s+");
|
||||
|
|
@ -840,7 +857,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
VectrasStatus.logInfo(i + ": " + params[i]);
|
||||
Log.d("StartVM", i + ": " + params[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupFolders() {
|
||||
|
|
@ -916,6 +932,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
} else {
|
||||
Log.d("TAG", "The interstitial ad wasn't ready yet.");
|
||||
}
|
||||
VectrasApp.disablerunsh(getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import android.util.Log;
|
|||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
import com.vectras.qemu.MainVNCActivity;
|
||||
import com.vectras.vterm.Terminal;
|
||||
|
||||
|
|
@ -60,10 +61,12 @@ public class MainService extends Service {
|
|||
|
||||
if (env != null) {
|
||||
if (service != null) {
|
||||
Terminal vterm = new Terminal(this);
|
||||
vterm.executeShellCommand("awesome &", false, MainActivity.activity);
|
||||
//vterm.executeShellCommand("pulseaudio --system --disallow-exit --disallow-module-loading --daemonize --log-level=debug --log-time=1");
|
||||
vterm.executeShellCommand(env, true, MainActivity.activity);
|
||||
Terminal vterm = new Terminal(this);
|
||||
vterm.executeShellCommand("awesome &", false, MainActivity.activity);
|
||||
//vterm.executeShellCommand("pulseaudio --system --disallow-exit --disallow-module-loading --daemonize --log-level=debug --log-time=1");
|
||||
if (MainSettingsManager.getVmUi(MainActivity.activity).equals("VNC")) {
|
||||
vterm.executeShellCommand(env, true, MainActivity.activity);
|
||||
}
|
||||
}
|
||||
} else
|
||||
Log.e(TAG, "env is null");
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
vterm.append(textToAdd);
|
||||
|
||||
if (textToAdd.contains("xssFjnj58Id")) {
|
||||
VectrasApp.addrunshtostartup(getApplicationContext());
|
||||
startActivity(new Intent(this, SplashActivity.class));
|
||||
finish();
|
||||
}
|
||||
|
|
@ -409,7 +410,7 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
" apk update;" +
|
||||
" apk add tar libslirp libslirp-dev pulseaudio-dev glib-dev pixman-dev zlib-dev spice-dev" +
|
||||
" libusbredirparser usbredir-dev libiscsi-dev sdl2 sdl2-dev libepoxy-dev virglrenderer-dev rdma-core" +
|
||||
" libusb ncurses-libs curl libnfs sdl2 gtk+3.0 fuse libpulse libseccomp jack pipewire liburing awesome lxterminal font-terminus xkeyboard-config;" +
|
||||
" libusb ncurses-libs curl libnfs sdl2 gtk+3.0 fuse libpulse libseccomp jack pipewire liburing awesome lxterminal font-terminus xkeyboard-config fluxbox;" +
|
||||
" tar -xzvf " + tarPath + " -C /;" +
|
||||
" rm " + tarPath + ";" +
|
||||
" mkdir -p ~/.vnc && echo -e \"555555\\n555555\" | vncpasswd -f > ~/.vnc/passwd && chmod 0600 ~/.vnc/passwd;" +
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class SplashActivity extends AppCompatActivity implements Runnable {
|
|||
MainSettingsManager.setOrientationSetting(activity, 1);
|
||||
|
||||
setupFiles();
|
||||
VectrasApp.disablerunsh(getApplicationContext());
|
||||
}
|
||||
|
||||
public void setupFiles() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.vectras.vm;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.vectras.qemu.Config;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
|
|
@ -27,6 +28,8 @@ public class StartVM {
|
|||
|
||||
ArrayList<String> params = new ArrayList<>(Arrays.asList(qemu));
|
||||
|
||||
SharedPreferences dataAppConfig = activity.getSharedPreferences("appconfig", activity.MODE_PRIVATE);
|
||||
|
||||
if (MainSettingsManager.getArch(activity).equals("I386"))
|
||||
params.add("qemu-system-i386");
|
||||
else if (MainSettingsManager.getArch(activity).equals("X86_64"))
|
||||
|
|
@ -98,7 +101,7 @@ public class StartVM {
|
|||
bios += "openbios-ppc";
|
||||
} else {
|
||||
bios = "-bios ";
|
||||
bios += AppConfig.basefiledir + "bios-vectras.bin";
|
||||
bios += dataAppConfig.getString("basefiledir","") + "bios-vectras.bin";
|
||||
}
|
||||
|
||||
String machine = "-M ";
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
|
|
@ -28,6 +29,7 @@ import androidx.appcompat.app.AppCompatDelegate;
|
|||
import androidx.core.content.res.ResourcesCompat;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
import com.vectras.qemu.Config;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
import com.vectras.vterm.Terminal;
|
||||
|
||||
|
|
@ -50,6 +52,7 @@ import java.util.Date;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class VectrasApp extends Application {
|
||||
public static VectrasApp vectrasapp;
|
||||
|
|
@ -410,12 +413,23 @@ public class VectrasApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
public static void killallqemuprocesses(Context context) {
|
||||
Terminal vterm = new Terminal(context);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-i386", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-x86_64", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-aarch64", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-ppc", false, MainActivity.activity);
|
||||
public static void killallqemuprocesses(Activity activity) {
|
||||
Terminal vterm = new Terminal(activity);
|
||||
if (MainSettingsManager.getVmUi(activity).equals("X11")) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(activity, SplashActivity.class);
|
||||
activity.startActivity(intent);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-i386", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-x86_64", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-aarch64", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-ppc", false, MainActivity.activity);
|
||||
activity.finish();
|
||||
} else {
|
||||
vterm.executeShellCommand("killall -9 qemu-system-i386", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-x86_64", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-aarch64", false, MainActivity.activity);
|
||||
vterm.executeShellCommand("killall -9 qemu-system-ppc", false, MainActivity.activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void killcurrentqemuprocess(Context context) {
|
||||
|
|
@ -437,4 +451,42 @@ public class VectrasApp extends Application {
|
|||
}
|
||||
vterm.executeShellCommand(env, false, MainActivity.activity);
|
||||
}
|
||||
|
||||
public static void disablerunsh(Context context) {
|
||||
Terminal vterm = new Terminal(context);
|
||||
vterm.executeShellCommand("chmod -x /home/run.sh", false, MainActivity.activity);
|
||||
}
|
||||
|
||||
public static void createrunsh(String env,Context context) {
|
||||
Terminal vterm = new Terminal(context);
|
||||
vterm.executeShellCommand("echo 'fluxbox &' > /home/run.sh && echo 'chmod -x /home/run.sh' >> /home/run.sh && echo '"+ env +"' >> /home/run.sh && echo 'pkill -SIGKILL -u root' >> /home/run.sh && chmod +rwx /home/run.sh", true, MainActivity.activity);
|
||||
}
|
||||
|
||||
public static void addrunshtostartup(Context context) {
|
||||
SharedPreferences data = context.getSharedPreferences("addrunshtostartup", context.MODE_PRIVATE);
|
||||
if (!data.getString("isaddedrunshtostartup","").contains("1")) {
|
||||
data.edit().putString("isaddedrunshtostartup", "1").commit();
|
||||
Terminal vterm = new Terminal(context);
|
||||
vterm.executeShellCommand("echo '/home/run.sh' >> /etc/profile", true, MainActivity.activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void logoutroot(String env,Context context) {
|
||||
Terminal vterm = new Terminal(context);
|
||||
vterm.executeShellCommand("pkill -SIGKILL -u root", true, MainActivity.activity);
|
||||
}
|
||||
|
||||
public static void saveappconfig(Context context) {
|
||||
try {
|
||||
SharedPreferences data = context.getSharedPreferences("appconfig", context.MODE_PRIVATE);
|
||||
data.edit().putString("basefiledir", AppConfig.basefiledir).commit();
|
||||
data.edit().putString("maindirpath", AppConfig.maindirpath).commit();
|
||||
data.edit().putString("sharedFolder", AppConfig.sharedFolder).commit();
|
||||
data.edit().putString("downloadsFolder", AppConfig.downloadsFolder).commit();
|
||||
} catch (ExceptionInInitializerError e) {
|
||||
|
||||
} catch (NoClassDefFoundError e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ public class AppUpdater extends AsyncTask<String, String, String> {
|
|||
sb.append(response);
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (ExceptionInInitializerError e) {
|
||||
e.printStackTrace();
|
||||
return "Error on getting data: " + e.getMessage();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
e.printStackTrace();
|
||||
return "Error on getting data: " + e.getMessage();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "Error on getting data: " + e.getMessage();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue