Skip to content

Commit

Permalink
MCinaBox Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
longjunyu2 committed Mar 30, 2020
1 parent f97e2b6 commit f7ca946
Show file tree
Hide file tree
Showing 221 changed files with 2,076 additions and 2,807 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion boat3/build.gradle → boat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions boat/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cosine.boat">
</manifest>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cosine.boat2;
package cosine.boat;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.concurrent.BlockingDeque;
Expand All @@ -11,31 +11,31 @@
import java.io.OutputStream;

public class BoatInputEventSender{

public static final int KeyPress = 2;
public static final int KeyRelease = 3;
public static final int ButtonPress = 4;
public static final int ButtonRelease = 5;
public static final int MotionNotify = 6;

private static final int MESSAGE_SIZE = 10;
private static final int CACHE_SIZE = 8 * MESSAGE_SIZE;
private Deque<byte[]> cachedObjs = new ArrayDeque<byte[]>(CACHE_SIZE);
private BlockingDeque<byte[]> deque = new LinkedBlockingDeque<byte[]>();
public ServerSocket serverSock;
public Socket sock;
private static final int CACHE_SIZE = 8 * MESSAGE_SIZE;


private Deque<byte[]> cachedObjs = new ArrayDeque<byte[]>(CACHE_SIZE);
private BlockingDeque<byte[]> deque = new LinkedBlockingDeque<byte[]>();

public ServerSocket serverSock;
public Socket sock;

private OutputStream os;
private InputStream is;
public int port;
public boolean receiving;
public boolean running;

private BoatClientActivity activity;
public void startServer(BoatClientActivity a){
public void startServer(BoatClientActivity a){
activity = a;
running = true;
try{
Expand All @@ -45,12 +45,12 @@ public void startServer(BoatClientActivity a){
new Thread(new Receiver()).start();
port = this.serverSock.getLocalPort();
System.out.println("BoatInputEventSender is created!The port is:" + port);

}
catch (IOException e){
e.printStackTrace();
}
}
}

private class Receiver implements Runnable
{
Expand All @@ -60,30 +60,30 @@ public void run()
{
// TODO: Implement this method
try {

while(!receiving){

}
byte[] msg = new byte[1];

while (running) {

is.read(msg, 0, 1);

activity.changeGrab(msg[0]);

}

} catch (Exception e) {
e.printStackTrace();
}


}


}

private class Sender implements Runnable
{

Expand All @@ -108,54 +108,64 @@ public void run()
}
System.out.println("Exiting input event sender");
}


}


private byte[] obtain() {
byte[] msg = this.cachedObjs.poll();
if (msg == null) {
return new byte[MESSAGE_SIZE];
}
return msg;
}

private void recycle(byte[] msg) {
if (this.cachedObjs.size() < CACHE_SIZE) {
this.cachedObjs.add(msg);
}
}
private byte[] obtain() {
byte[] msg = this.cachedObjs.poll();
if (msg == null) {
return new byte[MESSAGE_SIZE];
}
return msg;
}

private void recycle(byte[] msg) {
if (this.cachedObjs.size() < CACHE_SIZE) {
this.cachedObjs.add(msg);
}
}




public static void writeInt(byte[] src, int offset, int i) {
src[0 + offset] = (byte)( i >> (0 * 8));
src[1 + offset] = (byte)( i >> (1 * 8));
src[2 + offset] = (byte)( i >> (2 * 8));
src[3 + offset] = (byte)( i >> (3 * 8));
}


