更新 DeviceInfoUtils.java

dev
wangsiyuan 2023-12-08 14:40:19 +08:00
parent 7cc38536f0
commit 4ef4f6fe39
1 changed files with 39 additions and 22 deletions

View File

@ -1,12 +1,10 @@
package com.nbee.echolink.utils;
import java.util.Locale;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;
public class DeviceInfoUtils {
/**
* px
@ -15,111 +13,127 @@ public class DeviceInfoUtils {
public static int getDeviceWidth(Context context) {
return context.getResources().getDisplayMetrics().widthPixels;
}
/**
* px
*/
public static int getDeviceHeight(Context context) {
return context.getResources().getDisplayMetrics().heightPixels;
}
/**
* android.permission.READ_Phone_STATE
* Android 10
*/
// public static String getIMEI(Context context) {
// TelephonyManager tm = (TelephonyManager) context
// .getSystemService(Context.TELEPHONY_SERVICE);
// String deviceId = tm.getDeviceId();
// if (deviceId == null) {
// return "UnKnown";
// } else {
// return deviceId;
// }
// }
public static String getIMEI(Context context) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
if (deviceId == null) {
return "UnKnown";
} else {
return deviceId;
}
}
/**
*
* **/
**/
public static String getDeviceManufacturer() {
return android.os.Build.MANUFACTURER;
}
/**
*
* **/
**/
public static String getDeviceProduct() {
return android.os.Build.PRODUCT;
}
/**
*
*/
public static String getDeviceBrand() {
return android.os.Build.BRAND;
}
/**
*
*/
public static String getDeviceModel() {
return android.os.Build.MODEL;
}
/**
*
*/
public static String getDeviceBoard() {
return android.os.Build.BOARD;
}
/**
*
* **/
**/
public static String getDeviceDevice() {
return android.os.Build.DEVICE;
}
/**
*
*
* fingerprit
* **/
**/
public static String getDeviceFubgerprint() {
return android.os.Build.FINGERPRINT;
}
/**
*
*
* **/
**/
public static String getDeviceHardware() {
return android.os.Build.HARDWARE;
}
/**
*
*
* **/
**/
public static String getDeviceHost() {
return android.os.Build.HOST;
}
/**
*
* ID
* **/
**/
public static String getDeviceDisplay() {
return android.os.Build.DISPLAY;
}
/**
* ID
*
* **/
**/
public static String getDeviceId() {
return android.os.Build.ID;
}
/**
*
*
* **/
**/
public static String getDeviceUser() {
return android.os.Build.USER;
}
/**
*
* **/
**/
public static String getDeviceSerial() {
return android.os.Build.SERIAL;
}
/**
* Android SDK
*
@ -128,6 +142,7 @@ public class DeviceInfoUtils {
public static int getDeviceSDK() {
return android.os.Build.VERSION.SDK_INT;
}
/**
* Android
*
@ -136,12 +151,14 @@ public class DeviceInfoUtils {
public static String getDeviceAndroidVersion() {
return android.os.Build.VERSION.RELEASE;
}
/**
*
*/
public static String getDeviceDefaultLanguage() {
return Locale.getDefault().getLanguage();
}
/**
* (Locale)
*/