From c8b54ba315faec26d323a1e062bb2d1bab1d1fd8 Mon Sep 17 00:00:00 2001 From: oxmc Date: Tue, 9 Sep 2025 05:33:48 -0700 Subject: [PATCH] Add core/java/pawletos/device/PawletSystem.java --- core/java/pawletos/device/PawletSystem.java | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 core/java/pawletos/device/PawletSystem.java diff --git a/core/java/pawletos/device/PawletSystem.java b/core/java/pawletos/device/PawletSystem.java new file mode 100644 index 0000000..dfe396d --- /dev/null +++ b/core/java/pawletos/device/PawletSystem.java @@ -0,0 +1,79 @@ +package pawletos.device.system; + +import android.content.Context; +import android.os.Build; +import android.os.SystemProperties; + +/** + * PawletOS System API for system apps (OTA, device management, etc.) + */ +public class PawletSystem { + private static final double PAWLET_SDK_VERSION = 1.0; + + /** + * Check if running on an emulator. + */ + public static boolean isEmulator() { + String fingerprint = Build.FINGERPRINT; + String model = Build.MODEL; + String manufacturer = Build.MANUFACTURER; + String brand = Build.BRAND; + String device = Build.DEVICE; + String product = Build.PRODUCT; + return fingerprint != null && (fingerprint.startsWith("generic") || fingerprint.startsWith("unknown")) + || model != null && model.contains("google_sdk") + || model != null && model.contains("Emulator") + || model != null && model.contains("Android SDK built for x86") + || manufacturer != null && manufacturer.contains("Genymotion") + || brand != null && brand.startsWith("generic") && device != null && device.startsWith("generic") + || product != null && product.equals("google_sdk"); + } + + /** + * Basic check if device is rooted. + */ + public static boolean isRooted() { + String buildTags = Build.TAGS; + if (buildTags != null && buildTags.contains("test-keys")) { + return true; + } + try { + java.io.File file = new java.io.File("/system/app/Superuser.apk"); + if (file.exists()) { + return true; + } + } catch (Exception e) { + // ignore + } + return false; + } + + /** + * Get the current language/locale. + */ + public static String getCurrentLocale(Context ctx) { + java.util.Locale locale; + if (android.os.Build.VERSION.SDK_INT >= 24) { + locale = ctx.getResources().getConfiguration().getLocales().get(0); + } else { + locale = ctx.getResources().getConfiguration().locale; + } + return locale.toString(); + } + + /** + * Check if device is running PawletOS. + * Returns true if running on PawletOS, false otherwise. + */ + public static boolean isPawletOS() { + return "Pawlet".equalsIgnoreCase(Build.MANUFACTURER) + || "PawletOS".equalsIgnoreCase(SystemProperties.get("ro.oxmc.os_name", "")); + } + + /** + * Get the PawletSDK version. + */ + public static double getPawletSDKVersion() { + return PAWLET_SDK_VERSION; + } +} \ No newline at end of file