Skip to content

Commit

Permalink
qemu version
Browse files Browse the repository at this point in the history
  • Loading branch information
limboemu committed Sep 24, 2021
1 parent 77474ec commit f28056c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,18 @@ public void run() {
t.start();
}

public static String LoadFile(Activity activity, String fileName, boolean loadFromRawFolder) throws IOException {
public static String LoadFile(Context context, String fileName, boolean loadFromRawFolder) throws IOException {
// Create a InputStream to read the file into
InputStream iS;
if (loadFromRawFolder) {
// get the resource id from the file name
int rID = activity.getResources().getIdentifier(activity.getClass().getPackage().getName() + ":raw/" + fileName,
int rID = context.getResources().getIdentifier(LimboApplication.getInstance().getClass().getPackage().getName() + ":raw/" + fileName,
null, null);
// get the file as a stream
iS = activity.getResources().openRawResource(rID);
iS = context.getResources().openRawResource(rID);
} else {
// get the file as a stream
iS = activity.getResources().getAssets().open(fileName);
iS = context.getResources().getAssets().open(fileName);
}

ByteArrayOutputStream oS = new ByteArrayOutputStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ public class Help {
private static final String TAG = "Help";

public static void showHelp(final Activity activity) {
PackageInfo pInfo = LimboApplication.getPackageInfo();

final AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(activity).create();
alertDialog.setTitle(Config.APP_NAME + " v" + pInfo.versionName + " (" + Config.emuVersion.name().replace("_", ".") + ")");
alertDialog.setTitle(Config.APP_NAME + " " + LimboApplication.getLimboVersionString()
+ " " + "QEMU" + " " + LimboApplication.getQemuVersionString() );

LinearLayout mLayout = new LinearLayout(activity);
mLayout.setOrientation(LinearLayout.VERTICAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private void addGenericOptions(Context context, ArrayList<String> paramsList) {
paramsList.add(Config.tbSize); //Don't increase it crashes
}

if (Config.emuVersion.ordinal() <= Config.EMU_VERSION.QEMUv2_9_1.ordinal()) {
if (LimboApplication.getQemuVersion() == 20901) {
paramsList.add("-realtime");
paramsList.add("mlock=off");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ public void onCreate(Bundle savedInstanceState) {
}

private void setupAppEnvironment() {
LimboApplication.setupPackageInfo(this);
LimboApplication.setupEnv(this);
}

private void setupController() {
Expand Down Expand Up @@ -1260,13 +1260,13 @@ public void importMachines(String importFilePath) {
}

private void promptLicense() {
final PackageInfo finalPInfo = LimboApplication.getPackageInfo();
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
LimboActivityCommon.promptLicense(LimboActivity.this, Config.APP_NAME + " v" + finalPInfo.versionName
+ " (" + Config.emuVersion.name().replace("_", ".") + ")",
LimboActivityCommon.promptLicense(LimboActivity.this,
Config.APP_NAME + " " + LimboApplication.getLimboVersionString()
+ " " + "QEMU" + " " + LimboApplication.getQemuVersionString() ,
FileUtils.LoadFile(LimboActivity.this, "LICENSE", false));
} catch (IOException e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
import android.os.Environment;
import android.util.Log;

import com.max2idea.android.limbo.files.FileUtils;
import com.max2idea.android.limbo.machine.Dispatcher;
import com.max2idea.android.limbo.machine.FavOpenHelper;
import com.max2idea.android.limbo.machine.MachineOpenHelper;
import com.max2idea.android.limbo.toast.ToastUtils;

import java.io.File;
import java.io.IOException;

/**
* We use the application context for the initiliazation of some of the Storage and
Expand All @@ -42,22 +45,34 @@ public class LimboApplication extends Application {
//Do not update these directly, see inherited project java files
public static Config.Arch arch;
private static Context sInstance;
private static PackageInfo packageInfo;
private static String qemuVersionString;
private static int qemuVersion;
private static String limboVersionString;
private static int limboVersion;

public static Context getInstance() {
return sInstance;
}

public static PackageInfo getPackageInfo() {
return packageInfo;
}

public static void setupPackageInfo(Context context) {
public static void setupEnv(Context context) {
try {
packageInfo = context.getPackageManager().getPackageInfo(context.getClass().getPackage().getName(),
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getClass().getPackage().getName(),
PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
limboVersion = packageInfo.versionCode;
limboVersionString = packageInfo.versionName;
Log.d(TAG, "Limbo Version: " + limboVersion);
Log.d(TAG, "Limbo Version Code: " + limboVersionString);

qemuVersionString = FileUtils.LoadFile(context, "QEMU_VERSION", false);
String [] qemuVersionParts = qemuVersionString.trim().split("\\.");
qemuVersion = Integer.parseInt(qemuVersionParts[0]) * 10000
+ Integer.parseInt(qemuVersionParts[1]) * 100
+ Integer.parseInt(qemuVersionParts[2]);
Log.d(TAG, "Qemu Version: " + qemuVersionString);
Log.d(TAG, "Qemu Version Number: " + qemuVersion);
} catch (Exception e) {
e.printStackTrace();
ToastUtils.toastShort(context, "Could not load version information: " + e);
}
}

Expand Down Expand Up @@ -135,6 +150,22 @@ public static String getLocalQMPSocketPath() {
return getInstance().getCacheDir() + "/qmpsocket";
}

public static String getQemuVersionString() {
return qemuVersionString;
}

public static int getQemuVersion() {
return qemuVersion;
}

public static String getLimboVersionString() {
return limboVersionString;
}

public static int getLimboVersion() {
return limboVersion;
}

@Override
public void onCreate() {
super.onCreate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,14 @@ public static void setExitCode(Context context, int exitCode) {
}

public static boolean isFirstLaunch(Context context) {
PackageInfo pInfo = LimboApplication.getPackageInfo();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getBoolean("firstTime" + pInfo.versionName, true);
return prefs.getBoolean("firstTime" + LimboApplication.getLimboVersionString(), true);
}

public static void setFirstLaunch(Context context) {
PackageInfo pInfo = LimboApplication.getPackageInfo();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("firstTime" + pInfo.versionName, false);
edit.putBoolean("firstTime" + LimboApplication.getLimboVersionString(), false);
edit.apply();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public static void checkNewVersion(final Activity activity) {
float version = Float.parseFloat(versionStr);
String versionName = getVersionName(versionStr);

PackageInfo pInfo = LimboApplication.getPackageInfo();
int versionCheck = (int) (version * 100);
if (versionCheck > pInfo.versionCode) {
if (versionCheck > LimboApplication.getLimboVersion()) {
final String finalVersionName = versionName;
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
Expand Down

0 comments on commit f28056c

Please sign in to comment.