类 DeviceUtils
- java.lang.Object
-
- cn.authing.guard.util.DeviceUtils
-
public final class DeviceUtils extends Object
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classDeviceUtils.CommandResultThe result of command.
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static DeviceUtils.CommandResultexecCmd(String[] commands, boolean isRooted, boolean isNeedResultMsg)static DeviceUtils.CommandResultexecCmd(String[] commands, String[] envp, boolean isRooted, boolean isNeedResultMsg)static DeviceUtils.CommandResultexecCmd(String command, boolean isRooted)static String[]getABIs()Return an ordered list of ABIs supported by this device.static StringgetAndroidID(Context context)Return the android id of device.static StringgetMacAddress(Context context)Return the MAC address.static StringgetMacAddress(Context context, String... excepts)Return the MAC address.static StringgetManufacturer()Return the manufacturer of the product/hardware.static StringgetModel()Return the model of device.static intgetSDKVersionCode()Return version code of device's system.static StringgetSDKVersionName()Return the version name of device's system.static StringgetString(Context context, String key, String defaultValue)static StringgetUniqueDeviceId(Context context)Return the unique device id.static StringgetUniqueDeviceId(Context context, boolean useCache)Return the unique device id.static StringgetUniqueDeviceId(Context context, String prefix)Return the unique device id.static StringgetUniqueDeviceId(Context context, String prefix, boolean useCache)Return the unique device id.static booleanisAdbEnabled(Context context)Return whether ADB is enabled.static booleanisDevelopmentSettingsEnabled(Context context)Whether user has enabled development settings.static booleanisDeviceRooted()Return whether device is rooted.static booleanisEmulator(Context context)Return whether device is emulator.static booleanisSameDevice(Context context, String uniqueDeviceId)static booleanisTablet()Return whether device is tablet.static voidput(Context context, String key, String value)
-
-
-
方法详细资料
-
isDeviceRooted
public static boolean isDeviceRooted()
Return whether device is rooted.- 返回:
true: yesfalse: no
-
isAdbEnabled
@RequiresApi(api=17) public static boolean isAdbEnabled(Context context)
Return whether ADB is enabled.- 返回:
true: yesfalse: no
-
getSDKVersionName
public static String getSDKVersionName()
Return the version name of device's system.- 返回:
- the version name of device's system
-
getSDKVersionCode
public static int getSDKVersionCode()
Return version code of device's system.- 返回:
- version code of device's system
-
getAndroidID
public static String getAndroidID(Context context)
Return the android id of device.- 返回:
- the android id of device
-
getMacAddress
@RequiresPermission(allOf={"android.permission.ACCESS_WIFI_STATE","android.permission.CHANGE_WIFI_STATE"}) public static String getMacAddress(Context context)Return the MAC address.Must hold
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />,<uses-permission android:name="android.permission.INTERNET" />,<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />- 返回:
- the MAC address
-
getMacAddress
@RequiresPermission(allOf="android.permission.ACCESS_WIFI_STATE") public static String getMacAddress(Context context, String... excepts)
Return the MAC address.Must hold
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />,<uses-permission android:name="android.permission.INTERNET" />- 返回:
- the MAC address
-
getManufacturer
public static String getManufacturer()
Return the manufacturer of the product/hardware.e.g. Xiaomi
- 返回:
- the manufacturer of the product/hardware
-
getModel
public static String getModel()
Return the model of device.e.g. MI2SC
- 返回:
- the model of device
-
getABIs
public static String[] getABIs()
Return an ordered list of ABIs supported by this device. The most preferred ABI is the first element in the list.- 返回:
- an ordered list of ABIs supported by this device
-
isTablet
public static boolean isTablet()
Return whether device is tablet.- 返回:
true: yesfalse: no
-
isEmulator
public static boolean isEmulator(Context context)
Return whether device is emulator.- 返回:
true: yesfalse: no
-
isDevelopmentSettingsEnabled
@RequiresApi(api=17) public static boolean isDevelopmentSettingsEnabled(Context context)
Whether user has enabled development settings.- 返回:
- whether user has enabled development settings.
-
getUniqueDeviceId
public static String getUniqueDeviceId(Context context)
Return the unique device id.{1}{UUID(macAddress)}{2}{UUID(androidId )}{9}{UUID(random )}- 返回:
- the unique device id
-
getUniqueDeviceId
public static String getUniqueDeviceId(Context context, String prefix)
Return the unique device id.android 10 deprecated {prefix}{1}{UUID(macAddress)}{prefix}{2}{UUID(androidId )}{prefix}{9}{UUID(random )}- 参数:
prefix- The prefix of the unique device id.- 返回:
- the unique device id
-
getUniqueDeviceId
public static String getUniqueDeviceId(Context context, boolean useCache)
Return the unique device id.{1}{UUID(macAddress)}{2}{UUID(androidId )}{9}{UUID(random )}- 参数:
useCache- True to use cache, false otherwise.- 返回:
- the unique device id
-
getUniqueDeviceId
public static String getUniqueDeviceId(Context context, String prefix, boolean useCache)
Return the unique device id.android 10 deprecated {prefix}{1}{UUID(macAddress)}{prefix}{2}{UUID(androidId )}{prefix}{9}{UUID(random )}- 参数:
prefix- The prefix of the unique device id.useCache- True to use cache, false otherwise.- 返回:
- the unique device id
-
isSameDevice
@RequiresPermission(allOf={"android.permission.ACCESS_WIFI_STATE","android.permission.INTERNET","android.permission.CHANGE_WIFI_STATE"}) public static boolean isSameDevice(Context context, String uniqueDeviceId)
-
getString
public static String getString(Context context, @NonNull String key, String defaultValue)
-
execCmd
public static DeviceUtils.CommandResult execCmd(String command, boolean isRooted)
-
execCmd
public static DeviceUtils.CommandResult execCmd(String[] commands, boolean isRooted, boolean isNeedResultMsg)
-
execCmd
public static DeviceUtils.CommandResult execCmd(String[] commands, String[] envp, boolean isRooted, boolean isNeedResultMsg)
-
-