ufukhawk / safe_device

MIT License
47 stars 43 forks source link

All Android Sony is considered Emulator (Not real device) #49

Closed tulioccalazans closed 2 weeks ago

tulioccalazans commented 4 months ago

Hi,

The Sony XQ-CC72 device is being considered as an Emulator by the library (verson 1.1.7).

Below are more details about the device:

Android Sony XQ-CC72 Dalvik/2.1.0 (Linux; U; Android 14; XQ-CC72 Build/65.2.A.2.137)

Is there any problem with safe_device package?

tulioccalazans commented 4 months ago

Same issue for:

Android Sony XQ-DC72 Dalvik/2.1.0 (Linux; U; Android 14; XQ-DC72 Build/68.1.A.2.187)

tulioccalazans commented 4 months ago

It seems to be general for any Sony device. Another device with the same issue:

Android Sony SO-01M Dalvik/2.1.0 (Linux; U; Android 11; SO-01M Build/55.2.D.3.22)

venCjin commented 4 months ago

I can confirm it also happens for Sony XQ-DC54 after updating this app https://play.google.com/store/apps/details?id=com.sonymobile.support (system app I guess).

I will provide more info once I get this phone to me and I will debug what gives false-positive result.

tulioccalazans commented 4 months ago

More info about the device with false-positive:

image

This info is generated by:

"Android ${ai.manufacturer} | ${ai.model} | ${ai.brand} | ${ai.fingerprint} | ${ai.hardware} | ${ai.product} | ${ai.board} | ${ai.host} | ${ai.device}"

tulioccalazans commented 4 months ago

I can confirm it also happens for Sony XQ-DC54 after updating this app https://play.google.com/store/apps/details?id=com.sonymobile.support (system app I guess).

I will provide more info once I get this phone to me and I will debug what gives false-positive result.

Hi @venCjin Were you able to check?

tulioccalazans commented 4 months ago

I checked isEmulator method and I found the point:

public static boolean isEmulator() { return Build.FINGERPRINT.startsWith("generic") || Build.FINGERPRINT.startsWith("unknown") || Build.MODEL.contains("google_sdk") || Build.MODEL.contains("Emulator") || Build.MODEL.contains("Android SDK built for x86") || Build.MANUFACTURER.contains("Genymotion") || Build.MODEL.startsWith("sdk_") || Build.DEVICE.startsWith("emulator") || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) || "google_sdk".equals(Build.PRODUCT) //bluestacks || "QC_Reference_Phone" == Build.BOARD && !"xiaomi".equalsIgnoreCase(Build.MANUFACTURER) //bluestacks || Build.MANUFACTURER.contains("Genymotion") || Build.HOST.startsWith("Build") //MSI App Player || Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic") || Build.PRODUCT == "google_sdk" // another Android SDK emulator check || SystemProperties.get("ro.kernel.qemu") == "1" || Build.HARDWARE.contains("goldfish") || Build.HARDWARE.contains("ranchu") || Build.PRODUCT.contains("vbox86p") || Build.PRODUCT.toLowerCase().contains("nox") || Build.BOARD.toLowerCase().contains("nox") || Build.HARDWARE.toLowerCase().contains("nox") || Build.MODEL.toLowerCase().contains("droid4x") || Build.HARDWARE == "vbox86" || checkEmulatorFiles() ; }

HERE:

|| Build.HOST.startsWith("Build")

"Host" in sony device is "BuildHost"

This seems to be the problem for the devices I listed.

tulioccalazans commented 4 months ago

I confirmed with my app user. Commenting on the line below, his Sony device stopped being identified as an emulator.

//|| Build.HOST.startsWith("Build")

@venCjin if you want use it in your project, I created a fork commenting this line. But know that I removed the whole checking part related to MockLocations too, as this part is also causing problems to my app and I don't need it (com.xamdesign.safe_device.MockLocation is causing ANR).

https://github.com/tulioccalazans/safe_device/tree/dev

If you want to use it in your project, use it this way:

  safe_device:
    git:
      url: https://github.com/tulioccalazans/safe_device.git
      ref: dev
venCjin commented 3 months ago

Hi, sorry for late response. I debugged and can confirm what @tulioccalazans found, that on Sony devices Build.HOST is set to "BuildHost" and therefore gives false-positive result.

I would suggest to make there additional check to exclude sony devices like this: || (Build.HOST.startsWith("Build") && !Build.MANUFACTURER.equalsIgnoreCase("sony")) as this type of exclude check is for "xiaomi" already || "QC_Reference_Phone" == Build.BOARD && !"xiaomi".equalsIgnoreCase(Build.MANUFACTURER) and with that in mind I created PR #51

venCjin commented 3 months ago

@tulioccalazans Thank you a lot for fork and for info how to reference it in pubspec. For now I am staying on 1.1.4 version, but I will keep in mind your fork ♥️

thanhnt-mdev commented 1 month ago

It should be resolved asap since many user might be impacted. We even didn't know about the issue since there is no test devices.

lamltf commented 3 weeks ago

Are there any updates yet? Now i have bug with Sony: XQ-BT52 😭

ufukhawk commented 2 weeks ago

safe_device: ^1.1.8