Skip to content

Commit 57b9edb

Browse files
committed
#1898 do not launch directly into the Wireless Debugging activity on Xiaomi devices due to a bug they introduced.
1 parent 8ab3f6f commit 57b9edb

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Bug fixes
1313

1414
- #1901 prompt user to set default USB configuration to 'No data transfer' after starting pro mode.
15+
- #1898 do not launch directly into the Wireless Debugging activity on Xiaomi devices due to a bug they introduced.
1516

1617
## [4.0.0 Beta 2](https://github.com/sds100/KeyMapper/releases/tag/v4.0.0-beta.02)
1718

base/src/main/java/io/github/sds100/keymapper/base/promode/SystemBridgeSetupUseCase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import io.github.sds100.keymapper.system.permissions.Permission
2121
import io.github.sds100.keymapper.system.permissions.PermissionAdapter
2222
import io.github.sds100.keymapper.system.root.SuAdapter
2323
import io.github.sds100.keymapper.system.shizuku.ShizukuAdapter
24+
import javax.inject.Inject
2425
import kotlinx.coroutines.Dispatchers
2526
import kotlinx.coroutines.ExperimentalCoroutinesApi
2627
import kotlinx.coroutines.flow.Flow
@@ -30,7 +31,6 @@ import kotlinx.coroutines.flow.flatMapLatest
3031
import kotlinx.coroutines.flow.flowOf
3132
import kotlinx.coroutines.flow.flowOn
3233
import kotlinx.coroutines.flow.map
33-
import javax.inject.Inject
3434

3535
@RequiresApi(Constants.SYSTEM_BRIDGE_MIN_API)
3636
@ViewModelScoped

sysbridge/src/main/java/io/github/sds100/keymapper/sysbridge/service/SystemBridgeSetupController.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ class SystemBridgeSetupControllerImpl @Inject constructor(
255255
* false then developer options was launched.
256256
*/
257257
private fun launchWirelessDebuggingActivity(): Boolean {
258+
// See issue #1898. Xiaomi like to do dodgy stuff, which causes a crash
259+
// when long pressing the quick settings tile for wireless debugging.
260+
if (Build.BRAND in setOf("xiaomi", "redmi", "poco")) {
261+
highlightDeveloperOptionsWirelessDebuggingOption()
262+
return false
263+
}
264+
258265
val quickSettingsIntent = Intent(TileService.ACTION_QS_TILE_PREFERENCES).apply {
259266
// Set the package name because this action can also resolve to a "Permission Controller" activity.
260267
val packageName = "com.android.settings"
@@ -280,16 +287,20 @@ class SystemBridgeSetupControllerImpl @Inject constructor(
280287
ctx.startActivity(quickSettingsIntent)
281288
return true
282289
} catch (_: ActivityNotFoundException) {
283-
SettingsUtils.launchSettingsScreen(
284-
ctx,
285-
Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS,
286-
"toggle_adb_wireless",
287-
)
290+
highlightDeveloperOptionsWirelessDebuggingOption()
288291

289292
return false
290293
}
291294
}
292295

296+
private fun highlightDeveloperOptionsWirelessDebuggingOption() {
297+
SettingsUtils.launchSettingsScreen(
298+
ctx,
299+
Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS,
300+
"toggle_adb_wireless",
301+
)
302+
}
303+
293304
fun invalidateSettings() {
294305
isDeveloperOptionsEnabled.update { getDeveloperOptionsEnabled() }
295306
isWirelessDebuggingEnabled.update { getWirelessDebuggingEnabled() }

0 commit comments

Comments
 (0)