public void setMouseButton(byte button, boolean press) {
byte[] msg = obtain();
byte[] msg = obtain();
msg[0] = (byte) (press ? ButtonPress : ButtonRelease);
msg[1] = button;
this.deque.add(msg);
}
msg[1] = button;
this.deque.add(msg);
}
public void setPointer(int x, int y) {
byte[] msg = obtain();
byte[] msg = obtain();
msg[0] = (byte) (MotionNotify);
writeInt(msg, 2, x);
writeInt(msg, 2, x);
writeInt(msg, 6, y);
this.deque.add(msg);
}
this.deque.add(msg);
}
public void setKey(int keyCode, boolean press , int keyChar){
//处理鼠标按钮
if(keyCode == 1001){
setMouseButton((byte)1,press);
return;
}else if(keyCode == 1002){
setMouseButton((byte)2,press);
return;
}


byte[] msg = obtain();
msg[0] = (byte) (press ? KeyPress : KeyRelease);
writeInt(msg, 2, keyCode);
writeInt(msg, 6, keyChar);
this.deque.add(msg);
this.deque.add(msg);
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cosine.boat2;
package cosine.boat;

import android.app.Activity;
import android.os.Bundle;
import com.aof.sharedmodule.Model.ArgsModel;
import cosine.boat2.logcat.Logcat;
import cosine.boat2.logcat.LogcatService;
import cosine.boat.logcat.Logcat;
import cosine.boat.logcat.LogcatService;
import ru.ivanarh.jndcrash.NDCrashError;
import ru.ivanarh.jndcrash.NDCrash;
import ru.ivanarh.jndcrash.NDCrashService;
Expand All @@ -22,8 +22,11 @@ public void onCreate(Bundle savedInstance) {
argsModel = (ArgsModel) getIntent().getSerializableExtra("LauncherConfig");

//初始化日志
//【release版暂时不开启】
/*
final String logPath = BOAT_HOME + "/log.txt";
Logcat.initializeOutOfProcess(this, logPath, LogcatService.class);
*/

final String reportPath = BOAT_HOME + "/crash.txt";
System.out.println("Crash report: " + reportPath);
Expand All @@ -43,6 +46,7 @@ public void onCreate(Bundle savedInstance) {
Intent intent = new Intent(this, BoatClientActivity.class);
intent.putExtra("LauncherConfig", argsModel);
this.startActivity(intent);
this.finish();

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package cosine.boat2;
package cosine.boat;

import com.aof.sharedmodule.Model.ArgsModel;
import static com.aof.sharedmodule.Data.DataPathManifest.*;

public class LoadMe {
public static native int chdir(String str);
public static native void jliLaunch(String[] strArr);
public static native void redirectStdio(String file);
public static native void setenv(String str, String str2);

public static native int chdir(String str);
public static native void jliLaunch(String[] strArr);
public static native void redirectStdio(String file);
public static native void setenv(String str, String str2);
public static native void setupJLI();
public static native int dlopen(String name);
static {
System.loadLibrary("boat");
}
public static int exec(ArgsModel args, BoatClientActivity activity) {
try {

static {
System.loadLibrary("boat");
}

public static int exec(ArgsModel args, BoatClientActivity activity) {
try {
String runtimePath = RUNTIME_HOME;
String home = args.getHome();

setenv("HOME", home);
setenv("JAVA_HOME" ,runtimePath + "/j2re-image");
setenv("BOAT_INPUT_PORT", Integer.toString(activity.mInputEventSender.port));

dlopen(runtimePath + "/j2re-image/lib/aarch32/jli/libjli.so");
dlopen(runtimePath + "/j2re-image/lib/aarch32/client/libjvm.so");
dlopen(runtimePath + "/j2re-image/lib/aarch32/libverify.so");
Expand All @@ -33,20 +33,20 @@ public static int exec(ArgsModel args, BoatClientActivity activity) {
dlopen(runtimePath + "/j2re-image/lib/aarch32/libnio.so");
dlopen(runtimePath + "/j2re-image/lib/aarch32/libawt.so");
dlopen(runtimePath + "/j2re-image/lib/aarch32/libawt_headless.so");
dlopen("libserver2.so");
dlopen("libserver.so");
dlopen(runtimePath + "/libopenal.so.1");
dlopen(runtimePath + "/libGL.so.1");
dlopen(runtimePath + "/lwjgl2/liblwjgl.so");

setupJLI();
redirectStdio(home + "/boat_output.txt");
chdir(home);
jliLaunch(args.getArgs());
redirectStdio(home + "/boat_output.txt");
chdir(home);
jliLaunch(args.getArgs());

} catch (Exception e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
return 0;
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cosine.boat;
package cosine.boat.version3;

import android.app.Application;
import android.app.Activity;
Expand Down
Loading

0 comments on commit f7ca946

Please sign in to comment.