Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/src/main/java/com/castla/mirror/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,19 @@ class MainActivity : AppCompatActivity() {
}

private fun refreshHotspotStatus() {
if (!shizukuSetup.serviceConnected.value) {
// Check hotspot status without requiring Shizuku by inspecting network interfaces directly
try {
val hotspotNames = listOf("swlan0", "wlan1", "ap0", "softap0")
val interfaces = java.net.NetworkInterface.getNetworkInterfaces()?.toList() ?: emptyList()
val active = interfaces.any { iface ->
iface.isUp && hotspotNames.any { name -> iface.name.contains(name) }
}
isHotspotActive = active
Log.d(TAG, "refreshHotspotStatus: active=$active (interfaces=${interfaces.map { it.name }})")
} catch (e: Exception) {
Log.w(TAG, "refreshHotspotStatus failed", e)
isHotspotActive = false
return
}
isHotspotActive = findHotspotInterface() != null
}

private fun toggleHotspot() {
Expand Down Expand Up @@ -920,6 +928,7 @@ class MainActivity : AppCompatActivity() {
val alreadyActive = findHotspotInterface() != null
if (alreadyActive) {
Log.i(TAG, "Hotspot already active — skipping enableHotspot, starting service directly")
isHotspotActive = true
launchMirrorService(resultCode, data)
} else {
Toast.makeText(this, getString(R.string.toast_hotspot_enabling), Toast.LENGTH_SHORT).show()
Expand All @@ -929,6 +938,7 @@ class MainActivity : AppCompatActivity() {
runOnUiThread {
if (success) {
Toast.makeText(this@MainActivity, getString(R.string.toast_hotspot_enabled), Toast.LENGTH_SHORT).show()
isHotspotActive = true
} else {
Toast.makeText(this@MainActivity, getString(R.string.toast_hotspot_failed), Toast.LENGTH_SHORT).show()
}
Expand Down