Skip to content

Commit

Permalink
Fixed: ANR when the program doesn't collect events, bug where only on…
Browse files Browse the repository at this point in the history
…e task would be launched for all programs.
  • Loading branch information
tareksander committed Nov 8, 2021
1 parent 331c784 commit 507e1bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdk 24
targetSdk 31
versionCode 2
versionName "1.1"
versionName "0.1.1"

}
signingConfigs {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/termux/gui/ConnectionHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ConnectionHandler(private val request: GUIService.ConnectionRequest, servi
private var activityID = 0
private val app: Context = service.applicationContext
private val rand = Random()
var eventQueue = LinkedBlockingQueue<String>()
var eventQueue = LinkedBlockingQueue<String>(10000)
var eventWorker: Thread? = null

data class SharedBuffer(val btm: Bitmap, val shm: SharedMemory, val buff: ByteBuffer)
Expand All @@ -79,7 +79,6 @@ class ConnectionHandler(private val request: GUIService.ConnectionRequest, servi
//println("ptid: $ptid")
val i = Intent(app, GUIActivity::class.java)
if (ptid == null) {
println("new task")
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_ACTIVITY_NEW_DOCUMENT
}
val aid = Thread.currentThread().id.toString()+"-"+activityID.toString()
Expand Down Expand Up @@ -120,7 +119,6 @@ class ConnectionHandler(private val request: GUIService.ConnectionRequest, servi
if (task == null) {
return gson.toJson(arrayOf("-1",-1))
}
println("stated in task")
task.startActivity(app, i, null)
}
while (true) {
Expand Down Expand Up @@ -346,7 +344,9 @@ class ConnectionHandler(private val request: GUIService.ConnectionRequest, servi
eventWorker = Thread {
val eventOut = DataOutputStream(event.outputStream)
while (! Thread.currentThread().isInterrupted) {
sendMessage(eventOut, eventQueue.take())
try {
sendMessage(eventOut, eventQueue.take())
} catch (ignored: Exception) {}
}
}
eventWorker!!.start()
Expand Down

0 comments on commit 507e1bb

Please sign in to comment.