Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54433fa66b | ||
|
|
14394772c6 | ||
|
|
97b7b84a5f | ||
|
|
cc3d76ec5f | ||
|
|
af0e0661d9 | ||
|
|
e28dcc5e87 | ||
|
|
cc49cb2a1d | ||
|
|
517cd06f94 | ||
|
|
b19df4e430 | ||
|
|
788c51f586 | ||
|
|
46421a9ee0 | ||
|
|
ae8e9e21d1 | ||
|
|
4f2dc7eb25 | ||
|
|
c2ded22c38 | ||
|
|
6307f6cbcb | ||
|
|
d16ca39c59 | ||
|
|
515d2eaa4e | ||
|
|
7ab71f5f7a | ||
|
|
2f575782a1 | ||
|
|
8426c2fbda | ||
|
|
d0eeef05e2 | ||
|
|
169cf25b28 | ||
|
|
8987d065ce | ||
|
|
82778a6352 | ||
|
|
ee30c7e83e | ||
|
|
1f02968e30 | ||
|
|
bc702243de | ||
|
|
d542f1c947 |
No files matched your search
+1
-1
@@ -56,4 +56,4 @@ deploy:
|
||||
overwrite: true
|
||||
target_commitish: $TRAVIS_COMMIT
|
||||
on:
|
||||
branch: gl4es
|
||||
branch: dalvikvm_gl4es
|
||||
@@ -1,4 +1,4 @@
|
||||

|
||||

