diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..340fa46
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gen-manifest.sh b/gen-manifest.sh
new file mode 100644
index 0000000..eee3f84
--- /dev/null
+++ b/gen-manifest.sh
@@ -0,0 +1 @@
+i=2;while [ $i -le 32 ]; do echo '';i=$(($i+1));done
\ No newline at end of file
diff --git a/src/common/overlay.java b/src/common/overlay.java
new file mode 100644
index 0000000..49db090
--- /dev/null
+++ b/src/common/overlay.java
@@ -0,0 +1,196 @@
+package common;
+import android.content.*;
+import android.graphics.*;
+import android.view.*;
+import android.app.*;
+import android.util.Log;
+import android.os.Handler;
+
+public class overlay {
+ private static final String T = "virgl-java";
+ private static native void nativeRun(int fd);
+ private static native int nativeAccept(int fd);
+ private static native int nativeOpen();
+ private static native int nativeInit(String settings)
+ private static native void nativeUnlink();
+ private static Handler handler;
+ private static Context ctx;
+ private static WindowManager wm;
+
+ private static void start_next(int svc_id)
+ {
+ java.util.List services =
+ ((ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE)).
+ getRunningServices(Integer.MAX_VALUE);
+ for(int i = 1; i < 32; i++)
+ {
+ boolean free = true;
+
+ if( i == svc_id )
+ continue;
+ for(ActivityManager.RunningServiceInfo s :services)
+ {
+
+ if(s.service.getClassName().equals("process.p"+i))
+ {
+ free = false;
+ break;
+ }
+ }
+ if(free)
+ {
+ Log.d(T,"starting instance "+i);
+ ctx.startService( new Intent().setClassName(ctx, "process.p"+i));
+ return;
+ }
+ }
+ }
+
+ private static void run_mt()
+ {
+
+ new Thread(){
+ @Override
+ public void run()
+ {
+ int sock = nativeOpen();
+ int fd;
+ while((fd = nativeAccept(sock)) >= 0)
+ {
+ final int fd1 = fd;
+ Thread t = new Thread(){
+ @Override
+ public void run()
+ {
+ nativeRun(fd1);
+ }
+ };
+ t.start();
+ }
+ }
+ }.start();
+ }
+ private static void run_mp(final int svc_id)
+ {
+ new Thread()
+ {
+ public void run()
+ {
+ int fd = nativeOpen();
+ fd = nativeAccept(fd);
+ nativeUnlink();
+ start_next(svc_id);
+ nativeRun(fd);
+ ctx.stopService( new Intent().setClassName(ctx, "process.p"+svc_id));
+ }
+ }.start();
+ }
+
+ public static void start(Context ctx1, int svc_id)
+ {
+ ctx = ctx1;
+ wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
+ byte[] settings = new byte[65];
+ System.loadLibrary("vtest");
+ int thread_mode = nativeInit(ctx.getFilesDir().getPath()+"/settings");
+ handler = new Handler();
+ if( thread_mode == 1 )
+ run_mt();
+ else
+ run_mp(svc_id);
+ }
+
+ private static SurfaceView create(final int x, final int y, final int width, final int height) {
+ //resize(x,y,width, height);
+ final Thread t = Thread.currentThread();
+ final SurfaceView surf[] = new SurfaceView[1];
+ try
+ {
+ Log.d(T, "post");
+
+ handler.postDelayed(new Runnable(){
+ public void run()
+ {
+ surf[0] = new SurfaceView(ctx);
+ WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.OPAQUE);
+ params.gravity = Gravity.LEFT | Gravity.TOP;
+ params.x = x;
+ params.y = y;
+ params.width = width;
+ params.height = height;
+ if( (width == 0) || (height == 0) )
+ {
+ params.width = params.height = 32;
+ }
+ wm.addView(surf[0], params);
+ Log.d(T, "notify");
+ synchronized(t)
+ {
+ t.notify();
+ }
+ }
+ },100);
+ synchronized(t)
+ {
+ t.wait();
+ t.sleep(1000);
+ }
+ Log.d(T, "resume");
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+
+ Log.d(T, "int");
+ //return null;
+ }
+ return surf[0];
+ }
+
+ private static void set_rect(final SurfaceView surface, final int x, final int y, final int width, final int height, final int visible)
+ {
+
+ Log.d(T,"resize " + x + " " + y + " " + width );
+ handler.post(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ WindowManager.LayoutParams params = (WindowManager.LayoutParams)surface.getLayoutParams();
+
+ if( params == null )
+ return;
+ if( visible != 0 )
+ {
+ params.x = x;
+ params.y = y;
+ params.width = width;
+ params.height = height;
+ }
+ else
+ {
+ params.x = params.y = -33;
+ params.width = params.height = 32;
+ }
+ wm.updateViewLayout(surface, params);
+ }
+ catch(Exception e)
+ {}
+ }
+ });
+ }
+
+ public static void destroy(final SurfaceView surface) {
+ handler.post(new Runnable(){
+ public void run()
+ {
+ wm.removeView(surface);
+ }
+ });
+ }
+ public static Surface get_surface(SurfaceView surf)
+ {
+ return surf.getHolder().getSurface();
+ }
+}
diff --git a/src/gen-process.sh b/src/gen-process.sh
new file mode 100644
index 0000000..4fcc7d2
--- /dev/null
+++ b/src/gen-process.sh
@@ -0,0 +1 @@
+i=2;while [ $i -le 32 ]; do sed -e s/1/$i/ process/p1.java > process/p$i.java;i=$(($i+1));done
diff --git a/src/process/p1.java b/src/process/p1.java
new file mode 100644
index 0000000..326a4be
--- /dev/null
+++ b/src/process/p1.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p1 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,1);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p10.java b/src/process/p10.java
new file mode 100644
index 0000000..5abf96c
--- /dev/null
+++ b/src/process/p10.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p10 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,10);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p11.java b/src/process/p11.java
new file mode 100644
index 0000000..976fc8c
--- /dev/null
+++ b/src/process/p11.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p11 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,11);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p12.java b/src/process/p12.java
new file mode 100644
index 0000000..543171e
--- /dev/null
+++ b/src/process/p12.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p12 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,12);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p13.java b/src/process/p13.java
new file mode 100644
index 0000000..73d2503
--- /dev/null
+++ b/src/process/p13.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p13 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,13);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p14.java b/src/process/p14.java
new file mode 100644
index 0000000..beb4278
--- /dev/null
+++ b/src/process/p14.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p14 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,14);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p15.java b/src/process/p15.java
new file mode 100644
index 0000000..0a510ba
--- /dev/null
+++ b/src/process/p15.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p15 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,15);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p16.java b/src/process/p16.java
new file mode 100644
index 0000000..9e26bf8
--- /dev/null
+++ b/src/process/p16.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p16 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,16);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p17.java b/src/process/p17.java
new file mode 100644
index 0000000..04903f5
--- /dev/null
+++ b/src/process/p17.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p17 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,17);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p18.java b/src/process/p18.java
new file mode 100644
index 0000000..41666c1
--- /dev/null
+++ b/src/process/p18.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p18 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,18);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p19.java b/src/process/p19.java
new file mode 100644
index 0000000..0f4f737
--- /dev/null
+++ b/src/process/p19.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p19 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,19);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p2.java b/src/process/p2.java
new file mode 100644
index 0000000..ca1fc13
--- /dev/null
+++ b/src/process/p2.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p2 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,2);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p20.java b/src/process/p20.java
new file mode 100644
index 0000000..3dfd273
--- /dev/null
+++ b/src/process/p20.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p20 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,20);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p21.java b/src/process/p21.java
new file mode 100644
index 0000000..32c43b1
--- /dev/null
+++ b/src/process/p21.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p21 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,21);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p22.java b/src/process/p22.java
new file mode 100644
index 0000000..fa9c252
--- /dev/null
+++ b/src/process/p22.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p22 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,22);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p23.java b/src/process/p23.java
new file mode 100644
index 0000000..2e86d0d
--- /dev/null
+++ b/src/process/p23.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p23 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,23);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p24.java b/src/process/p24.java
new file mode 100644
index 0000000..093d379
--- /dev/null
+++ b/src/process/p24.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p24 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,24);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p25.java b/src/process/p25.java
new file mode 100644
index 0000000..c9b4e08
--- /dev/null
+++ b/src/process/p25.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p25 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,25);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p26.java b/src/process/p26.java
new file mode 100644
index 0000000..cf3ed68
--- /dev/null
+++ b/src/process/p26.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p26 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,26);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p27.java b/src/process/p27.java
new file mode 100644
index 0000000..8a31f45
--- /dev/null
+++ b/src/process/p27.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p27 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,27);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p28.java b/src/process/p28.java
new file mode 100644
index 0000000..1d87537
--- /dev/null
+++ b/src/process/p28.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p28 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,28);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p29.java b/src/process/p29.java
new file mode 100644
index 0000000..2f9275a
--- /dev/null
+++ b/src/process/p29.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p29 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,29);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p3.java b/src/process/p3.java
new file mode 100644
index 0000000..ba52424
--- /dev/null
+++ b/src/process/p3.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p3 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,3);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p30.java b/src/process/p30.java
new file mode 100644
index 0000000..f936a61
--- /dev/null
+++ b/src/process/p30.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p30 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,30);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p31.java b/src/process/p31.java
new file mode 100644
index 0000000..5b6901d
--- /dev/null
+++ b/src/process/p31.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p31 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,31);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p32.java b/src/process/p32.java
new file mode 100644
index 0000000..7ee33a7
--- /dev/null
+++ b/src/process/p32.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p32 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,32);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p4.java b/src/process/p4.java
new file mode 100644
index 0000000..474c672
--- /dev/null
+++ b/src/process/p4.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p4 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,4);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p5.java b/src/process/p5.java
new file mode 100644
index 0000000..b17b86b
--- /dev/null
+++ b/src/process/p5.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p5 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,5);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p6.java b/src/process/p6.java
new file mode 100644
index 0000000..42d4fe1
--- /dev/null
+++ b/src/process/p6.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p6 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,6);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p7.java b/src/process/p7.java
new file mode 100644
index 0000000..c1d4240
--- /dev/null
+++ b/src/process/p7.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p7 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,7);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p8.java b/src/process/p8.java
new file mode 100644
index 0000000..ea65fd1
--- /dev/null
+++ b/src/process/p8.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p8 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,8);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/process/p9.java b/src/process/p9.java
new file mode 100644
index 0000000..e330c8c
--- /dev/null
+++ b/src/process/p9.java
@@ -0,0 +1,19 @@
+package process;
+
+public class p9 extends android.app.Service
+{
+ @Override
+ public android.os.IBinder onBind(android.content.Intent intent) {
+ return null;
+ }
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ common.overlay.start(this,9);
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0);
+ }
+}
diff --git a/src/settings/activity.java b/src/settings/activity.java
new file mode 100644
index 0000000..07cb16e
--- /dev/null
+++ b/src/settings/activity.java
@@ -0,0 +1,260 @@
+package settings;
+
+import android.app.*;
+import android.os.*;
+import android.view.*;
+import android.widget.*;
+import android.widget.RelativeLayout.*;
+import android.content.*;
+import android.text.*;
+import android.text.style.*;
+import android.graphics.*;
+import java.awt.font.*;
+import android.widget.GridLayout.*;
+import java.io.*;
+import android.util.*;
+import java.nio.*;
+
+public class activity extends Activity
+{
+ public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
+ public static final String T = "virgl-activity";
+ ;public static final int FL_RING = (1<<0);
+ //#define FL_GLX (1<<1)
+ public static final int FL_GLES = (1<<2);
+ //#define FL_OVERLAY (1<<3)
+ public static final int FL_MULTITHREAD = (1<<4);
+
+ public SpannableString style_button_string(String str)
+ {
+ if(sdk < 21)
+ str = str.toUpperCase();
+
+ SpannableString span_string = new SpannableString(str.toUpperCase());
+
+ if(sdk < 21)
+ span_string.setSpan(new StyleSpan(Typeface.BOLD), 0, str.length(), 0);
+
+ span_string.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, str.length(), 0);
+
+ return span_string;
+ }
+
+ private EditText add_edit(LinearLayout layout, String title)
+ {
+ LinearLayout.LayoutParams edit_params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ edit_params.setMargins(10,20,10,20);//размеры строки для ввода аргументов
+
+ TextView title_view = new TextView(this);
+ title_view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ title_view.setText(title);
+ title_view.setTextAppearance(this, android.R.attr.textAppearanceLarge);
+
+ EditText edit = new EditText(this);
+ edit.setLayoutParams(edit_params);
+ edit.setSingleLine(true);
+ if(sdk < 21)
+ {
+ edit.setBackgroundColor(0xFF353535);
+ edit.setTextColor(0xFFFFFFFF);
+ edit.setPadding(5,5,5,5);
+ }
+
+ layout.addView(title_view);
+ layout.addView(edit);
+ return edit;
+ }
+ private Button add_button(LinearLayout panel,String title, View.OnClickListener listener)
+ {
+ Button startButton = new Button(this);
+
+ // Set launch button title here
+ startButton.setText(style_button_string(title));
+ //startButton.setTextAlignment()
+ LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ //buttonParams.addRule(Layout.ALIGN_PARENT_BOTTOM);
+ buttonParams.weight = 1;
+ startButton.setGravity(Gravity.BOTTOM);
+ startButton.setLayoutParams(buttonParams);
+ if(sdk < 21)
+ {
+ startButton.getBackground().setAlpha(96);
+ startButton.getBackground().invalidateSelf();
+ startButton.setTextColor(0xFFFFFFFF);
+ startButton.setTextAppearance(this, android.R.attr.textAppearanceLarge);
+ startButton.setTextSize(20);
+ }
+ startButton.setOnClickListener(listener);
+
+ // Add other options here
+
+ panel.addView(startButton);
+ return startButton;
+ }
+ private CheckBox add_checkbox(LinearLayout layout, String title)
+ {
+ CheckBox cb = new CheckBox(this);
+ cb.setText(title);
+ layout.addView(cb);
+ return cb;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.requestWindowFeature(Window.FEATURE_NO_TITLE);
+
+ // set theme
+ if ( sdk >= 21 )
+ super.setTheme( 0x01030224 );
+ else
+ super.setTheme( 0x01030005 );
+
+ // Build layout
+ RelativeLayout launcher = new RelativeLayout(this);
+ // launcher.setOrientation(LinearLayout.VERTICAL);
+ // launcher.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+
+ launcher.setBackgroundColor(0xFF252525);
+ TextView launcherTitle = new TextView(this);
+ LayoutParams titleparams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ titleparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ titleparams.setMargins(5,15,5,1);//размеры верхнего layout
+ //titleparams.weight = 1;
+ launcherTitle.setLayoutParams(titleparams);
+ launcherTitle.setText("virgl renderer");
+ launcherTitle.setTextColor(0xFF4db017);
+ launcherTitle.setTextAppearance(this, android.R.attr.textAppearanceMedium);
+ launcherTitle.setTextSize(25);
+ launcherTitle.setBackgroundColor(0xFF555555);
+ launcherTitle.setCompoundDrawablePadding(10);
+ try
+ {
+ launcherTitle.setCompoundDrawablesWithIntrinsicBounds(getApplicationContext().getPackageManager().getApplicationIcon(getPackageName()),null,null,null);
+ launcherTitle.setPadding(9,9,6,0);
+ }
+ catch(Exception e)
+ {
+ launcherTitle.setPadding(60,6,6,6);
+ }
+ launcher.addView(launcherTitle);
+ LinearLayout launcherBody = new LinearLayout(this);
+ launcherBody.setOrientation(LinearLayout.VERTICAL);
+ ScrollView.LayoutParams bp = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+ bp.setMargins(10,15,10,10);//размеры верхнего layout
+
+ launcherBody.setLayoutParams(bp);
+ launcherBody.setPadding(10,0,10,30);
+ launcherBody.setBackgroundColor(0xFF454545);
+ LinearLayout launcherBorder = new LinearLayout(this);
+ RelativeLayout.LayoutParams params_ = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.MATCH_PARENT);
+
+ LinearLayout panel = new LinearLayout(this);
+ panel.setId(1000);
+ launcherTitle.setId(1001);
+ params_.addRule(RelativeLayout.BELOW, launcherTitle.getId());
+ params_.setMargins(5,15,5,1);//размеры верхнего layout
+
+ params_.addRule(RelativeLayout.ABOVE, panel.getId());
+ launcherBorder.setLayoutParams(params_);
+ launcherBorder.setBackgroundColor(0xFF555555);
+ launcherBorder.setOrientation(LinearLayout.VERTICAL);
+
+ ScrollView launcherBorder2 = new ScrollView(this);
+ LinearLayout.LayoutParams sp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+ sp.setMargins(5,15,5,10);//размеры верхнего layout
+
+ launcherBorder2.setLayoutParams(sp);
+ //launcherBorder2.setOrientation(LinearLayout.VERTICAL);
+ launcherBorder2.setBackgroundColor(0xFF353535);
+ launcherBorder2.addView(launcherBody);
+ launcherBorder2.setPadding(10,0,10,10);
+ launcherBorder.addView(launcherBorder2);
+ launcherBorder.setPadding(10,0,10,20);
+ launcher.addView(launcherBorder);
+
+ final EditText socket_path = add_edit(launcherBody, "Socket path (/tmp/.virgl_test)");
+ final EditText ring_path = add_edit(launcherBody, "Ring buffer path (/dev/shm)");
+ final CheckBox use_ring = add_checkbox(launcherBody, "Use ring buffer instead of socket");
+ final CheckBox use_gles = add_checkbox(launcherBody, "Use GL ES 3.x instead of OpenGL");
+ final CheckBox use_threads = add_checkbox(launcherBody, "Use multi-thread egl access");
+ int flags = 0;
+ try
+ {
+ //char[] buffer = new char[64];
+ CharBuffer buffer = CharBuffer.allocate(128);
+ FileReader settings_reader = new FileReader(getFilesDir().getPath()+"/settings");
+ //int len = settings_reader.read(buffer);
+ //buffer.notifyAll()
+ //buffer.
+ BufferedReader reader = new BufferedReader(settings_reader);
+ //reader.readLine()
+ //CharBuffer buf = CharBuffer.allocate(settings_reader.read(buffer));
+ //buffer.read(buf);
+ //StringReader reader = new StringReader(settings_reader);
+ String[] parts = reader.readLine().split(" ");
+ //Log.d(T,"read:"+Integer.valueOf(parts[0]) + ", " + parts[1] + ", " + parts[2]);
+ flags = Integer.valueOf(parts[0]);
+ socket_path.setText(parts[1]);
+ ring_path.setText(parts[2]);
+ reader.close();
+ settings_reader.close();
+ }
+ catch(Exception e){}
+ use_ring.setChecked((flags & FL_RING) != 0);
+ use_gles.setChecked((flags & FL_GLES) != 0);
+ use_threads.setChecked((flags & FL_MULTITHREAD) != 0);
+ panel.setOrientation(LinearLayout.HORIZONTAL);
+ add_button(panel,"Clean services", new View.OnClickListener(){@Override public void onClick(View v){
+ for(int i = 1; i < 32; i++)
+ {
+ try{
+ stopService( new Intent().setClassName(activity.this, "process.p"+i));
+ }
+ catch(Exception e){}
+ }
+ }});
+ add_button(panel,"Start service", new View.OnClickListener(){@Override public void onClick(View v){
+ try{
+ int flags = 0;
+ if(use_ring.isChecked())
+ flags |= FL_RING;
+ if(use_gles.isChecked())
+ flags |= FL_GLES;
+ if(use_threads.isChecked())
+ flags |= FL_MULTITHREAD;
+
+ FileWriter writer = new FileWriter(getFilesDir().getPath()+"/settings");
+ writer.write(String.valueOf(flags));
+ writer.write(' ');
+ writer.write(socket_path.getText().toString());
+ writer.write(' ');
+ writer.write(ring_path.getText().toString());
+ writer.close();
+ startService( new Intent().setClassName(activity.this, "process.p1"));
+ }
+ catch(Exception e)
+ {}
+ }});
+ //panel.setWeightSum(2);
+ RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ //params.weight = 1;
+ //params.alignWithParent = true;
+ params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+
+ panel.setLayoutParams(params);//
+ //panel.setGravity(Gravity.BOTTOM);
+ //RelativeLayout.ALIGN_PARENT_BOTTOM;
+
+ launcher.addView(panel);
+ //launcher.setWeightSum(5000000);
+ setContentView(launcher);
+ //mPref = getSharedPreferences("mod", 0);
+ //socket_path.setText(mPref.getString("argv","-dev 3 -log"));
+
+ // Uncomment this if you have pak file
+ // ExtractAssets.extractPAK(this, false);
+ }
+
+
+}