Add core/java/pawletos/device/PawletSystem.java
This commit is contained in:
79
core/java/pawletos/device/PawletSystem.java
Normal file
79
core/java/pawletos/device/PawletSystem.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user