Skip to content

Commit

Permalink
fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 2, 2024
1 parent ff33893 commit 1a638af
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
12 changes: 9 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,26 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<!--<category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter>
</activity>
<activity
android:name=".Simulator"
android:exported="false"
android:exported="true"
android:process=":simulator"
android:taskAffinity=""
android:noHistory="true"
android:screenOrientation="nosensor"
android:excludeFromRecents="true"
android:configChanges="keyboard|keyboardHidden|uiMode"
android:theme="@style/Simulator"
tools:ignore="DiscouragedApi" />
tools:ignore="DiscouragedApi">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
2 changes: 1 addition & 1 deletion app/src/main/cpp/droidboot_gui
37 changes: 35 additions & 2 deletions app/src/main/java/org/andbootmgr/app/Simulator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}

0 comments on commit 1a638af

Please sign in to comment.