From 752e05ce4cf16074ffec422bd27b611fe5e1292b Mon Sep 17 00:00:00 2001 From: oxmc <67136658+oxmc@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:34:17 -0700 Subject: [PATCH] Change a few things --- Android.bp | 5 +- .../java/pawletos/device/OxmcEnvironment.java | 65 ---------- core/java/pawletos/device/PawletDevice.java | 118 ++++++++++++++++++ 3 files changed, 121 insertions(+), 67 deletions(-) delete mode 100644 core/java/pawletos/device/OxmcEnvironment.java create mode 100644 core/java/pawletos/device/PawletDevice.java diff --git a/Android.bp b/Android.bp index 333755e..e2cde07 100644 --- a/Android.bp +++ b/Android.bp @@ -1,9 +1,10 @@ -java_library { +java_sdk_library { name: "pawlet-device", srcs: ["core/java/**/*.java"], + api_packages: ["pawletos.device"], libs: ["core-libart"], sdk_version: "current", installable: true, product_specific: true, - visibility: ["//packages/apps/..."], + visibility: ["//packages/apps/..."] } \ No newline at end of file diff --git a/core/java/pawletos/device/OxmcEnvironment.java b/core/java/pawletos/device/OxmcEnvironment.java deleted file mode 100644 index 9fb4ed7..0000000 --- a/core/java/pawletos/device/OxmcEnvironment.java +++ /dev/null @@ -1,65 +0,0 @@ -package pawletos.device; - -import android.content.Context; -import android.os.Build; -import android.os.SystemProperties; - -/** - * PawletOS Environment API for apps running on PawletOS builds. - */ -public class OxmcEnvironment { - private static final String OXMC_OS_NAME = "PawletOS"; - private static final int OXMC_OS_VERSION = 16; - - /** - * Check if device is running PawletOS. - */ - public static boolean isPawletOS() { - return "PawletOS".equalsIgnoreCase(Build.MANUFACTURER) - || "PawletOS".equalsIgnoreCase(OXMC_OS_NAME); - } - - /** - * Get the PawletOS version. - */ - public static int getPawletVersion() { - return OXMC_OS_VERSION; - } - - /** - * Get a welcome message from framework resources. - */ - public static String getWelcomeMessage(Context ctx) { - return ctx.getString(android.R.string.oxmc_device_message); - } - - /** - * Get the brand name. - */ - public static String getBrandName(Context ctx) { - return ctx.getString(android.R.string.oxmc_brand_name); - } - - /** - * Get the codename (e.g., PV16). - */ - public static String getCodename(Context ctx) { - return ctx.getString(android.R.string.oxmc_codename); - } - - // ───────────────────────────── - // Custom build property access - // ───────────────────────────── - - public static String getManufactureDate() { - return SystemProperties.get("ro.oxmc.build.manufacture_date", "unknown"); - } - - public static String getWarrantyExclusion() { - return SystemProperties.get("ro.oxmc.build.warranty_exclusion", "none"); - } - - public static String getSeries() { - return SystemProperties.get("ro.oxmc.build.series", "generic"); - } -} \ No newline at end of file diff --git a/core/java/pawletos/device/PawletDevice.java b/core/java/pawletos/device/PawletDevice.java new file mode 100644 index 0000000..9cc878e --- /dev/null +++ b/core/java/pawletos/device/PawletDevice.java @@ -0,0 +1,118 @@ +package pawletos.device; + +import android.content.Context; +import android.os.Build; +import android.os.SystemProperties; + +/** + * PawletOS Environment API for apps running on PawletOS builds. + */ +public class PawletDevice { + private static final double PAWLET_SDK_VERSION = 1.0; + + /** + * Check if running on an emulator. + */ + public static boolean isEmulator() { + String fingerprint = android.os.Build.FINGERPRINT; + String model = android.os.Build.MODEL; + String manufacturer = android.os.Build.MANUFACTURER; + String brand = android.os.Build.BRAND; + String device = android.os.Build.DEVICE; + String product = android.os.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 = android.os.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() { + // Check manufacturer and system property for OS name + 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; + } + + /** + * Get the brand name. + */ + public static String getBrandName(Context ctx) { + int resId = ctx.getResources().getIdentifier("oxmc_brand_name", "string", ctx.getPackageName()); + if (resId != 0) { + return ctx.getString(resId); + } + return "PawletOS"; + } + + /** + * Get the codename. + */ + public static String getCodename(Context ctx) { + int resId = ctx.getResources().getIdentifier("oxmc_codename", "string", ctx.getPackageName()); + if (resId != 0) { + return ctx.getString(resId); + } + return "generic-pawlet-device"; + } + + // ───────────────────────────── + // Custom build property access + // ───────────────────────────── + + public static String getManufactureDate() { + return SystemProperties.get("ro.oxmc.build.manufacture_date", "unknown"); + } + + public static String getWarrantyExclusion() { + return SystemProperties.get("ro.oxmc.build.warranty_exclusion", "none"); + } + + public static String getSeries() { + return SystemProperties.get("ro.oxmc.build.series", "generic"); + } +} \ No newline at end of file