From 1a638af2431f4f6c344f1f981f75f662d4592822 Mon Sep 17 00:00:00 2001 From: nift4 Date: Fri, 2 Aug 2024 12:11:25 +0200 Subject: [PATCH] fixing bugs --- app/src/main/AndroidManifest.xml | 12 ++++-- app/src/main/cpp/droidboot_gui | 2 +- .../main/java/org/andbootmgr/app/Simulator.kt | 37 ++++++++++++++++++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aac16948..64c7cde4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,12 +29,12 @@ - + + tools:ignore="DiscouragedApi"> + + + + + + \ No newline at end of file diff --git a/app/src/main/cpp/droidboot_gui b/app/src/main/cpp/droidboot_gui index 606653b5..3ff4da12 160000 --- a/app/src/main/cpp/droidboot_gui +++ b/app/src/main/cpp/droidboot_gui @@ -1 +1 @@ -Subproject commit 606653b50dd2f77340c827aa7d1791c0fa48ecb6 +Subproject commit 3ff4da129c22e2d0f437732c9a432be8721f5844 diff --git a/app/src/main/java/org/andbootmgr/app/Simulator.kt b/app/src/main/java/org/andbootmgr/app/Simulator.kt index cdaf397d..2717dad8 100644 --- a/app/src/main/java/org/andbootmgr/app/Simulator.kt +++ b/app/src/main/java/org/andbootmgr/app/Simulator.kt @@ -10,6 +10,8 @@ import android.os.Handler import android.os.IBinder import android.os.Looper import android.util.Log +import android.view.KeyEvent +import android.view.MotionEvent import android.view.View import android.widget.LinearLayout import android.widget.Toast @@ -18,6 +20,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import com.topjohnwu.superuser.Shell +import com.topjohnwu.superuser.io.SuRandomAccessFile import com.topjohnwu.superuser.ipc.RootService import com.topjohnwu.superuser.nio.FileSystemManager import org.andbootmgr.app.util.RootFsService @@ -27,6 +30,7 @@ import java.nio.channels.FileChannel import kotlin.math.min import kotlin.system.exitProcess + class Simulator : AppCompatActivity() { init { Log.i("Simulator","going to load library") @@ -56,8 +60,8 @@ class Simulator : AppCompatActivity() { w = 1080 //TODO make size fullscreen and hide sysui h = 1920 bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888) - f = File(intent.getStringExtra("sdCardBlock")!!) - // TODO make keys work + //f = File(intent.getStringExtra("sdCardBlock")!!) + f = File("/dev/block/mmcblk1") val intent = Intent(this, RootFsService::class.java) val l = LinearLayout(this) v = object : View(this) { @@ -143,4 +147,33 @@ class Simulator : AppCompatActivity() { // droidboot cannot cope with starting twice in same process due to static variables exitProcess(0) } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + Log.i("Simulator", "key down: $keyCode") + key(if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) 1 else 2) + true + } else { + super.onKeyDown(keyCode, event) + } + } + + override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + Log.i("Simulator", "key up: $keyCode") + key(if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) 8 else 16) + true + } else { + super.onKeyUp(keyCode, event) + } + } + + override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { + when (ev?.action) { + MotionEvent.ACTION_UP -> key(32) + MotionEvent.ACTION_DOWN -> key(4) + else -> return false + } + return true + } } \ No newline at end of file