下面列出了android.os.Build#DISPLAY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static int getFlymeVersion() {
String displayId = Build.DISPLAY;
if (!TextUtils.isEmpty(displayId) && displayId.contains("Flyme")) {
displayId = displayId.replaceAll("Flyme", "");
displayId = displayId.replaceAll("OS", "");
displayId = displayId.replaceAll(" ", "");
String version = displayId.substring(0, 1);
if (version != null) {
return stringToInt(version);
}
}
return 0;
}
public static boolean check(String rom) {
if (sName != null) {
return sName.equals(rom);
}
if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {
sName = ROM_MIUI;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {
sName = ROM_EMUI;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {
sName = ROM_OPPO;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {
sName = ROM_VIVO;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {
sName = ROM_SMARTISAN;
} else {
sVersion = Build.DISPLAY;
if (sVersion.toUpperCase().contains(ROM_FLYME)) {
sName = ROM_FLYME;
} else {
sVersion = Build.UNKNOWN;
sName = Build.MANUFACTURER.toUpperCase();
}
}
return sName.equals(rom);
}
public static boolean check(String rom) {
if (sName != null) {
return sName.equals(rom);
}
if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {
sName = ROM_MIUI;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {
sName = ROM_EMUI;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {
sName = ROM_OPPO;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {
sName = ROM_VIVO;
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {
sName = ROM_SMARTISAN;
} else {
sVersion = Build.DISPLAY;
if (sVersion.toUpperCase().contains(ROM_FLYME)) {
sName = ROM_FLYME;
} else {
sVersion = Build.UNKNOWN;
sName = Build.MANUFACTURER.toUpperCase();
}
}
return sName.equals(rom);
}
/**
* 获取 ROM 版本信息
* @param propertyName 属性名
* @return ROM 版本信息
*/
private static String getRomVersion(final String propertyName) {
String ret = "";
if (!TextUtils.isEmpty(propertyName)) {
ret = getSystemProperty(propertyName);
}
if (TextUtils.isEmpty(ret) || ret.equals(UNKNOWN)) {
try {
String display = Build.DISPLAY;
if (!TextUtils.isEmpty(display)) {
ret = display.toLowerCase();
}
} catch (Throwable ignore) {
}
}
if (TextUtils.isEmpty(ret)) {
return UNKNOWN;
}
return ret;
}
private static String getRomVersion(final String propertyName) {
String ret = "";
if (!TextUtils.isEmpty(propertyName)) {
ret = getSystemProperty(propertyName);
}
if (TextUtils.isEmpty(ret) || ret.equals(UNKNOWN)) {
try {
String display = Build.DISPLAY;
if (!TextUtils.isEmpty(display)) {
ret = display.toLowerCase();
}
} catch (Throwable ignore) {/**/}
}
if (TextUtils.isEmpty(ret)) {
return UNKNOWN;
}
return ret;
}
private static String getRomVersion(final String propertyName) {
String ret = "";
if (!TextUtils.isEmpty(propertyName)) {
ret = getSystemProperty(propertyName);
}
if (TextUtils.isEmpty(ret) || ret.equals(UNKNOWN)) {
try {
String display = Build.DISPLAY;
if (!TextUtils.isEmpty(display)) {
ret = display.toLowerCase();
}
} catch (Throwable ignore) {/**/}
}
if (TextUtils.isEmpty(ret)) {
return UNKNOWN;
}
return ret;
}
@SuppressLint("NewApi")
private void setCamcorderProfile() {
CamcorderProfile profile;
profile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
if (profile != null) {
if (currentUsePoint != null) {
profile.videoFrameWidth = currentUsePoint.x;
profile.videoFrameHeight = currentUsePoint.y;
}
profile.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
if (Build.MODEL.equalsIgnoreCase("MB525") || Build.MODEL.equalsIgnoreCase("C8812") ||
Build.MODEL.equalsIgnoreCase("C8650")) {
profile.videoCodec = MediaRecorder.VideoEncoder.H263;
} else {
profile.videoCodec = MediaRecorder.VideoEncoder.H264;
}
if (Build.VERSION.SDK_INT >= 14) {
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
} else {
if (Build.DISPLAY != null && Build.DISPLAY.indexOf("MIUI") >= 0) {
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
} else {
profile.audioCodec = MediaRecorder.AudioEncoder.AMR_NB;
}
}
mediaRecorder.setProfile(profile);
} else {
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
}
}
public static void loadFromContext(Context context) {
APP_NAME = getAppName(context);
ANDROID_VERSION = Build.VERSION.RELEASE;
ANDROID_BUILD = Build.DISPLAY;
PHONE_MODEL = Build.MODEL;
PHONE_MANUFACTURER = Build.MANUFACTURER;
SDK_ID = Functions.getSdkId();
loadPackageData(context);
loadCrashIdentifier(context);
}
public static String getDeviceInfo() {
return "Android version: " + Build.VERSION.RELEASE + "\n" +
"Device: " + Build.DEVICE + "\n" +
"Product: " + Build.PRODUCT + "\n" +
"Brand: " + Build.BRAND + "\n" +
"Display: " + Build.DISPLAY + "\n" +
"Manufacturer: " + Build.MANUFACTURER + "\n" +
"Model: " + Build.MODEL + "\n";
}
@Override
public void onResume() {
super.onResume();
TextView textView = (TextView) getActivity().findViewById(R.id.txt_build_info);
String text = String.format("WALT v%s (versionCode=%d)\n",
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
text += "WALT protocol version: " + WaltDevice.PROTOCOL_VERSION + "\n";
text += "Android Build ID: " + Build.DISPLAY + "\n";
text += "Android API Level: " + Build.VERSION.SDK_INT + "\n";
text += "Android OS Version: " + System.getProperty("os.version");
textView.setText(text);
}
public static boolean isAOSP(int sdk) {
if (!PrivacyManager.cVersion3)
return false;
if (Build.VERSION.SDK_INT >= sdk) {
if ("true".equals(System.getenv("XPrivacy.AOSP")))
return true;
if (Build.DISPLAY == null || Build.HOST == null)
return false;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
// @formatter:off
return (
isAOSP() ||
isCyanogenMod() ||
isOmni() ||
isMIUI() ||
isSlim() ||
isParanoidAndroid() ||
isCarbon() ||
isDirtyUnicorns() ||
isLiquidSmooth() ||
isAndroidRevolutionHD() ||
isMahdi() ||
isOmega()
);
// @formatter:on
else
return isAOSP();
} else
return false;
}
public static String getDisplay() {
return Build.DISPLAY;
}
public static String getBuildDisplayId() {
return Build.DISPLAY;
}
public static String getBuildDisplayId() {
return Build.DISPLAY;
}
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
String crashTime =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())
.format(new Date());
String env =
"########RuntimeEnviormentInormation#######\n" +
"crashTime = " + crashTime + "\n" +
"model = " + Build.MODEL + "\n" +
"android = " + Build.VERSION.RELEASE + "(" + Build.VERSION.SDK_INT + ")\n" +
"brand = " + Build.BRAND + "\n" +
"manufacturer = " + Build.MANUFACTURER + "\n" +
"board = " + Build.BOARD + "\n" +
"hardware = " + Build.HARDWARE + "\n" +
"device = " + Build.DEVICE + "\n" +
"version = " + getVersionName() + "(" + getVersionCode() + ")\n" +
"supportAbis = " + getSupportAbis() + "\n" +
"display = " + Build.DISPLAY + "\n";
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
e.printStackTrace(printWriter);
Throwable cause = e.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String stack = "############ForceCloseCrashLog############\n" + writer.toString();
String message = env + stack;
try {
String name = "error_log_" + crashTime + ".log";
FileOutputStream fos =
new FileOutputStream(new File(mContext.getExternalFilesDir("logs"), name));
fos.write(message.getBytes());
fos.close();
} catch (IOException ex) {
ex.printStackTrace();
}
Process.killProcess(Process.myPid());
System.exit(1);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String getDisplaySync() { return Build.DISPLAY; }
/**
* 获取Flyme的版本
*
* @return
*/
public static String getFlymeVersion() {
return isFlyme() ? Build.DISPLAY : "";
}
/**
* 获取系统版本号
*
* @return 系统版本号
*/
public static String getDisplay() {
return Build.DISPLAY;
}
/**
* 获取设备显示的版本包 ( 在系统设置中显示为版本号 ) 和 ID 一样
* @return 设备显示的版本包
*/
public static String getDisplay() {
return Build.DISPLAY;
}
/**
* 获取Flyme的版本
*
* @return
*/
public static String getFlymeVersion() {
return isFlyme() ? Build.DISPLAY : "";
}