修复sn生成规则

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-10-13 17:40:07 +08:00
parent 5368aec141
commit 2d3a00700c
9 changed files with 80 additions and 128 deletions

View File

@@ -36,33 +36,25 @@ public final class DeviceIdUtils {
if ( TextUtils.isEmpty( deviceId )) {
deviceId = getDeviceIdInternal(appContext);
if (!TextUtils.isEmpty(deviceId)) {
saveDeviceId(appContext,deviceId);
} else {
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) {
if ( ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE ) == PackageManager.PERMISSION_GRANTED ) {
deviceId = (( TelephonyManager ) appContext.getSystemService( Context.TELEPHONY_SERVICE)).getSimSerialNumber();
if (TextUtils.isEmpty(deviceId)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
deviceId = ((TelephonyManager) appContext.getSystemService(Context.TELEPHONY_SERVICE)).getSimSerialNumber();
}
}else{
deviceId = (( TelephonyManager ) appContext.getSystemService( Context.TELEPHONY_SERVICE)).getSimSerialNumber();
}
if (!TextUtils.isEmpty(deviceId)) {
saveDeviceId(appContext,deviceId);
} else {
deviceId = ((TelephonyManager) appContext.getSystemService(Context.TELEPHONY_SERVICE)).getSimSerialNumber();
}
if (TextUtils.isEmpty(deviceId)) {
deviceId = getDeviceSerial();
if (!TextUtils.isEmpty(deviceId) && !deviceId.equalsIgnoreCase("unknown")) {
saveDeviceId(appContext,deviceId);
} else {
if (TextUtils.isEmpty(deviceId) || deviceId.equalsIgnoreCase("unknown")) {
deviceId = getAndroidId(appContext);
if (!TextUtils.isEmpty(deviceId)) {
saveDeviceId(appContext,deviceId);
} else {
deviceId = String.valueOf( System.currentTimeMillis());
saveDeviceId(appContext,deviceId);
if (TextUtils.isEmpty(deviceId)) {
deviceId = String.valueOf(System.currentTimeMillis());
}
}
}
}
saveDeviceId(appContext,deviceId);
}
return deviceId;