Files
FrameworkAPI/core/java/pawletos/device/PawletDevice.java
2025-08-18 21:34:17 -07:00

118 lines
3.9 KiB
Java

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");
}
}