From 90f9eccb64d0d6be441409548abbae372c5d4692 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Mon, 25 Mar 2019 19:24:52 +0100 Subject: [PATCH] Add Constants#isRunningOnEmulator --- .../nutomic/syncthingandroid/service/Constants.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java b/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java index ee3c403a..ff975e67 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/Constants.java @@ -3,6 +3,7 @@ package com.nutomic.syncthingandroid.service; import android.content.Context; import android.os.Build; import android.os.Environment; +import android.text.TextUtils; import java.io.File; import java.util.concurrent.TimeUnit; @@ -190,6 +191,16 @@ public class Constants { return new File(context.getExternalFilesDir(null), "syncthing.log"); } + /** + * Checks if the app is running on an Android emulator (AVD). + */ + public static Boolean isRunningOnEmulator() { + return !TextUtils.isEmpty(Build.MANUFACTURER) && + !TextUtils.isEmpty(Build.MODEL) && + Build.MANUFACTURER.equals("Google") && + Build.MODEL.equals("Android SDK built for x86"); + } + /** * Decide if we should enforce HTTPS when accessing the Web UI and REST API. * Android 4.4 and earlier don't have support for TLS 1.2 requiring us to