From 532bb3027fd4e7467ee932c2a974a7e5804789cc Mon Sep 17 00:00:00 2001 From: Wook Song Date: Tue, 28 May 2024 08:37:08 +0900 Subject: [PATCH] App/Service: Introduce the isRunningOnEmulator property This patch introduces a property to check that the app is running on the Android Emulator. Signed-off-by: Wook Song --- .../ml/inference/offloading/MainService.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ml_inference_offloading/src/main/java/ai/nnstreamer/ml/inference/offloading/MainService.kt b/ml_inference_offloading/src/main/java/ai/nnstreamer/ml/inference/offloading/MainService.kt index 5dd1d48..ef8fe78 100644 --- a/ml_inference_offloading/src/main/java/ai/nnstreamer/ml/inference/offloading/MainService.kt +++ b/ml_inference_offloading/src/main/java/ai/nnstreamer/ml/inference/offloading/MainService.kt @@ -9,6 +9,7 @@ import android.content.pm.PackageManager import android.content.pm.ServiceInfo import android.net.ConnectivityManager import android.os.Binder +import android.os.Build import android.os.Handler import android.os.HandlerThread import android.os.IBinder @@ -53,6 +54,27 @@ class MainService : Service() { private val TAG = "MainService" private val binder = LocalBinder() + private val isRunningOnEmulator: Boolean + get() = (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) + || Build.FINGERPRINT.startsWith("generic") + || Build.FINGERPRINT.startsWith("unknown") + || Build.HARDWARE.contains("goldfish") + || Build.HARDWARE.contains("ranchu") + || Build.MODEL.contains("google_sdk") + || Build.MODEL.contains("Emulator") + || Build.MODEL.contains("Android SDK built for x86") + || Build.MANUFACTURER.contains("Genymotion") + || Build.PRODUCT.contains("sdk_google") + || Build.PRODUCT.contains("google_sdk") + || Build.PRODUCT.contains("sdk") + || Build.PRODUCT.contains("sdk_x86") + || Build.PRODUCT.contains("sdk_gphone64_arm64") + || Build.PRODUCT.contains("vbox86p") + || Build.PRODUCT.contains("emulator") + || Build.PRODUCT.contains("simulator") + || Build.PRODUCT == "sdk_gphone64_arm64" + || Build.FINGERPRINT == "robolectric" + || Build.MANUFACTURER.contains("Geny") private lateinit var serviceHandler : MainHandler private lateinit var serviceLooper : Looper private lateinit var handlerThread: HandlerThread