Change a few things
This commit is contained in:
@@ -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/..."]
|
||||
}
|
@@ -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");
|
||||
}
|
||||
}
|
118
core/java/pawletos/device/PawletDevice.java
Normal file
118
core/java/pawletos/device/PawletDevice.java
Normal file
@@ -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");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user