diff --git a/gradle.properties b/gradle.properties
index 82b2e5859918868330f8a5847c93fbed4ad92244..3fff6c9ba93ca369240e5d08a8f0cb2460277a43 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,6 @@
 GROUP=org.briarproject
 POM_ARTIFACT_ID=dont-kill-me-lib
-VERSION_NAME=0.2.2
+VERSION_NAME=0.2.3
 
 POM_NAME=Do not kill me library
 POM_DESCRIPTION=An Android library helping to keep a foreground service with wake-locks running. No other use-cases considered.
diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml
index c186d0bf284be39acf21c7b1ac285096800e9281..991f46dfd32f349b27a605cf7bd23f8365d47ed8 100644
--- a/lib/src/main/AndroidManifest.xml
+++ b/lib/src/main/AndroidManifest.xml
@@ -8,6 +8,7 @@
 		<package android:name="com.huawei.systemmanager" />
 		<package android:name="com.huawei.powergenie" />
 		<package android:name="com.evenwell.PowerMonitor" />
+		<package android:name="com.miui.securitycenter" />
 	</queries>
 
 </manifest>
diff --git a/lib/src/main/java/org/briarproject/android/dontkillmelib/XiaomiUtils.kt b/lib/src/main/java/org/briarproject/android/dontkillmelib/XiaomiUtils.kt
index 415b82203f7bdacaf5cb94bbead5803ac7c453b7..2b025930882f609cef68ba07c02d605ea85f2bef 100644
--- a/lib/src/main/java/org/briarproject/android/dontkillmelib/XiaomiUtils.kt
+++ b/lib/src/main/java/org/briarproject/android/dontkillmelib/XiaomiUtils.kt
@@ -1,41 +1,63 @@
 package org.briarproject.android.dontkillmelib
 
+import android.content.Context
+import android.content.Intent
+import android.content.pm.PackageManager.MATCH_DEFAULT_ONLY
 import android.os.Build.BRAND
-import java.io.IOException
-import java.util.Scanner
+import android.os.Build.VERSION.INCREMENTAL
+import android.util.Log
 
 public object XiaomiUtils {
 
+    private const val TAG = "XiaomiUtils"
+
+    private const val PACKAGE_NAME = "com.miui.securitycenter"
+    private const val CLASS_NAME = "com.miui.securityscan.ui.settings.SettingsActivity"
+
     @JvmStatic
     public val isXiaomiOrRedmiDevice: Boolean
         get() = "Xiaomi".equals(BRAND, ignoreCase = true) ||
-            "Redmi".equals(BRAND, ignoreCase = true)
+                "Redmi".equals(BRAND, ignoreCase = true)
 
     @JvmStatic
     public val isMiuiTenOrLater: Boolean
-        get() {
-            var version = getSystemProperty("ro.miui.ui.version.name")
-            if (version == null || version == "") return false
-            version = version.replace("[^\\d]".toRegex(), "")
-            return try {
-                version.toInt() >= 10
+        get() = isMiuiVersionAtLeast(10, 0)
+
+    @JvmStatic
+    public fun isMiuiVersionAtLeast(major: Int, minor: Int): Boolean {
+        // E.g. "V12.5.3.0.QFGMIXM"
+        var version = INCREMENTAL
+        Log.i(TAG, "MIUI version $version")
+        version = version.replace("[^\\d.]".toRegex(), "")
+        val parts = version.split("\\.")
+        if (parts.size >= 2) {
+            try {
+                val maj = parts[0].toInt()
+                val min = parts[1].toInt()
+                Log.i(TAG, "Parsed version $maj.$min")
+                return maj > major || (maj == major && min >= minor)
             } catch (e: NumberFormatException) {
-                false
+                // Fall through
             }
         }
+        Log.w(TAG, "Could not parse MIUI version")
+        return false
+    }
 
-    private fun getSystemProperty(propName: String): String? {
-        return try {
-            val p = Runtime.getRuntime().exec("getprop $propName")
-            val s = Scanner(p.inputStream)
-            val line = s.nextLine()
-            s.close()
-            line
-        } catch (e: SecurityException) {
-            null
-        } catch (e: IOException) {
-            null
-        }
+    @JvmStatic
+    public val xiaomiRecentAppsNeedsToBeShown: Boolean
+        get() = isXiaomiOrRedmiDevice && !isMiuiVersionAtLeast(12, 5)
+
+    @JvmStatic
+    public fun xiaomiLockAppsNeedsToBeShown(context: Context): Boolean {
+        if (!isXiaomiOrRedmiDevice || !isMiuiVersionAtLeast(12, 5)) return false
+        val pm = context.packageManager
+        val resolveInfos = pm.queryIntentActivities(xiaomiLockAppsIntent, MATCH_DEFAULT_ONLY)
+        return resolveInfos.isNotEmpty()
     }
 
+    @JvmStatic
+    public val xiaomiLockAppsIntent: Intent = Intent().apply {
+        setClassName(PACKAGE_NAME, CLASS_NAME)
+    }
 }
diff --git a/lib/src/main/res/values/strings.xml b/lib/src/main/res/values/strings.xml
index ce4fe3f42cecdb47feedd26566da9cd15ba504e9..bbb1b6f9e6b2da5ef61180403f2685c249f9d7a7 100644
--- a/lib/src/main/res/values/strings.xml
+++ b/lib/src/main/res/values/strings.xml
@@ -18,7 +18,12 @@
     <string name="dnkm_xiaomi_button">Lock to recent apps</string>
     <string name="dnkm_xiaomi_help">If this app is not locked to the recent apps list, it will be unable to run in the background.</string>
     <string name="dnkm_xiaomi_dialog_body_old">1. Open the recent apps list (also called the app switcher)\n\n2. Swipe down on the image of this app to show the padlock icon\n\n3. If the padlock is not locked, tap to lock it</string>
-    <string name="dnkm_xiaomi_dialog_body_new">1. Open the recent apps list (also called the app switcher)\n\n2. Press and hold the image of this app until the padlock button appears\n\n3. If the padlock is not locked, tap to lock it</string>
+    <string name="dnkm_xiaomi_dialog_body_new">1. Open the recent apps list (also called the app switcher)\n\n2. If this app has a small image of a padlock next to its name then you don\'t need to do anything\n\n3. If there\'s no padlock, press and hold the image of this app until the padlock button appears, then tap it</string>
+
+    <string name="dnkm_xiaomi_lock_apps_text">Please tap the button below to open the security settings. Tap \"Boost speed\", then tap \"Lock apps\", and make sure this app is set to \"Locked\".</string>
+    <string name="dnkm_xiaomi_lock_apps_button">Open Security Settings</string>
+    <string name="dnkm_xiaomi_lock_apps_help">If this app is not set to \"Locked\" in the \"Lock apps\" screen, it will be unable to run in the background.</string>
+    <string name="dnkm_xiaomi_lock_apps_error_toast">Could not open security settings</string>
 
     <string name="dnkm_got_it">Got it</string>
     <string name="dnkm_help">Help</string>