Skip to content

Commit

Permalink
emulator enhances host recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
yang.bai committed May 29, 2024
1 parent 02f6e96 commit 4bd9568
Showing 1 changed file with 55 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,63 +41,66 @@ class EmulatorCollector : EmulatorInterface {
"x8.prop",
"/system/lib/libc_malloc_debug_qemu.so"
)

private fun checkDevice(): Boolean = "nox" == Build.DEVICE
|| "vbox86p" == Build.DEVICE
|| "vbox86tp" == Build.DEVICE
|| "appplayer" == Build.DEVICE
|| "droid4x" == Build.DEVICE
|| "vbox" == Build.DEVICE
|| "virtual" == Build.DEVICE
|| "andywin" == Build.DEVICE
|| "andyosx" == Build.DEVICE
|| "generic" == Build.DEVICE
|| "generic_x86" == Build.DEVICE
|| "emu64a" == Build.DEVICE
|| Build.DEVICE.lowercase(Locale.getDefault()).contains("mumu")
|| Build.DEVICE.lowercase(Locale.getDefault()).contains("zerofltezc")
|| "vbox86p" == Build.DEVICE
|| "vbox86tp" == Build.DEVICE
|| "appplayer" == Build.DEVICE
|| "droid4x" == Build.DEVICE
|| "vbox" == Build.DEVICE
|| "virtual" == Build.DEVICE
|| "andywin" == Build.DEVICE
|| "andyosx" == Build.DEVICE
|| "generic" == Build.DEVICE
|| "generic_x86" == Build.DEVICE
|| "emu64a" == Build.DEVICE
|| Build.DEVICE.lowercase(Locale.getDefault()).contains("mumu")
|| Build.DEVICE.lowercase(Locale.getDefault()).contains("zerofltezc")

private fun checkModel(): Boolean = "vmos" == Build.MODEL
|| "duos" == Build.MODEL
|| "amiduos" == Build.MODEL
|| "noxw" == Build.MODEL
|| "genymotion" == Build.MODEL
|| "bluestacks" == Build.MODEL
|| "tiantian" == Build.MODEL
|| "windroy" == Build.MODEL
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.lowercase(Locale.getDefault()).contains("droid4x")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MODEL.contains("Subsystem for Android(TM)")
|| "duos" == Build.MODEL
|| "amiduos" == Build.MODEL
|| "noxw" == Build.MODEL
|| "genymotion" == Build.MODEL
|| "bluestacks" == Build.MODEL
|| "tiantian" == Build.MODEL
|| "windroy" == Build.MODEL
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.lowercase(Locale.getDefault()).contains("droid4x")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MODEL.contains("Subsystem for Android(TM)")

private fun checkFingerprint(): Boolean = Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.contains("vbox")
private fun checkFingerprint(): Boolean = Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.contains("vbox")

private fun checkProduct(): Boolean = "sdk" == Build.PRODUCT
|| "google_sdk" == Build.PRODUCT
|| "sdk_x86" == Build.PRODUCT
|| "vbox86p" == Build.PRODUCT
|| "vbox86tp" == Build.PRODUCT
|| "genymotion" == Build.PRODUCT
|| "bluestacks" == Build.PRODUCT
|| "droid4x" == Build.PRODUCT
|| "ttvm_hdragon" == Build.PRODUCT
|| "duos_native" == Build.PRODUCT
|| "duos" == Build.PRODUCT
|| "vbox" == Build.PRODUCT
|| "android_x86" == Build.PRODUCT
|| Build.PRODUCT.lowercase(Locale.getDefault()).contains("nox")
private fun checkProduct(): Boolean = "sdk" == Build.PRODUCT
|| "google_sdk" == Build.PRODUCT
|| "sdk_x86" == Build.PRODUCT
|| "vbox86p" == Build.PRODUCT
|| "vbox86tp" == Build.PRODUCT
|| "genymotion" == Build.PRODUCT
|| "bluestacks" == Build.PRODUCT
|| "droid4x" == Build.PRODUCT
|| "ttvm_hdragon" == Build.PRODUCT
|| "duos_native" == Build.PRODUCT
|| "duos" == Build.PRODUCT
|| "vbox" == Build.PRODUCT
|| "android_x86" == Build.PRODUCT
|| Build.PRODUCT.lowercase(Locale.getDefault()).contains("nox")

private fun checkHardware(): Boolean = "goldfish" == Build.HARDWARE
|| "vbox86" == Build.HARDWARE

private fun checkOtherBuildInfo(): Boolean = Build.MANUFACTURER.contains("Genymotion")
|| Build.BOARD.lowercase(Locale.getDefault()).contains("nox")
|| Build.BOOTLOADER.lowercase(Locale.getDefault()).contains("nox")
|| Build.HARDWARE.lowercase(Locale.getDefault()).contains("nox")
|| Build.SERIAL.lowercase(Locale.getDefault()).contains("nox")
|| Build.HOST.lowercase(Locale.getDefault()).startsWith("bliss-os")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| Build.BOARD.lowercase(Locale.getDefault()).contains("nox")
|| Build.BOOTLOADER.lowercase(Locale.getDefault()).contains("nox")
|| Build.HARDWARE.lowercase(Locale.getDefault()).contains("nox")
|| Build.SERIAL.lowercase(Locale.getDefault()).contains("nox")
|| Build.HOST.lowercase(Locale.getDefault()).startsWith("bliss-os")
|| Build.HOST.lowercase(Locale.getDefault()).contentEquals("G1-SNIPER-B7")
|| Build.HOST.lowercase(Locale.getDefault()).contentEquals("Build2")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))

override fun detectEmulator(): Boolean {
var isEmulator = checkBuildInfo()
Expand All @@ -109,11 +112,11 @@ class EmulatorCollector : EmulatorInterface {

private fun checkBuildInfo(): Boolean =
checkDevice() ||
checkModel() ||
checkFingerprint() ||
checkProduct() ||
checkHardware() ||
checkOtherBuildInfo()
checkModel() ||
checkFingerprint() ||
checkProduct() ||
checkHardware() ||
checkOtherBuildInfo()

private fun checkFiles(): Boolean {
for (filePtah in QEMU_FILES) {
Expand Down

0 comments on commit 4bd9568

Please sign in to comment.