Skip to content

Commit

Permalink
Fix Services Killing (Now really mountmgr don't bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
KreitinnSoftware committed Dec 31, 2024
1 parent 86b7b72 commit bf93dc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/src/main/java/com/micewine/emu/activities/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,17 @@ class MainActivity : AppCompatActivity() {
runCommand("pkill -9 wineserver")
runCommand("pkill -9 .exe")
runCommand(getEnv() + "$usrDir/bin/pulseaudio --start --exit-idle=-1")
WineWrapper.wine("wineboot", winePrefix)

var wineRunning = true
if (!enableServices) {
lifecycleScope.launch {
val processName = if (exePath == "") "TFM.exe" else File(exePath).name

// Wait for Wine Successfully Start and Execute Specified Program and Kill Services
while (!WineWrapper.wine("tasklist", winePrefix, true).contains(processName)) {
delay(100)
}

lifecycleScope.launch {
while (!enableServices && wineRunning) {
runCommand("pkill -9 services.exe", false)
delay(1200)
}
}

Expand Down Expand Up @@ -667,8 +670,6 @@ class MainActivity : AppCompatActivity() {
runCommand("pkill -9 wineserver")
runCommand("pkill -9 .exe")

wineRunning = false

runOnUiThread {
Toast.makeText(this@MainActivity, getString(R.string.wine_is_closed), Toast.LENGTH_SHORT).show()
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/micewine/emu/core/WineWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.micewine.emu.core
import android.os.Build
import com.micewine.emu.core.EnvVars.getEnv
import com.micewine.emu.core.ShellLoader.runCommand
import com.micewine.emu.core.ShellLoader.runCommandWithOutput
import java.io.File

object WineWrapper {
Expand All @@ -20,6 +21,15 @@ object WineWrapper {
)
}

fun wine(args: String, winePrefix: File, retLog: Boolean): String {
if (retLog) {
return runCommandWithOutput(
getEnv() + "WINEPREFIX=$winePrefix $IS_BOX64 wine $args"
)
}
return ""
}

fun wine(args: String, winePrefix: File, cwd: String) {
runCommand(
"cd $cwd;" +
Expand Down

0 comments on commit bf93dc6

Please sign in to comment.