mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-21 10:07:15 -04:00
[JRE auto install] use short-hand method and other stuff
This commit is contained in:
@@ -59,8 +59,8 @@ public class PojavApplication extends Application
|
||||
Tools.datapath = getDir("files", MODE_PRIVATE).getParent();
|
||||
Tools.currentArch = new File(getApplicationInfo().nativeLibraryDir).getName();
|
||||
switch (Tools.currentArch) {
|
||||
case "arm": Tools.currentArch = "arm/aarch32"; break;
|
||||
case "arm64": Tools.currentArch = "arm64/aarch64"; break;
|
||||
case "arm": Tools.currentArch = "aarch32"; break;
|
||||
case "arm64": Tools.currentArch = "aarch64"; break;
|
||||
case "x86": Tools.currentArch = "x86/i*86"; break;
|
||||
case "x86_64": Tools.currentArch = "x86_64/amd64"; break;
|
||||
}
|
||||
|
||||
@@ -423,37 +423,37 @@ public class PojavLoginActivity extends BaseActivity
|
||||
}
|
||||
private boolean installRuntimeAutomatically(AssetManager am) {
|
||||
File rtUniversal = new File(Tools.homeJreDir+"/universal.tar.xz");
|
||||
File rtPlatformDependent = new File(Tools.homeJreDir+"/cust-bin.tar.xz");;
|
||||
File rtPlatformDependent = new File(Tools.homeJreDir+"/cust-bin.tar.xz");
|
||||
InputStream is;
|
||||
FileOutputStream os;
|
||||
try {
|
||||
is = am.open("components/runtime/universal.tar.xz");
|
||||
os = new FileOutputStream(rtUniversal);
|
||||
os = new FileOutputStream(rtUniversal);
|
||||
IOUtils.copy(is,os);
|
||||
is.close();
|
||||
os.close();
|
||||
uncompressTarXZ(rtUniversal, new File(Tools.homeJreDir));
|
||||
}catch(IOException e){
|
||||
} catch (IOException e){
|
||||
Log.e("JREAuto","Failed to unpack universal. Custom embedded-less build?",e);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
is = am.open("components/runtime/bin-" + new File(getApplicationInfo().nativeLibraryDir).getName() + ".tar.xz");
|
||||
is = am.open("components/runtime/bin-" + Tools.currentArch.split("/")[0] + ".tar.xz");
|
||||
os = new FileOutputStream(rtPlatformDependent);
|
||||
IOUtils.copy(is, os);
|
||||
is.close();
|
||||
os.close();
|
||||
uncompressTarXZ(rtPlatformDependent, new File(Tools.homeJreDir));
|
||||
}catch(IOException e) {
|
||||
} catch (IOException e) {
|
||||
//Something's very wrong, or user's using an unsupported arch (MIPS phone? ARMv6 phone?), in both cases, redirecting to manual install, and removing the universal stuff
|
||||
for(File f : new File(Tools.homeJreDir).listFiles()) {
|
||||
if(f.isDirectory()){
|
||||
for (File f : new File(Tools.homeJreDir).listFiles()) {
|
||||
if (f.isDirectory()){
|
||||
try {
|
||||
FileUtils.deleteDirectory(f);
|
||||
}catch(IOException e1) {
|
||||
} catch(IOException e1) {
|
||||
Log.e("JREAuto","da fuq is wrong wit ur device?",e1);
|
||||
}
|
||||
}else{
|
||||
} else{
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,18 +632,6 @@ public final class Tools
|
||||
return out;
|
||||
}
|
||||
|
||||
public static void deleteRecursive(File fileOrDirectory) {
|
||||
try {
|
||||
if (fileOrDirectory.isDirectory()) {
|
||||
for (File child : fileOrDirectory.listFiles()) {
|
||||
deleteRecursive(child);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
fileOrDirectory.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static File lastFileModified(String dir) {
|
||||
File fl = new File(dir);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
import net.kdt.pojavlaunch.R;
|
||||
import org.apache.commons.io.*;
|
||||
|
||||
public class UninstallJREDialogPreference extends Preference implements DialogInterface.OnClickListener
|
||||
{
|
||||
@@ -37,11 +38,16 @@ public class UninstallJREDialogPreference extends Preference implements DialogIn
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
Tools.deleteRecursive(new File(Tools.homeJreDir));
|
||||
getContext().getSharedPreferences("pojav_extract", Context.MODE_PRIVATE)
|
||||
.edit().putBoolean(PojavLoginActivity.PREF_IS_INSTALLED_JAVARUNTIME, false).commit();
|
||||
|
||||
Toast.makeText(getContext(), R.string.toast_uninstalljre_done, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
FileUtils.deleteDirectory(new File(Tools.homeJreDir));
|
||||
|
||||
getContext().getSharedPreferences("pojav_extract", Context.MODE_PRIVATE)
|
||||
.edit().putBoolean(PojavLoginActivity.PREF_IS_INSTALLED_JAVARUNTIME, false).commit();
|
||||
|
||||
Toast.makeText(getContext(), R.string.toast_uninstalljre_done, Toast.LENGTH_SHORT).show();
|
||||
} catch (IOException e) {
|
||||
Tools.showError(getContext(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user