added one ui check and miui ui version info
This commit is contained in:
@@ -48,6 +48,14 @@ public class Device {
|
||||
}
|
||||
|
||||
public String toDeviceName() {
|
||||
return "Device information: " + "commit='" + getBuildNumber() + "', sdkVersion=" + this.sdkVersion + ", productName='" + this.productName + "', deviceName='" + this.deviceName + "', boardName='" + this.boardName + "', manufacturerName='" + this.manufacturerName + "', brandName='" + this.brandName + "', modelName='" + this.modelName + "'";
|
||||
return "Device information: "
|
||||
+ "commit='" + getBuildNumber()
|
||||
+ "', sdkVersion=" + this.sdkVersion
|
||||
+ ", productName='" + this.productName
|
||||
+ "', deviceName='" + this.deviceName
|
||||
+ "', boardName='" + this.boardName
|
||||
+ "', manufacturerName='" + this.manufacturerName
|
||||
+ "', brandName='" + this.brandName
|
||||
+ "', modelName='" + this.modelName + "'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,14 @@ import android.os.Build;
|
||||
public class DeviceInfoCollector {
|
||||
|
||||
public Device collect() {
|
||||
return new Device().withSdkVersion(Build.VERSION.SDK_INT).withProductName(Build.PRODUCT).withDeviceName(Build.DEVICE).withBoardName(Build.BOARD).withManufacturerName(Build.MANUFACTURER).withBrandName(Build.BRAND).withModelName(Build.MODEL);
|
||||
return new Device()
|
||||
.withSdkVersion(Build.VERSION.SDK_INT)
|
||||
.withProductName(Build.PRODUCT)
|
||||
.withDeviceName(Build.DEVICE)
|
||||
.withBoardName(Build.BOARD)
|
||||
.withManufacturerName(Build.MANUFACTURER)
|
||||
.withBrandName(Build.BRAND)
|
||||
.withModelName(Build.MODEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,63 @@
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import ru.vtosters.lite.utils.ReflectionUtils;
|
||||
|
||||
public class OEMDetector {
|
||||
private static Field semPlatformIntField;
|
||||
|
||||
private static Boolean isOneUi;
|
||||
private static int oneUiMajorVersion;
|
||||
private static float oneUiMinorVersion;
|
||||
|
||||
static {
|
||||
try {
|
||||
semPlatformIntField = ReflectionUtils.getDeclaredField(Build.VERSION.class, "SEM_PLATFORM_INT");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOneUi() {
|
||||
if (isOneUi != null)
|
||||
return isSamsung() && isOneUi;
|
||||
try {
|
||||
var semPlatform = semPlatformIntField.getInt(null);
|
||||
if (semPlatform < 0x186a0) {
|
||||
isOneUi = false;
|
||||
return false;
|
||||
}
|
||||
final var encodedVersion = semPlatform - 0x15f90;
|
||||
oneUiMajorVersion = encodedVersion / 0x2710;
|
||||
oneUiMinorVersion = (encodedVersion % 0x2710) / 0x64;
|
||||
isOneUi = true;
|
||||
} catch (Throwable e) {
|
||||
isOneUi = false;
|
||||
}
|
||||
return isOneUi;
|
||||
}
|
||||
|
||||
public static int getOneUiMajorVersion() {
|
||||
return isOneUi() ? oneUiMajorVersion : 0;
|
||||
}
|
||||
|
||||
public static float getOneUiMinorVersion() {
|
||||
return isOneUi() ? oneUiMinorVersion : 0;
|
||||
}
|
||||
|
||||
public static boolean isOEM() {
|
||||
return isMIUI() || isEMUI() || isFlyme() || isZenUI() || isSamsung() || isVivo();
|
||||
}
|
||||
|
||||
private static boolean isMIUI() {
|
||||
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
|
||||
return !TextUtils.isEmpty(getMiuiUiVersionName());
|
||||
}
|
||||
|
||||
private static boolean isEMUI() {
|
||||
@@ -35,6 +80,14 @@ public class OEMDetector {
|
||||
return !TextUtils.isEmpty(getSystemProperty("ro.build.ro.meizu.rom.config")) || !TextUtils.isEmpty(getSystemProperty("persist.sys.static_blur_mode")) || !TextUtils.isEmpty(getSystemProperty("persist.sys.use.flyme.icon"));
|
||||
}
|
||||
|
||||
public static String getMiuiUiVersionName() {
|
||||
return getSystemProperty("ro.miui.ui.version.name");
|
||||
}
|
||||
|
||||
public static String getMiuiUiVersionCode() {
|
||||
return getSystemProperty("ro.miui.ui.version.code");
|
||||
}
|
||||
|
||||
private static String getSystemProperty(String str) {
|
||||
BufferedReader bufferedReader;
|
||||
try {
|
||||
@@ -52,4 +105,6 @@ public class OEMDetector {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user