Skip to content

Commit b71dba8

Browse files
committed
#1965 disable miui_optimisation when system bridge starts
1 parent 4668058 commit b71dba8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sysbridge/src/main/java/io/github/sds100/keymapper/sysbridge/manager/SystemBridgeConnectionManager.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class SystemBridgeConnectionManagerImpl @Inject constructor(
5555

5656
companion object {
5757
private const val TAG = "SystemBridgeConnectionManagerImpl"
58+
private const val MIUI_OPTIMIZATION_SETTING = "miui_optimization"
5859
}
5960

6061
private val systemBridgeLock: Any = Any()
@@ -66,7 +67,7 @@ class SystemBridgeConnectionManagerImpl @Inject constructor(
6667
time = SystemClock.elapsedRealtime(),
6768
// Get whether the user previously stopped the system bridge.
6869
isStoppedByUser =
69-
preferences.get(Keys.isSystemBridgeStoppedByUser).firstBlocking() ?: false,
70+
preferences.get(Keys.isSystemBridgeStoppedByUser).firstBlocking() ?: false,
7071
),
7172
)
7273
private var isExpectedDeath: Boolean = false
@@ -241,6 +242,13 @@ class SystemBridgeConnectionManagerImpl @Inject constructor(
241242
1,
242243
)
243244
}
245+
246+
val isMiuiOptimisationEnabled =
247+
SettingsUtils.getGlobalSetting<Int>(ctx, MIUI_OPTIMIZATION_SETTING) == 1
248+
249+
if (isWriteSecureSettingsGranted && isMiuiOptimisationEnabled) {
250+
SettingsUtils.putGlobalSetting(ctx, MIUI_OPTIMIZATION_SETTING, 0)
251+
}
244252
}
245253

246254
private fun grantWriteSecureSettings(systemBridge: ISystemBridge) {

0 commit comments

Comments
 (0)