Skip to content

rizalrinoldi/cordova-plugin-emulator-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Emulator Detector Plugin

A Cordova plugin that provides robust detection of Android emulators, including popular ones like BlueStacks, NOX, Andy, and standard Android emulators.

Features

  • Comprehensive emulator detection using multiple verification methods
  • Detects popular Android emulators:
    • BlueStacks
    • NOX
    • Android Studio Emulator
    • Genymotion
    • Andy
    • Other QEMU-based emulators
  • No special permissions required
  • Lightweight and easy to use
  • Promise-based API

Installation

cordova plugin add cordova-plugin-emulator-detector

Or install directly from GitHub:

cordova plugin add https://github.com/rizalrinoldi/cordova-plugin-emulator-detector.git

Usage

Basic Usage

EmulatorDetector.isEmulator(
    function(isEmulator) {
        if (isEmulator === 1) {
            console.log("Running on emulator");
        } else {
            console.log("Running on real device");
        }
    },
    function(error) {
        console.error("Error detecting device type:", error);
    }
);

With Promises

// Using Promise wrapper
function checkEmulator() {
    return new Promise((resolve, reject) => {
        EmulatorDetector.isEmulator(
            isEmulator => resolve(isEmulator === 1),
            error => reject(error)
        );
    });
}

// Usage with async/await
async function checkDevice() {
    try {
        const isEmulator = await checkEmulator();
        if (isEmulator) {
            console.log("This is an emulator");
        } else {
            console.log("This is a real device");
        }
    } catch (error) {
        console.error("Error checking device:", error);
    }
}

Detection Methods

The plugin uses multiple detection methods to ensure accuracy:

  1. Basic Properties Detection

    • Build.FINGERPRINT
    • Build.MODEL
    • Build.MANUFACTURER
    • Build.BRAND
    • Build.DEVICE
    • Build.PRODUCT
    • Build.HARDWARE
    • Build.BOOTLOADER
  2. Advanced Emulator Properties

    • Specific manufacturer checks
    • Model name verification
    • Product name analysis
  3. File System Checks

    • Emulator-specific libraries
    • System binaries
    • QEMU-related files
  4. Package Detection

    • Checks for installed emulator packages
    • Verifies emulator-related services
  5. QEMU Detection

    • CPU information analysis
    • Hardware configuration checks
  6. Hardware Configuration

    • System property verification
    • Hardware type analysis

Supported Platforms

  • Android

Requirements

  • Cordova 9.0.0 or higher
  • Android API 19 or higher

Known Limitations

  • Only works on Android devices
  • Some newer or heavily modified emulators might not be detected
  • Detection methods may need updates as emulator technology evolves

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Clone the repository
git clone https://github.com/rizalrinoldi/cordova-plugin-emulator-detector.git
  1. Install dependencies
npm install
  1. Test the plugin
npm test

License

MIT License

Support

For bugs, feature requests, or questions, please create an issue.

Changelog

1.0.0 (2024-11-07)

  • Initial release
  • Added comprehensive emulator detection
  • Support for major Android emulators
  • Basic and advanced detection methods
  • File system and package checks

Authors

  • Rizal

Acknowledgments

  • Android Open Source Project
  • Cordova community
  • Contributors to similar emulator detection projects

FAQ

Q: Why isn't the emulator being detected?

A: Some emulators use sophisticated methods to hide their presence. If you encounter an undetected emulator, please create an issue with the emulator details.

Q: Does this plugin affect app performance?

A: The plugin performs checks only when explicitly called and has minimal impact on performance.

Q: Can this be bypassed?

A: Like any detection method, it's possible for sophisticated users to bypass these checks. This plugin is meant for general use cases and basic security measures.

Q: Will this work on iOS?

A: Currently, this plugin only supports Android devices. iOS support may be added in future versions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published