apache / cordova-plugin-device

Apache Cordova Device Plugin
https://cordova.apache.org/
Apache License 2.0
386 stars 430 forks source link

(android): device.isVirtual return false on simulator #134

Open atefeh-akheraty opened 3 years ago

atefeh-akheraty commented 3 years ago

Bug Report

device.isVirtual return false on bluestack and nox player.

It is expected to return true. but it returns false on both.

device version is 2.0.2

timbru31 commented 3 years ago

I thinks this one will be tricky, as NoxPlayer and BlueStacks try their best to hide that they are actually not a real Android device (I mean, that's their purpose...)

atefeh-akheraty commented 3 years ago

thanks for reply. I want to prevent users from screen record of my application. On real device I do it by some plugin, but on simulator it not working. Also users that launche app on simulator can record their screen. So I need to detect device is running on real device or not.

breautek commented 3 years ago

I'd fork the plugin and play with the isVirtual() method: https://github.com/apache/cordova-plugin-device/blob/4c18d1f2b70606b9311ed20c234b560b49107b28/src/android/Device.java#L169-L172

And try to determine if there are any hints that you're within a bluestacks simulator or a nox player emulator in android.os.Build.FINGERPRINT or android.os.Build.PRODUCT.

timbru31 commented 3 years ago

A quick Google search gave me two results:

breautek commented 3 years ago

The SafetyNet API requires a self-managed backend service, so that would have to be an opt-in feature, probably best as an independent plugin. See the SafetyNet overview

But the answer posted at https://stackoverflow.com/a/49445230/1902598 could definitely be something incorporated in this plugin I think.

atefeh-akheraty commented 3 years ago

I used this library: "https://github.com/framgia/android-emulator-detector". but it does not work correctly. also does not work. So I use this code: if( Build.CPU_ABI.contains("x86") && arch.contains("i686")){ finish(); }

But the problem is on ASUS device that has intel cpu, it does not work.

ForamRaiyani commented 2 years ago

Did any one found any solution? I'm also getting device.isVirtual return false on nox emulator. Please help