Skip to content

Commit

Permalink
simulator mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 1, 2024
1 parent f65b73d commit 7337642
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/src/main/cpp/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#include <jni.h>

extern "C" void simulator_start(JNIEnv* env, jobject bitmap, jint w, jint h);
extern "C" void simulator_stop();
extern "C" void simulator_stop(JNIEnv* env);
extern "C" void simulator_key(jint key);

extern "C" JNIEXPORT void JNICALL Java_org_andbootmgr_app_Simulator_key(JNIEnv* env, jobject thiz, jint key) {
simulator_key(key);
}

extern "C" JNIEXPORT void JNICALL Java_org_andbootmgr_app_Simulator_stop(JNIEnv* env, jobject thiz) {
simulator_stop();
simulator_stop(env);
}

extern "C" JNIEXPORT void JNICALL Java_org_andbootmgr_app_Simulator_start(JNIEnv* env, jobject thiz, jobject bitmap, jint w, jint h) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/droidboot_gui
26 changes: 24 additions & 2 deletions app/src/main/java/org/andbootmgr/app/Simulator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ package org.andbootmgr.app
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import kotlin.math.min


class Simulator : AppCompatActivity() {
init {
Log.i("Simulator","going to load library")
System.loadLibrary("app")
}
external fun start(bitmap: Bitmap, w: Int, h: Int)
Expand All @@ -22,13 +28,29 @@ class Simulator : AppCompatActivity() {
w = 1080
h = 1920
bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
setContentView(object : View(this) {
val l = LinearLayout(this)
l.addView(object : View(this) {
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
canvas.drawBitmap(this@Simulator.bitmap, 0f, 0f, null)
invalidate() //TODO
}

override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
setMeasuredDimension(when (MeasureSpec.getMode(widthMeasureSpec)) {
MeasureSpec.EXACTLY -> MeasureSpec.getSize(widthMeasureSpec)
MeasureSpec.AT_MOST -> min(Int.MAX_VALUE, MeasureSpec.getSize(widthMeasureSpec))
else -> Int.MAX_VALUE
}, when (MeasureSpec.getMode(heightMeasureSpec)) {
MeasureSpec.EXACTLY -> MeasureSpec.getSize(heightMeasureSpec)
MeasureSpec.AT_MOST -> min(Int.MAX_VALUE, MeasureSpec.getSize(heightMeasureSpec))
else -> Int.MAX_VALUE
})
}
})
}, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
setContentView(l)
Thread {
Log.i("Simulator","going to call start()")
start(bitmap, w, h)
}.run {
name = "droidboot0"
Expand Down

0 comments on commit 7337642

Please sign in to comment.