Browse Source

1.3.6 兼容紫鹏11,A50(X5)的sn获取

xulh 8 months ago
parent
commit
558135ccee

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -5,8 +5,8 @@
 
     <uses-permission android:name="android.permission.INTERNET"/>
 
-    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
     <uses-permission android:name="com.dopamine.provider.READ" />
 
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

+ 4 - 0
app/src/main/java/com/hh/hhomc/services/BackgroundService.java

@@ -916,6 +916,10 @@ public class BackgroundService extends Service {
         String logPath = serverActionBean.getLogDirPath();
         AppLogUtils.e("logPath:" + logPath);
 
+//        if(StringUtils.isNull(logType)){
+//            logType = "logcat";
+//        }
+
         List<String> logTypeList = printLogPath(logPath, Constants.VALUE.TIME_LOG_DAY);
 
         // 返回日志文件名列表

+ 38 - 4
app/src/main/java/com/hh/hhomc/utils/DeviceUtils.java

@@ -44,8 +44,10 @@ public final class DeviceUtils {
             Method get = c.getMethod("get", String.class);
             if (Build.VERSION.SDK_INT <= 28) {//28 is andoird 9.0 24-7.0 22-5.1
                 serial = (String) get.invoke(c, "ro.serialno");
+                AppLogUtils.e("SDK_INT <= 28--serial:"+serial);
             } else {
                 serial = (String) get.invoke(c, "persist.sys.hrSerial");//vendor.gsm.serial
+                AppLogUtils.e("SDK_INT > 28--serial:"+serial);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -54,12 +56,44 @@ public final class DeviceUtils {
 
         // 兼容版本11的紫鹏
         if (TextUtils.isEmpty(serial)) {
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-                // 注意清单文件加上READ_PHONE_STATE权限,不然还是会获取失败
-                serial = Build.getSerial();
-            }else{
+//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+//                // 注意清单文件加上READ_PHONE_STATE权限,不然还是会获取失败
+//                serial = Build.getSerial();
+//            }else{
+//                serial = Build.SERIAL;
+//            }
+
+
+            if(TextUtils.isEmpty(serial)) {
                 serial = Build.SERIAL;
+                AppLogUtils.e("SDK_INT < O--serial:"+serial);
+                if(!TextUtils.isEmpty(serial)&&!serial.equals("unknown")) {
+                    // 判断非空和非unknown,则返回
+                    return serial;
+                }else{
+                    serial = "";
+                }
             }
+
+
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+                try {
+                    // 高版本走到这里,又没有权限,会报错。建议targetSdkVersion为22,避免后续降版本提示应用未安装
+                    serial = Build.getSerial();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                AppLogUtils.e("SDK_INT >= O--serial:"+serial);
+                if(!TextUtils.isEmpty(serial)&&!serial.equals("unknown")) {
+                    // 判断非空和非unknown,则返回
+                    return serial;
+                }else{
+                    serial = "";
+                }
+            }
+
+
+
         }
 
         if (TextUtils.isEmpty(serial)) {

+ 2 - 2
config.gradle

@@ -7,8 +7,8 @@ ext {
 //            minSdkVersion    : 24,
             minSdkVersion    : 21,
             targetSdkVersion : 30,
-            versionCode      : 10,
-            versionName      : "1.3.4"
+            versionCode      : 12,
+            versionName      : "1.3.6"
     ]
     //依赖 配置
     dependencies = [