Last active
February 10, 2026 02:15
-
-
Save starry-shivam/901267c26eb030eb3faf1ccd4d2bdd32 to your computer and use it in GitHub Desktop.
Revisions
-
starry-shivam revised this gist
May 24, 2024 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,9 @@ object MiuiCheck { * @return True if the device is running on MIUI, false otherwise */ fun isMiui(excludeHyperOS: Boolean = true): Boolean { // Check if the device is manufactured by Xiaomi, Redmi, or POCO. val brand = Build.BRAND.lowercase() if (!setOf("xiaomi", "redmi", "poco").contains(brand)) return false // This property is present in both MIUI and HyperOS. val isMiui = !getProperty("ro.miui.ui.version.name").isNullOrBlank() // This property is exclusive to HyperOS only and isn't present in MIUI. -
starry-shivam created this gist
May 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ object MiuiCheck { /** * Check if the device is running on MIUI. * * By default, HyperOS is excluded from the check. * If you want to include HyperOS in the check, set excludeHyperOS to false. * * @param excludeHyperOS Whether to exclude HyperOS * @return True if the device is running on MIUI, false otherwise */ fun isMiui(excludeHyperOS: Boolean = true): Boolean { // This property is present in both MIUI and HyperOS. val isMiui = !getProperty("ro.miui.ui.version.name").isNullOrBlank() // This property is exclusive to HyperOS only and isn't present in MIUI. val isHyperOS = !getProperty("ro.mi.os.version.name").isNullOrBlank() return isMiui && (!excludeHyperOS || !isHyperOS) } // Private function to get the property value from build.prop. private fun getProperty(property: String): String? { return try { Runtime.getRuntime().exec("getprop $property").inputStream.use { input -> BufferedReader(InputStreamReader(input), 1024).readLine() } } catch (e: IOException) { e.printStackTrace() null } } }