|
||||
# PojavLauncher
|
||||
An open source Minecraft: Java Edition launcher for Android based from Boardwalk. Support up-to Minecraft 1.11
|
||||
(Codes has not been sorted yet, it contains ton of classes without packing to module).
|
||||
@@ -9,8 +9,14 @@ Discord server: https://discord.gg/6RpEJda
|
||||
- Impossible for directly run. There's RoboVM but is AOT Compiler. You could also try UTM with Android-x86.
|
||||
- OpenJDK 9 and GL4ES has iOS port so maybe run in a jailbreaked device. I don't have a Mac OS X device to build one.
|
||||
|
||||
## Installing OptiFine?
|
||||
Follow steps [here](https://github.com/khanhduytran0/PojavLauncher/wiki/Install-OptiFine).
|
||||
## About this branch
|
||||
- This branch attempt to launch Minecraft using command line like `dalvikvm` and `app_process`.
|
||||
- Status: working partial, EGL Context not yet shared, process get crashed if attempt to execute OpenGL command.
|
||||
|
||||
|
||||
## Anything if this successful?
|
||||
- Able to custom min/max RAM heap.
|
||||
- Solve some incompatible issues.
|
||||
|
||||
## Installing Forge?
|
||||
Not implemented yet.
|
||||
@@ -131,6 +137,9 @@ Increase max DX references. Launcher Options -> Settings -> Increase max DX refe
|
||||
## A note about 1.12.x
|
||||
- Minecraft 1.12.x can be run on Android 8.0 and above by use d8 for desugar and dexing in the latest v2, but will crash in singleplayer.
|
||||
|
||||
## Solution found!
|
||||
- [twaik/libcw](https://github.com/twaik/libcw) or [shodruky-rhyammer/gl-streaming](https://github.com/shodruky-rhyammer/gl-streaming) but I'm busy at v3.
|
||||
|
||||
## License
|
||||
- PojavLauncher is licensed under [GNU GPLv3](https://github.com/khanhduytran0/PojavLauncher/blob/master/LICENSE).
|
||||
|
||||
@@ -144,3 +153,4 @@ Increase max DX references. Launcher Options -> Settings -> Increase max DX refe
|
||||
- (v3) PRoot: [GNU GPLv2 License](https://github.com/termux/proot/blob/master/COPYING).<br>
|
||||
- (v3) XVnc: [GNU GPLv3 License](https://github.com/theqvd/qvd-client-android/blob/master/LICENSE.txt).
|
||||
- (all) LWJGL 2: [Legacy LWJGL License](http://legacy.lwjgl.org/license.php.html).<br>
|
||||
|
||||
+1
-1
@@ -21,10 +21,10 @@ android {
|
||||
release {
|
||||
// Don't set to true or java.awt will be a.a or something similar.
|
||||
minifyEnabled false
|
||||
debuggable true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
// defaultConfig already set
|
||||
// multiDexEnabled = true
|
||||
debuggable = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,6 @@
|
||||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -76,6 +76,7 @@ import android.graphics.PixelXorXfermode;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
import android.content.Context;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
public class AndroidGraphics2D extends Graphics2D {
|
||||
|
||||
@@ -120,7 +121,7 @@ public class AndroidGraphics2D extends Graphics2D {
|
||||
}
|
||||
|
||||
public static AndroidGraphics2D getInstance(Context ctx, Canvas c, Paint p) {
|
||||
if (c == null || ctx == null) {
|
||||
if (c == null /* || ctx == null */) {
|
||||
throw new RuntimeException(
|
||||
"Illegal argument, Canvas cannot be null!");
|
||||
}
|
||||
@@ -143,7 +144,10 @@ public class AndroidGraphics2D extends Graphics2D {
|
||||
Display d = wm.getDefaultDisplay();
|
||||
displayWidth = d.getWidth();
|
||||
displayHeight = d.getHeight();
|
||||
}
|
||||
} else {
|
||||
displayWidth = AndroidDisplay.windowWidth;
|
||||
displayHeight = AndroidDisplay.windowHeight;
|
||||
}
|
||||
blitter = new AndroidJavaBlitter(c);
|
||||
cm = new DirectColorModel(32, 0xff0000, 0xff00, 0xff, 0xff000000);
|
||||
sm = new SinglePixelPackedSampleModel(
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.android.gles_jni;
|
||||
import javax.microedition.khronos.egl.*;
|
||||
import javax.microedition.khronos.opengles.*;
|
||||
|
||||
public class EGLContextImpl extends EGLContext
|
||||
{
|
||||
public EGLContextImpl(long ctx) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public GL getGL() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+16
-3
@@ -1,4 +1,4 @@
|
||||
package com.kdt.glsupport;
|
||||
package com.kdt.minecraftegl;
|
||||
|
||||
// Search "DISABLED" to find disabled codes.
|
||||
|
||||
@@ -22,10 +22,13 @@ import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.View.*;
|
||||
|
||||
public class GLTextureView
|
||||
public class GLTextureView extends SurfaceTextureView implements SurfaceTextureView.SurfaceTextureListener
|
||||
/*
|
||||
extends TextureView
|
||||
implements TextureView.SurfaceTextureListener,
|
||||
View.OnLayoutChangeListener {
|
||||
View.OnLayoutChangeListener
|
||||
*/
|
||||
{
|
||||
|
||||
private final static String TAG = "GLTextureView";
|
||||
private final static boolean LOG_ALL = true;
|
||||
@@ -72,23 +75,32 @@ public class GLTextureView
|
||||
*/
|
||||
public final static int DEBUG_LOG_GL_CALLS = 2;
|
||||
|
||||
public GLTextureView(long lSurfaceTexture, long lProducer, long lFrameAvailableListener) {
|
||||
super(lSurfaceTexture, lProducer, lFrameAvailableListener);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard View constructor. In order to render something, you
|
||||
* must call {@link #setRenderer} to register a renderer.
|
||||
*/
|
||||
/*
|
||||
public GLTextureView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Standard View constructor. In order to render something, you
|
||||
* must call {@link #setRenderer} to register a renderer.
|
||||
*/
|
||||
/*
|
||||
public GLTextureView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
@@ -457,6 +469,7 @@ public class GLTextureView
|
||||
* called or subclassed by clients of GLTextureView.
|
||||
* Must not be called before a renderer has been set.
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
if (LOG_ATTACH_DETACH) {
|
||||
@@ -0,0 +1,196 @@
|
||||
package com.kdt.minecraftegl;
|
||||
|
||||
import android.graphics.*;
|
||||
import android.os.*;
|
||||
import android.system.*;
|
||||
import com.android.internal.awt.*;
|
||||
import dalvik.system.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import javax.microedition.khronos.egl.*;
|
||||
import javax.microedition.khronos.opengles.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import net.kdt.pojavlaunch.exit.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import static org.lwjgl.opengl.AndroidContextImplementation.*;
|
||||
|
||||
public class MinecraftEGLInitializer
|
||||
{
|
||||
public static void main(final String[] args) throws Throwable {
|
||||
/*
|
||||
new Thread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
runOnThread(args);
|
||||
}
|
||||
}).start();
|
||||
*/
|
||||
|
||||
runOnThread(args);
|
||||
}
|
||||
|
||||
private static void runOnThread(final String[] args) {
|
||||
try {
|
||||
Tools.datapath = System.getenv("POJAV_DATA_DIR");
|
||||
|
||||
// long surfaceAddress = Long.parseLong(args[0]);
|
||||
|
||||
// Disable for testing
|
||||
ExitManager.disableSystemExit();
|
||||
Thread.sleep(200);
|
||||
// System.out.println(Arrays.toString(args));
|
||||
|
||||
MainActivity.fixRSAPadding(null);
|
||||
|
||||
long lSurfaceTexture = Long.parseLong(args[0]);
|
||||
long lProducer = Long.parseLong(args[1]);
|
||||
long lFrameAvailableListener = Long.parseLong(args[2]);
|
||||
|
||||
AndroidDisplay.windowWidth = Integer.parseInt(args[3]);
|
||||
AndroidDisplay.windowHeight = Integer.parseInt(args[4]);
|
||||
|
||||
Bitmap awtGraphics = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
|
||||
AndroidGraphics2D.getInstance(null, new Canvas(awtGraphics), null);
|
||||
|
||||
GLTextureView gtv = new GLTextureView(lSurfaceTexture, lProducer, lFrameAvailableListener);
|
||||
gtv.setRenderer(new GLTextureView.Renderer() {
|
||||
@Override
|
||||
public void onSurfaceDestroyed(GL10 gl) {
|
||||
System.out.println("Surface destroyed.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, javax.microedition.khronos.egl.EGLConfig p2)
|
||||
{
|
||||
EGL10 egl10 = (EGL10) EGLContext.getEGL();
|
||||
|
||||
AndroidContextImplementation.theEgl = egl10;
|
||||
AndroidContextImplementation.context = egl10.eglGetCurrentContext();
|
||||
AndroidContextImplementation.display = egl10.eglGetCurrentDisplay();
|
||||
AndroidContextImplementation.read = egl10.eglGetCurrentSurface(EGL10.EGL_READ);
|
||||
AndroidContextImplementation.draw = egl10.eglGetCurrentSurface(EGL10.EGL_DRAW);
|
||||
egl10.eglMakeCurrent(AndroidContextImplementation.display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
|
||||
System.out.println(new StringBuffer().append("Gave up context: ").append(AndroidContextImplementation.context).toString());
|
||||
|
||||
int eglGetError = egl10.eglGetError();
|
||||
System.out.println("eglGetError: " + Integer.toString(eglGetError) + ", success: " + Boolean.toString(eglGetError == EGL10.EGL_SUCCESS));
|
||||
|
||||
MainActivity.launchClassPath = args[5];
|
||||
MainActivity.launchOptimizedDirectory = args[6];
|
||||
MainActivity.launchLibrarySearchPath = args[7];
|
||||
|
||||
// System.out.println("Received EGL context address: " + Long.toString(eglAddress));
|
||||
|
||||
String minecraftMainClass = args[8];
|
||||
List<String> minecraftArgs = new ArrayList<String>();
|
||||
// 10
|
||||
for (int i = 9; i < args.length; i++) {
|
||||
if (args[i] != null && !args[i].isEmpty())
|
||||
minecraftArgs.add(args[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
initEnvs();
|
||||
System.out.println("user.home: " + System.getProperty("user.home"));
|
||||
|
||||
// ActivityThread.currentActivityThread().getSystemContext().startActivity(new Intent().setComponent(new ComponentName("net.kdt.pojavlaunch", ".CustomControlsActivity")));
|
||||
|
||||
/*
|
||||
GL10 gl = ((GL10) context.getGL());
|
||||
gl.glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
|
||||
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||
int glErr = gl.glGetError();
|
||||
*/
|
||||
DexClassLoader classLoader = new DexClassLoader(MainActivity.launchClassPath, MainActivity.launchOptimizedDirectory, MainActivity.launchLibrarySearchPath, MinecraftEGLInitializer.class.getClassLoader());
|
||||
Class minecraftClass = classLoader.loadClass(minecraftMainClass);
|
||||
Method minecraftMethod = minecraftClass.getMethod("main", String[].class);
|
||||
minecraftMethod.invoke(null, new Object[]{minecraftArgs.toArray(new String[0])});
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
//mkToast("onDrawFrame");
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height) {
|
||||
AndroidDisplay.windowWidth = width;
|
||||
AndroidDisplay.windowHeight = height;
|
||||
}
|
||||
});
|
||||
gtv.setPreserveEGLContextOnPause(true);
|
||||
gtv.setRenderMode(GLTextureView.RENDERMODE_CONTINUOUSLY);
|
||||
gtv.setSize(AndroidDisplay.windowWidth, AndroidDisplay.windowHeight);
|
||||
|
||||
// hmmmm
|
||||
while (true) {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
System.err.println("UNEXCEPTED SHUTTING DOWN");
|
||||
th.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static EGLConfig getEglConfig(EGL10 egl, EGLDisplay eglDisplay, int[] configAttributes) {
|
||||
EGLConfig[] configs = new EGLConfig[1];
|
||||
int[] numConfigs = new int[1];
|
||||
if (!egl.eglChooseConfig(eglDisplay, configAttributes, configs, configs.length, numConfigs)) {
|
||||
throw new RuntimeException(
|
||||
"eglChooseConfig failed: 0x" + Integer.toHexString(egl.eglGetError()));
|
||||
}
|
||||
if (numConfigs[0] <= 0) {
|
||||
throw new RuntimeException("Unable to find any matching EGL config");
|
||||
}
|
||||
final EGLConfig eglConfig = configs[0];
|
||||
if (eglConfig == null) {
|
||||
throw new RuntimeException("eglChooseConfig returned null");
|
||||
}
|
||||
return eglConfig;
|
||||
}
|
||||
|
||||
public static void forceUserHome(String s) throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Class clazz = props.getClass();
|
||||
Field f = null;
|
||||
while (clazz != null) {
|
||||
try {
|
||||
f = clazz.getDeclaredField("defaults");
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
if (f != null) {
|
||||
f.setAccessible(true);
|
||||
Properties p = ((Properties) f.get(props));
|
||||
p.put("user.home", s);
|
||||
// p.put("user.dir", s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initEnvs() throws Exception {
|
||||
Os.setenv("LIBGL_MIPMAP", "3", true);
|
||||
System.setProperty("user.home", Tools.MAIN_PATH);
|
||||
if (!System.getProperty("user.home", "/").equals(Tools.MAIN_PATH)) {
|
||||
forceUserHome(Tools.MAIN_PATH);
|
||||
}
|
||||
System.setProperty("org.apache.logging.log4j.level", "INFO");
|
||||
System.setProperty("org.apache.logging.log4j.simplelog.level", "INFO");
|
||||
|
||||
// Disable javax management for smaller launcher.
|
||||
System.setProperty("log4j2.disable.jmx", "true");
|
||||
|
||||
//System.setProperty("net.zhuoweizhang.boardwalk.org.apache.logging.log4j.level", "INFO");
|
||||
//System.setProperty("net.zhuoweizhang.boardwalk.org.apache.logging.log4j.simplelog.level", "INFO");
|
||||
|
||||
// Change info for useful dump
|
||||
System.setProperty("java.vm.info", Build.MANUFACTURER + " " + Build.MODEL + ", Android " + Build.VERSION.RELEASE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.kdt.minecraftegl;
|
||||
|
||||
import android.graphics.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
public class SurfaceTextureView
|
||||
{
|
||||
private SurfaceTexture mSurfaceTexture;
|
||||
private SurfaceTextureListener mListener;
|
||||
private boolean isTextureAvailable = false;
|
||||
public SurfaceTextureView(long lSurfaceTexture, long lProducer, long lFrameAvailableListener) {
|
||||
mSurfaceTexture = new SurfaceTexture(true);
|
||||
|
||||
try {
|
||||
Tools.findField(mSurfaceTexture, "mSurfaceTexture").set(mSurfaceTexture, lSurfaceTexture);
|
||||
// Tools.findField(mSurfaceTexture, "mProducer").set(mSurfaceTexture, lProducer);
|
||||
Tools.findField(mSurfaceTexture, "mFrameAvailableListener").set(mSurfaceTexture, lFrameAvailableListener);
|
||||
} catch (Throwable th) {
|
||||
throw new RuntimeException(th);
|
||||
}
|
||||
}
|
||||
|
||||
public SurfaceTexture getSurfaceTexture() {
|
||||
return mSurfaceTexture;
|
||||
}
|
||||
|
||||
public void setSize(int width, int height) {
|
||||
if (mListener != null) {
|
||||
if (isTextureAvailable) {
|
||||
mListener.onSurfaceTextureSizeChanged(mSurfaceTexture, width, height);
|
||||
} else {
|
||||
onAttachedToWindow();
|
||||
mListener.onSurfaceTextureAvailable(mSurfaceTexture, width, height);
|
||||
|
||||
isTextureAvailable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSurfaceTextureListener(SurfaceTextureListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void updateTexImage() {
|
||||
if (mListener != null) mListener.onSurfaceTextureUpdated(mSurfaceTexture);
|
||||
}
|
||||
|
||||
protected void onAttachedToWindow() {
|
||||
// if (mListener != null) mListener.onSurfaceTextureAvailable(mSurfaceTexture);
|
||||
}
|
||||
|
||||
protected void onDetachedFromWindow() {
|
||||
if (mListener != null) mListener.onSurfaceTextureDestroyed(mSurfaceTexture);
|
||||
}
|
||||
|
||||
/**
|
||||
* This listener can be used to be notified when the surface texture
|
||||
* associated with this texture view is available.
|
||||
*/
|
||||
public static interface SurfaceTextureListener {
|
||||
/**
|
||||
* Invoked when a {@link TextureView}'s SurfaceTexture is ready for use.
|
||||
*
|
||||
* @param surface The surface returned by
|
||||
* {@link android.view.TextureView#getSurfaceTexture()}
|
||||
* @param width The width of the surface
|
||||
* @param height The height of the surface
|
||||
*/
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height);
|
||||
/**
|
||||
* Invoked when the {@link SurfaceTexture}'s buffers size changed.
|
||||
*
|
||||
* @param surface The surface returned by
|
||||
* {@link android.view.TextureView#getSurfaceTexture()}
|
||||
* @param width The new width of the surface
|
||||
* @param height The new height of the surface
|
||||
*/
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height);
|
||||
/**
|
||||
* Invoked when the specified {@link SurfaceTexture} is about to be destroyed.
|
||||
* If returns true, no rendering should happen inside the surface texture after this method
|
||||
* is invoked. If returns false, the client needs to call {@link SurfaceTexture#release()}.
|
||||
* Most applications should return true.
|
||||
*
|
||||
* @param surface The surface about to be destroyed
|
||||
*/
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface);
|
||||
/**
|
||||
* Invoked when the specified {@link SurfaceTexture} is updated through
|
||||
* {@link SurfaceTexture#updateTexImage()}.
|
||||
*
|
||||
* @param surface The surface just updated
|
||||
*/
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surface);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.kdt.minecraftegl;
|
||||
import android.view.*;
|
||||
import java.lang.reflect.*;
|
||||
|
||||
public class SurfaceUtils
|
||||
{
|
||||
public static long getSurfaceAddress(Surface surface) {
|
||||
try {
|
||||
Field field = surface.getClass().getDeclaredField("mNativeObject");
|
||||
field.setAccessible(true);
|
||||
return (long) field.get(surface);
|
||||
} catch (Throwable th) {
|
||||
System.err.println("Unable to get surface address!");
|
||||
th.printStackTrace();
|
||||
}
|
||||
|
||||
return -1l;
|
||||
}
|
||||
|
||||
public static Surface createSurfaceByAddress(long surfaceAddress) {
|
||||
try {
|
||||
Constructor c = Surface.class.getDeclaredConstructor(long.class);
|
||||
c.setAccessible(true);
|
||||
return (Surface) c.newInstance(surfaceAddress);
|
||||
} catch (Throwable th) {
|
||||
System.err.println("Unable to create surface by address!");
|
||||
th.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,9 @@ import android.graphics.*;
|
||||
import java.awt.image.*;
|
||||
import javax.imageio.stream.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.jar.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
/**
|
||||
* The ImageIO class provides static methods to perform reading and writing
|
||||
@@ -428,7 +431,26 @@ public final class ImageIO {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("input == null!");
|
||||
}
|
||||
|
||||
|
||||
// DEBUG
|
||||
/*
|
||||
if (input.getClass().getName().equals("libcore.net.url.JarURLConnectionImpl$JarURLConnectionInputStream")) {
|
||||
try {
|
||||
Field f = input.getClass().getDeclaredField("jarFile");
|
||||
f.setAccessible(true);
|
||||
JarFile jf = (JarFile) f.get(input);
|
||||
Field f2 = input.getClass().getField("fileName");
|
||||
f2.setAccessible(true);
|
||||
System.out.println("Found JarFile = " + f2.get(jf).toString());
|
||||
} catch (Throwable th) {
|
||||
System.err.println("Unable to get jarFile.");
|
||||
System.err.println("__________ BEGIN ERR");
|
||||
th.printStackTrace();
|
||||
System.err.println("__________ ENDED ERR");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
ImageInputStream stream = createImageInputStream(input);
|
||||
return read(stream);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ package javax.imageio.spi;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
/**
|
||||
* The ImageInputStreamSpi abstract class is a service provider interface (SPI)
|
||||
@@ -126,6 +127,6 @@ public abstract class ImageInputStreamSpi extends IIOServiceProvider implements
|
||||
* if an I/O exception has occurred.
|
||||
*/
|
||||
public ImageInputStream createInputStreamInstance(Object input) throws IOException {
|
||||
return createInputStreamInstance(input, true, null);
|
||||
return createInputStreamInstance(input, true, new File(Tools.datapath, "cache"));
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import android.view.View.*;
|
||||
import android.view.inputmethod.*;
|
||||
import android.widget.*;
|
||||
import com.android.internal.awt.*;
|
||||
import com.kdt.glsupport.*;
|
||||
import com.kdt.pointer.*;
|
||||
import dalvik.system.*;
|
||||
import java.io.*;
|
||||
@@ -33,6 +32,11 @@ import org.lwjgl.opengl.*;
|
||||
import sun.security.jca.*;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||
import com.google.android.gles_jni.*;
|
||||
import com.kdt.minecraftegl.*;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements OnTouchListener, OnClickListener
|
||||
{
|
||||
@@ -112,6 +116,8 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
private View.OnTouchListener glTouchListener;
|
||||
|
||||
private Button[] controlButtons;
|
||||
|
||||
private PrintStream logStream;
|
||||
|
||||
/*
|
||||
private LinearLayout contentCanvas;
|
||||
@@ -121,7 +127,6 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
private boolean lastGrab = false;
|
||||
private boolean isExited = false;
|
||||
private boolean isLogAllow = false;
|
||||
private int navBarHeight = 40;
|
||||
|
||||
// private static Collection<? extends Provider.Service> rsaPkcs1List;
|
||||
|
||||
@@ -136,6 +141,11 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
setContentView(R.layout.main);
|
||||
|
||||
try {
|
||||
File logFile = new File(Tools.MAIN_PATH, "latestlog.txt");
|
||||
logFile.delete();
|
||||
logFile.createNewFile();
|
||||
logStream = new PrintStream(logFile.getAbsolutePath());
|
||||
|
||||
final View decorView = getWindow().getDecorView();
|
||||
decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() {
|
||||
@Override
|
||||
@@ -151,6 +161,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
ExitManager.setExitTrappedListener(new ExitManager.ExitTrappedListener(){
|
||||
@Override
|
||||
public void onExitTrapped()
|
||||
@@ -202,16 +213,17 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
Log.w(Tools.APP_NAME, "Could not disable System.exit() method!", th);
|
||||
}
|
||||
|
||||
*/
|
||||
File optDir = getDir("dalvik-cache", 0);
|
||||
optDir.mkdirs();
|
||||
launchOptimizedDirectory = optDir.getAbsolutePath();
|
||||
|
||||
|
||||
|
||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||
mVersionInfo = Tools.getVersionInfo(mProfile.getVersion());
|
||||
|
||||
setTitle("Minecraft " + mProfile.getVersion());
|
||||
|
||||
initEnvs();
|
||||
//System.loadLibrary("gl4es");
|
||||
/*
|
||||
if (mVersionInfo.arguments != null) {
|
||||
@@ -456,7 +468,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
|
||||
glSurfaceView.setFocusable(true);
|
||||
glSurfaceView.setFocusableInTouchMode(true);
|
||||
glSurfaceView.setEGLContextClientVersion(2);
|
||||
// glSurfaceView.setEGLContextClientVersion(2);
|
||||
|
||||
glTouchListener = new OnTouchListener(){
|
||||
private boolean isTouchInHotbar = false;
|
||||
@@ -648,6 +660,8 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
});
|
||||
}
|
||||
|
||||
calculateMcScale();
|
||||
|
||||
glSurfaceView.setOnHoverListener(new View.OnHoverListener(){
|
||||
@Override
|
||||
public boolean onHover(View p1, MotionEvent p2) {
|
||||
@@ -658,7 +672,61 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
}
|
||||
});
|
||||
glSurfaceView.setOnTouchListener(glTouchListener);
|
||||
glSurfaceView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
|
||||
|
||||
private boolean surfaceInited = false;
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(final SurfaceTexture texture, int width, int height)
|
||||
{
|
||||
AndroidDisplay.windowWidth = width;
|
||||
AndroidDisplay.windowHeight = height;
|
||||
if (!surfaceInited) {
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
long mSurfaceTexture = (long) Tools.findField(texture, "mSurfaceTexture").get(texture);
|
||||
long mProducer = (long) Tools.findField(texture, "mProducer").get(texture);
|
||||
long mFrameAvailableListener = (long) Tools.findField(texture, "mFrameAvailableListener").get(texture);
|
||||
runCraft(mSurfaceTexture, mProducer, mFrameAvailableListener);
|
||||
} catch (Throwable e) {
|
||||
Tools.showError(MainActivity.this, e, true);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
surfaceInited = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture p1)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture p1, int width, int height)
|
||||
{
|
||||
AndroidDisplay.windowWidth = width;
|
||||
AndroidDisplay.windowHeight = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture p1)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|
||||
glSurfaceView.setRenderer(new GLTextureView.Renderer() {
|
||||
private volatile long eglContext = 0l;
|
||||
@Override
|
||||
public void onSurfaceDestroyed(GL10 gl) {
|
||||
Log.d(Tools.APP_NAME, "Surface destroyed.");
|
||||
@@ -667,9 +735,11 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, javax.microedition.khronos.egl.EGLConfig p2)
|
||||
{
|
||||
calculateMcScale();
|
||||
|
||||
|
||||
EGL10 egl10 = (EGL10) EGLContext.getEGL();
|
||||
|
||||
/ *
|
||||
AndroidContextImplementation.theEgl = egl10;
|
||||
AndroidContextImplementation.context = egl10.eglGetCurrentContext();
|
||||
AndroidContextImplementation.display = egl10.eglGetCurrentDisplay();
|
||||
@@ -678,21 +748,22 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
egl10.eglMakeCurrent(AndroidContextImplementation.display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
|
||||
System.out.println(new StringBuffer().append("Gave up context: ").append(AndroidContextImplementation.context).toString());
|
||||
|
||||
AndroidDisplay.windowWidth += navBarHeight;
|
||||
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
runCraft();
|
||||
} catch (Throwable e) {
|
||||
Tools.showError(MainActivity.this, e, true);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
AndroidDisplay.windowWidth += navBarHeight;
|
||||
|
||||
* /
|
||||
|
||||
EGLContextImpl eglContextImpl = (EGLContextImpl) egl10.eglGetCurrentContext();
|
||||
try {
|
||||
Field eglContextField = eglContextImpl.getClass().getDeclaredField("mEGLContext");
|
||||
eglContextField.setAccessible(true);
|
||||
eglContext = (long) eglContextField.get(eglContextImpl);
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(MainActivity.this, th, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
@@ -707,6 +778,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
});
|
||||
glSurfaceView.setPreserveEGLContextOnPause(true);
|
||||
glSurfaceView.setRenderMode(MinecraftGLView.RENDERMODE_CONTINUOUSLY);
|
||||
*/
|
||||
// glSurfaceView.requestRender();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@@ -764,7 +836,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mIsResuming = true;
|
||||
if (glSurfaceView != null) glSurfaceView.requestRender();
|
||||
// if (glSurfaceView != null) glSurfaceView.requestRender();
|
||||
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
final View decorView = getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
@@ -905,7 +977,6 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
Tools.showError(MainActivity.this, e, true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPointerCaptureSupported() {
|
||||
return Build.VERSION.SDK_INT >= 26;
|
||||
}
|
||||
@@ -1001,7 +1072,8 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
public static String launchClassPath;
|
||||
public static String launchOptimizedDirectory;
|
||||
public static String launchLibrarySearchPath;
|
||||
private void runCraft() throws Throwable //oncreate
|
||||
private void runCraft(long lSurfaceTexture, long lProducer, long lFrameAvailableListener) throws Throwable
|
||||
|
||||
{
|
||||
LoggerJava.OnStringPrintListener printLog = new LoggerJava.OnStringPrintListener(){
|
||||
@Override
|
||||
@@ -1027,14 +1099,14 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
|
||||
launchClassPath = Tools.generateLaunchClassPath(mProfile.getVersion());
|
||||
launchLibrarySearchPath = getApplicationInfo().nativeLibraryDir;
|
||||
/* gl4es
|
||||
|
||||
if (mVersionInfo.mainClass.equals("net.minecraft.launchwrapper.Launch")) {
|
||||
net.minecraft.launchwrapper.Launch.main(launchArgs);
|
||||
} else {
|
||||
/*
|
||||
PrintStream theStreamErr = new PrintStream(new LoggerJava.LoggerOutputStream(System.err, printLog));
|
||||
System.setErr(theStreamErr);
|
||||
*/
|
||||
|
||||
fixRSAPadding(this);
|
||||
|
||||
appendlnToLog("Running Minecraft with classpath: \n" + launchClassPath + "\n", false);
|
||||
@@ -1042,17 +1114,86 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
// Load classpath
|
||||
DexClassLoader launchBaseLoader = new DexClassLoader(launchClassPath, launchOptimizedDirectory, launchLibrarySearchPath, getClassLoader());
|
||||
|
||||
// Launch Minecraft
|
||||
Class mainClass = launchBaseLoader.loadClass(mVersionInfo.mainClass);
|
||||
Method mainMethod = mainClass.getMethod("main", String[].class);
|
||||
mainMethod.setAccessible(true);
|
||||
mainMethod.invoke(null, new Object[]{launchArgs});
|
||||
LoggerJava.OnStringPrintListener printLog = new LoggerJava.OnStringPrintListener(){
|
||||
@Override
|
||||
public void onCharPrint(char c) {
|
||||
appendToLog(Character.toString(c));
|
||||
}
|
||||
};
|
||||
*/
|
||||
fixRSAPadding(this);
|
||||
|
||||
appendlnToLog("> Running Minecraft with classpath:");
|
||||
appendlnToLog(launchClassPath + "\n");
|
||||
|
||||
Thread.sleep(200);
|
||||
|
||||
ShellProcessOperation shell = new ShellProcessOperation(new ShellProcessOperation.OnPrintListener(){
|
||||
|
||||
@Override
|
||||
public void onPrintLine(String text) {
|
||||
appendToLog(text);
|
||||
}
|
||||
}, "sh");
|
||||
shell.initInputStream(this);
|
||||
|
||||
shell.writeToProcess("base=/system");
|
||||
shell.writeToProcess("export POJAV_DATA_DIR=" + Tools.datapath);
|
||||
shell.writeToProcess("export CLASSPATH=" + getApplicationInfo().publicSourceDir); // ":" + launchClassPath + "\n");
|
||||
shell.writeToProcess("export HOME=" + Tools.MAIN_PATH);
|
||||
shell.writeToProcess("export MESA_GLSL_CACHE_DIR=$POJAV_DATA_DIR/cache");
|
||||
String argStr = "";
|
||||
for (String arg : launchArgs) {
|
||||
argStr = argStr + " " + arg;
|
||||
}
|
||||
// app_process32 because this app is 32-bit only.
|
||||
String execAppProcessStr = (
|
||||
"exec app_process32 " +
|
||||
"-Xmx512M " + // Max heap
|
||||
"-Djava.library.path=/system/lib:" + getApplicationInfo().nativeLibraryDir + " " +
|
||||
"$base/bin com.kdt.minecraftegl.MinecraftEGLInitializer " +
|
||||
Long.toString(lSurfaceTexture) + " " +
|
||||
Long.toString(lProducer) + " " +
|
||||
Long.toString(lFrameAvailableListener) + " " +
|
||||
|
||||
Integer.toString(AndroidDisplay.windowWidth) + " " +
|
||||
Integer.toString(AndroidDisplay.windowHeight) + " " +
|
||||
|
||||
/* Long.toString(SurfaceUtils.getSurfaceAddress(((SurfaceView) glSurfaceView).getHolder().getSurface())) + "" + */
|
||||
launchClassPath + " " + launchOptimizedDirectory + " " + launchLibrarySearchPath + " " +
|
||||
this.mVersionInfo.mainClass + " " + argStr
|
||||
);
|
||||
shell.writeToProcess(execAppProcessStr);
|
||||
|
||||
final int waitFor = shell.waitFor();
|
||||
|
||||
runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
AlertDialog.Builder d = new AlertDialog.Builder(MainActivity.this);
|
||||
d.setTitle(R.string.mcn_exit_title);
|
||||
d.setMessage("Exited with code " + waitFor);
|
||||
d.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
// finish();
|
||||
}
|
||||
});
|
||||
d.setCancelable(false);
|
||||
d.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void fixRSAPadding(final Activity act) {
|
||||
/*
|
||||
private void createEGLHackStuff() {
|
||||
|
||||
}
|
||||
*/
|
||||
// welcome to the territory of YOLO; I'll be your tour guide for today.
|
||||
|
||||
final boolean isLegacyPatch = Build.VERSION.SDK_INT < 24;
|
||||
@@ -1323,7 +1464,12 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
}
|
||||
|
||||
private void appendToLog(final String text, boolean checkAllow) {
|
||||
logStream.print(text);
|
||||
if (checkAllow && !isLogAllow) return;
|
||||
/*
|
||||
private void appendToLog(final String text) {
|
||||
*/
|
||||
// if (!isLogAllow) r
|
||||
textLog.post(new Runnable(){
|
||||
@Override
|
||||
public void run()
|
||||
|
||||
@@ -3,9 +3,9 @@ package net.kdt.pojavlaunch;
|
||||
import android.content.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
import com.kdt.glsupport.*;
|
||||
|
||||
public class MinecraftGLView extends GLTextureView
|
||||
public class MinecraftGLView extends TextureView
|
||||
// GLTextureView
|
||||
{
|
||||
// private View.OnTouchListener mTouchListener;
|
||||
public MinecraftGLView(Context context) {
|
||||
@@ -17,18 +17,5 @@ public class MinecraftGLView extends GLTextureView
|
||||
super(context, attributeSet);
|
||||
//setPreserveEGLContextOnPause(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnTouchListener(View.OnTouchListener l)
|
||||
{
|
||||
super.setOnTouchListener(l);
|
||||
// mTouchListener = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnClickListener(View.OnClickListener l)
|
||||
{
|
||||
super.setOnClickListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import android.*;
|
||||
import android.Manifest;
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.content.pm.*;
|
||||
import android.net.*;
|
||||
import android.os.*;
|
||||
import android.support.annotation.*;
|
||||
import android.support.v4.app.*;
|
||||
import android.support.v4.content.*;
|
||||
import android.system.*;
|
||||
import android.text.method.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import android.widget.CompoundButton.*;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import static android.view.ViewGroup.LayoutParams.*;
|
||||
|
||||
import com.kdt.filermod.*;
|
||||
import com.kdt.mcgui.app.*;
|
||||
import com.kdt.mojangauth.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import android.widget.CompoundButton.*;
|
||||
import android.text.method.*;
|
||||
import android.system.*;
|
||||
import android.net.*;
|
||||
import static android.view.ViewGroup.LayoutParams.*;
|
||||
|
||||
import net.kdt.pojavlaunch.update.*;
|
||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
public class PojavLoginActivity extends AppCompatActivity
|
||||
// MineActivity
|
||||
@@ -57,68 +60,7 @@ public class PojavLoginActivity extends AppCompatActivity
|
||||
firstLaunchPrefs = getSharedPreferences("pojav_extract", MODE_PRIVATE);
|
||||
new File(Tools.mpProfiles).mkdir();
|
||||
|
||||
// Remove vmos warning???
|
||||
/*
|
||||
if (isAndroid7() && !firstLaunchPrefs.getBoolean(PREF_IS_DONOTSHOWAGAIN_WARN, false)) {
|
||||
AlertDialog.Builder startDlg = new AlertDialog.Builder(PojavLoginActivity.this);
|
||||
startDlg.setTitle(R.string.warning_title);
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
|
||||
|
||||
LinearLayout conLay = new LinearLayout(this);
|
||||
conLay.setLayoutParams(params);
|
||||
conLay.setOrientation(LinearLayout.VERTICAL);
|
||||
TextView conText = new TextView(this);
|
||||
conText.setText(R.string.warning_msg);
|
||||
conText.setLayoutParams(params);
|
||||
final CheckBox conCheck = new CheckBox(this);
|
||||
conCheck.setText(R.string.warning_noshowagain);
|
||||
conCheck.setLayoutParams(params);
|
||||
conLay.addView(conCheck);
|
||||
|
||||
conLay.addView(conText);
|
||||
|
||||
startDlg.setView(conLay);
|
||||
startDlg.setCancelable(false);
|
||||
startDlg.setPositiveButton(R.string.warning_action_install, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
setPref(PREF_IS_DONOTSHOWAGAIN_WARN, conCheck.isChecked());
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse("market://details?id=com.vmos.glb"));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
startDlg.setNegativeButton(R.string.warning_action_tryanyway, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
setPref(PREF_IS_DONOTSHOWAGAIN_WARN, conCheck.isChecked());
|
||||
|
||||
new InitTask().execute();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
startDlg.setNeutralButton(R.string.warning_action_exit, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2)
|
||||
{
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
startDlg.show();
|
||||
} else {
|
||||
*/
|
||||
new InitTask().execute();
|
||||
// }
|
||||
new InitTask().execute();
|
||||
}
|
||||
|
||||
private class InitTask extends AsyncTask<Void, String, Integer>{
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SecondaryDexLoader
|
||||
Log.w(TAG, "Exception in makeDexElement", e);
|
||||
}
|
||||
Field suppressedExceptionsField =
|
||||
findField(loader, "dexElementsSuppressedExceptions");
|
||||
Tools.findField(loader, "dexElementsSuppressedExceptions");
|
||||
IOException[] dexElementsSuppressedExceptions =
|
||||
(IOException[]) suppressedExceptionsField.get(loader);
|
||||
if (dexElementsSuppressedExceptions == null) {
|
||||
@@ -55,7 +55,7 @@ public class SecondaryDexLoader
|
||||
}
|
||||
|
||||
private static /* DexPathList */ Object getDexPathList(ClassLoader loader) throws Throwable {
|
||||
Field pathListField = findField(loader, "pathList");
|
||||
Field pathListField = Tools.findField(loader, "pathList");
|
||||
return pathListField.get(loader);
|
||||
}
|
||||
|
||||
@@ -64,57 +64,10 @@ public class SecondaryDexLoader
|
||||
* {@code private static final dalvik.system.DexPathList#makeDexElements}.
|
||||
*/
|
||||
private static Object[] makeDexElements(Object dexPathList, ArrayList<File> files, File optimizedDirectory, ArrayList<IOException> suppressedExceptions) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
Method makeDexElements = findMethod(dexPathList, "makeDexElements", ArrayList.class, File.class, ArrayList.class);
|
||||
Method makeDexElements = Tools.findMethod(dexPathList, "makeDexElements", ArrayList.class, File.class, ArrayList.class);
|
||||
return (Object[]) makeDexElements.invoke(dexPathList, files, optimizedDirectory, suppressedExceptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates a given field anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the field into.
|
||||
* @param name field name
|
||||
* @return a field object
|
||||
* @throws NoSuchFieldException if the field cannot be located
|
||||
*/
|
||||
private static Field findField(Object instance, String name) throws NoSuchFieldException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
throw new NoSuchFieldException("Field " + name + " not found in " + instance.getClass());
|
||||
}
|
||||
/**
|
||||
* Locates a given method anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the method into.
|
||||
* @param name method name
|
||||
* @param parameterTypes method parameter types
|
||||
* @return a method object
|
||||
* @throws NoSuchMethodException if the method cannot be located
|
||||
*/
|
||||
private static Method findMethod(Object instance, String name, Class<?>... parameterTypes) throws NoSuchMethodException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Method method = clazz.getDeclaredMethod(name, parameterTypes);
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return method;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
throw new NoSuchMethodException("Method " + name + " with parameters " +
|
||||
Arrays.asList(parameterTypes) + " not found in " + instance.getClass());
|
||||
}
|
||||
/**
|
||||
* Replace the value of a field containing a non null array, by a new array containing the
|
||||
* elements of the original array plus the elements of extraElements.
|
||||
@@ -124,7 +77,7 @@ public class SecondaryDexLoader
|
||||
*/
|
||||
private static Object[] originalDex;
|
||||
private static void expandFieldArray(Object instance, String fieldName, Object[] extraElements) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
Field jlrField = findField(instance, fieldName);
|
||||
Field jlrField = Tools.findField(instance, fieldName);
|
||||
originalDex = (Object[]) jlrField.get(instance);
|
||||
Object[] combined = (Object[]) Array.newInstance(
|
||||
originalDex.getClass().getComponentType(), originalDex.length + extraElements.length);
|
||||
@@ -138,7 +91,7 @@ public class SecondaryDexLoader
|
||||
|
||||
Object instance = getDexPathList(loader);
|
||||
|
||||
Field jlrField = findField(instance, "dexElements");
|
||||
Field jlrField = Tools.findField(instance, "dexElements");
|
||||
jlrField.set(instance, originalDex);
|
||||
|
||||
originalDex = null;
|
||||
|
||||
@@ -9,18 +9,22 @@ public class ShellProcessOperation
|
||||
private Process process;
|
||||
|
||||
public ShellProcessOperation(OnPrintListener listener) throws IOException {
|
||||
this.listener = listener;
|
||||
process = Runtime.getRuntime().exec("/system/bin/sh");
|
||||
this(listener, "sh");
|
||||
}
|
||||
|
||||
public ShellProcessOperation(OnPrintListener listener, String command) throws IOException {
|
||||
this.listener = listener;
|
||||
process = Runtime.getRuntime().exec(
|
||||
command
|
||||
); //"/system/bin/sh -c \"" + command + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.redirectErrorStream(true);
|
||||
|
||||
process = builder.start();
|
||||
|
||||
//"/system/bin/sh -c \"" + command + "\"");
|
||||
}
|
||||
|
||||
public void writeToProcess(String cmd) throws IOException {
|
||||
listener.onPrintLine(" > " + cmd + "\n");
|
||||
DataOutputStream os = new DataOutputStream(process.getOutputStream());
|
||||
os.writeBytes(cmd + "\n");
|
||||
os.flush();
|
||||
|
||||
@@ -162,6 +162,37 @@ public final class Tools
|
||||
showError(ctx, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Field findField(Object instance, String name) throws NoSuchFieldException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
throw new NoSuchFieldException("Field " + name + " not found in " + instance.getClass());
|
||||
}
|
||||
|
||||
public static Method findMethod(Object instance, String name, Class<?>... parameterTypes) throws NoSuchMethodException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Method method = clazz.getDeclaredMethod(name, parameterTypes);
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return method;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
throw new NoSuchMethodException("Method " + name + " with parameters " +
|
||||
Arrays.asList(parameterTypes) + " not found in " + instance.getClass());
|
||||
}
|
||||
|
||||
public static void showError(Context ctx, Throwable e)
|
||||
{
|
||||
|
||||
@@ -7,12 +7,12 @@ public class ExitManager {
|
||||
|
||||
private static ExitTrappedListener listener;
|
||||
private static Thread exitTrappedHook = new Thread(new Runnable(){
|
||||
|
||||
private boolean isFirst = true;
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (listener != null) listener.onExitTrapped();
|
||||
|
||||
|
||||
stopLoop = false;
|
||||
|
||||
while (!stopLoop) {
|
||||
@@ -47,8 +47,11 @@ public class ExitManager {
|
||||
{
|
||||
// changeRuntimeExitDisabled(false);
|
||||
|
||||
|
||||
Runtime.getRuntime().removeShutdownHook(exitTrappedHook);
|
||||
try {
|
||||
Runtime.getRuntime().removeShutdownHook(exitTrappedHook);
|
||||
} catch (Throwable th) {
|
||||
stopExitLoop();
|
||||
}
|
||||
}
|
||||
|
||||
// It's not safe. Add/Remove shutdown hooks will cause error.
|
||||
|
||||
@@ -26,6 +26,7 @@ public class AlphaVanillaTweakInjector implements IClassTransformer {
|
||||
|
||||
public LauncherFake(Map map) {
|
||||
this.map = map;
|
||||
this.map.put("fullscreen", "true");
|
||||
}
|
||||
|
||||
public void appletResize(int width, int height) {
|
||||
|
||||
@@ -115,7 +115,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="10dp">
|
||||
android:layout_margin="10dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
Reference in new issue
Block a user