From d590eef2aced6d0c8747c79a1d12eea04d247430 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Mon, 28 Feb 2022 19:32:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?[Change]=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E5=AD=97=E7=89=88=E6=9D=83=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E8=AE=BE=E5=A4=87ID=E6=96=B9=E6=B3=95=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=9B=A0=E4=B8=BA=E7=B3=BB=E7=BB=9F=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E7=AD=89=E5=8E=9F=E5=9B=A0=E9=80=A0=E6=88=90=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=9A=84SN=E8=A2=AB=E6=94=B9=E5=8F=98=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu (cherry picked from commit 31a0fdd86d46600a2881c0e385475e736e1e6e31) --- .../src/main/AndroidManifest.xml | 2 + .../core/utilcode/util/DeviceIdUtils.java | 93 ++++++++++++++----- 2 files changed, 74 insertions(+), 21 deletions(-) diff --git a/core/mogo-core-utils/src/main/AndroidManifest.xml b/core/mogo-core-utils/src/main/AndroidManifest.xml index c953b8a6ce..11c86de1fd 100644 --- a/core/mogo-core-utils/src/main/AndroidManifest.xml +++ b/core/mogo-core-utils/src/main/AndroidManifest.xml @@ -1,6 +1,8 @@ + + = Build.VERSION_CODES.M) { @@ -54,35 +56,37 @@ public final class DeviceIdUtils { } } } - saveDeviceId(appContext,deviceId); + saveDeviceId(appContext, deviceId); } return deviceId; } - private static String getDeviceIdInternal( Context context) { + private static String getDeviceIdInternal(Context context) { String id = ""; - if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) { - if ( ContextCompat.checkSelfPermission( context, Manifest.permission.READ_PHONE_STATE ) != PackageManager.PERMISSION_GRANTED ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { return id; } } - TelephonyManager telephonymanager = ( TelephonyManager ) context.getSystemService( Context.TELEPHONY_SERVICE); + TelephonyManager telephonymanager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephonymanager != null) { id = telephonymanager.getDeviceId(); - if ( TextUtils.isEmpty(id)) + if (TextUtils.isEmpty(id)) { id = ""; + } } return id; } - private static String getAndroidId( Context context) { + private static String getAndroidId(Context context) { String s = ""; s = Settings.Secure.getString(context.getContentResolver(), "android_id"); - if ( TextUtils.isEmpty(s)) + if (TextUtils.isEmpty(s)) { s = ""; + } return s; } @@ -95,16 +99,63 @@ public final class DeviceIdUtils { if (!method.isAccessible()) { method.setAccessible(true); } - serial = ( String ) method.invoke(new Build(), "ro.serialno"); - } catch ( ClassNotFoundException e) { + serial = (String) method.invoke(new Build(), "ro.serialno"); + } catch (ClassNotFoundException e) { e.printStackTrace(); - } catch ( NoSuchMethodException e) { + } catch (NoSuchMethodException e) { e.printStackTrace(); - } catch ( InvocationTargetException e) { + } catch (InvocationTargetException e) { e.printStackTrace(); - } catch ( IllegalAccessException e) { + } catch (IllegalAccessException e) { e.printStackTrace(); } return serial; } + + /** + * 获取数字版权管理设备ID + * + * @return WidevineID,可能为空 + */ + public static String getWidevineID(Context context) { + try { + //See https://stackoverflow.com/questions/16369818/how-to-get-crypto-scheme-uuid + //You can find some UUIDs in the https://github.com/google/ExoPlayer source code + final UUID WIDEVINE_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL); + MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID); + byte[] widevineId = mediaDrm.getPropertyByteArray(MediaDrm.PROPERTY_DEVICE_UNIQUE_ID); + if (widevineId == null) { + return ""; + } + StringBuilder sb = new StringBuilder(); + for (byte aByte : widevineId) { + sb.append(String.format("%02x", aByte)); + } + return sb.toString(); + } catch (Exception | Error e) { + e.printStackTrace(); + } + return ""; + } + + /** + * 获取数字版权管理设备ID,进行MD5加密,获取32位的唯一标记,给后台生成SN + * + * @return WidevineID,可能为空 + */ + public static String getWidevineIDWithMd5(Context context) { + try { + String widevineId = getWidevineID(context); + if (!TextUtils.isEmpty(widevineId)) { + widevineId = EncryptUtils.encryptHmacMD5ToString(widevineId, "MoGoAuto"); + return widevineId; + } else { + return getDeviceId(context); + } + } catch (Exception | Error e) { + e.printStackTrace(); + } + return getDeviceId(context); + } + } \ No newline at end of file From 83999af729f011b2cad1bb803a985c4a48281b0a Mon Sep 17 00:00:00 2001 From: donghongyu Date: Tue, 1 Mar 2022 17:18:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[Change]=20=E6=8B=BC=E6=8E=A5=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E6=A0=87=E8=AE=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../apm/ApmCrashReportProvider.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java b/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java index 8446c6d2e7..e51fa444f1 100644 --- a/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java +++ b/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java @@ -8,6 +8,7 @@ import com.apm.insight.CrashType; import com.apm.insight.MonitorCrash; import com.apm.insight.log.VLog; import com.bytedance.apm.insight.ApmInsight; +import com.bytedance.apm.insight.ApmInsightAgent; import com.bytedance.apm.insight.ApmInsightInitConfig; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.eagle.core.utilcode.mogo.logger.Logger; @@ -31,6 +32,7 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider { private static final String BYTEAMP_APPID = "302368"; private static final String TAG = "ApmCrashReportProvider"; + private static final String MAP_SDK_VERSION = "MAP_SDK_VERSION"; @Override public void init(Context context) { @@ -52,9 +54,22 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider { } }); crash.config().setChannel("eagle"); - crash.config().setDeviceId(MoGoAiCloudClientConfig.getInstance().getSn());//可选,可以设置自定义did,不设置会使用内部默认的 + //可选,可以设置自定义did,不设置会使用内部默认的 + crash.config().setDeviceId(MoGoAiCloudClientConfig.getInstance().getSn()); + String mapSDKVersion = AppUtils.getCustomMapSDKVersion(context); + crash.addTags(MAP_SDK_VERSION, mapSDKVersion); // crash.setReportUrl("www.xxx.com"); // 私有化部署:私有化部署才配置上报地址 // crash.addTags("key", "value"); // 自定义筛选tag, 按需添加、可多次覆盖 + + HashMap dimension = new HashMap<>(); + //维度值 + dimension.put("Devices_SN_DeviceId", MoGoAiCloudClientConfig.getInstance().getSn() + "__" + DeviceIdUtils.getDeviceId(context)); + dimension.put("Devices_SN_WidevineID_MD5", MoGoAiCloudClientConfig.getInstance().getSn() + "__" + DeviceIdUtils.getWidevineIDWithMd5(context)); + dimension.put("Devices_SN_WidevineID", MoGoAiCloudClientConfig.getInstance().getSn() + "__" + DeviceIdUtils.getWidevineID(context)); + HashMap metric = new HashMap<>(); + //指标值 + //metric.put("Devices_ID_metric", (double) 100); + ApmInsightAgent.monitorEvent("Devices_ID_EVENT", dimension, metric); } /** @@ -80,7 +95,7 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider { //是否打印日志,注:线上release版本要配置为false builder.debugMode(true); //支持用户自定义user_id把平台数据和自己用户关联起来,可以不配置 -// builder.userId("user_id"); + builder.userId(MoGoAiCloudClientConfig.getInstance().getSn()); //私有化部署:配置数据上报的域名 (私有化部署才需要配置,内部有默认域名),测试支持设置http://www.xxx.com 默认是https协议 // builder.defaultReportDomain("www.xxx.com"); //设置渠道。1.3.16版本增加接口 From 1240e218f20ca52993f0fb11ba34213745a5b67f Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 2 Mar 2022 11:41:09 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[Change]=20=E5=A2=9E=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E7=89=88=E6=9D=83ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt | 1 + .../src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 7a428474e1..5058f75ed1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -415,6 +415,7 @@ class DebugSettingView @JvmOverloads constructor( AppConfigInfo.appVersionName = AppUtils.getAppVersionName() AppConfigInfo.appPackageName = AppUtils.getAppPackageName() AppConfigInfo.uniqueDeviceId = DeviceIdUtils.getDeviceId(AbsMogoApplication.getApp()) + AppConfigInfo.widevineIDMd5 = DeviceIdUtils.getWidevineIDWithMd5(AbsMogoApplication.getApp()) AppConfigInfo.mogoSN = MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn AppConfigInfo.mogoToken = MoGoAiCloudClient.getInstance().aiCloudClientConfig.token AppConfigInfo.netMode = DebugConfig.getNetMode() diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt index d8bfadb408..9c93745808 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt @@ -16,6 +16,7 @@ object AppConfigInfo { var appVersionName: String? = null var appPackageName: String? = null var uniqueDeviceId: String? = null + var widevineIDMd5: String? = null // 高精地图版本 var mapSdkVersion: String? = null @@ -58,6 +59,7 @@ object AppConfigInfo { "ADAS-SDK版本:${adasSdkVersion}
" + "OBU-SDK版本:${obuSdkVersion}
" + "------------------鉴权信息---------------------
" + + "数字版权ID:${widevineIDMd5}
" + "PAD唯一标志:${uniqueDeviceId}
" + //"mogoToken:${mogoToken}
"+ "中台分配的SN:${mogoSN}
" + From d42aea7f6cc4ec419b2b6b10922b3424325f324f Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 2 Mar 2022 12:40:42 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[Change]=20=E5=A2=9E=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E7=89=88=E6=9D=83ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../com/mogo/test/crashreport/apm/ApmCrashReportProvider.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java b/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java index e51fa444f1..5a25fd6bf2 100644 --- a/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java +++ b/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java @@ -14,6 +14,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.eagle.core.utilcode.mogo.logger.Logger; import com.mogo.eagle.core.utilcode.util.AppUtils; import com.mogo.eagle.core.utilcode.util.CommonUtils; +import com.mogo.eagle.core.utilcode.util.DeviceIdUtils; import com.mogo.test.crashreport.CrashReportConstants; import com.mogo.test.crashreport.ITestCrashReportProvider; From b07dd902d1500cfe236ddfa0b8ee96a1ec631a2f Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 2 Mar 2022 14:01:35 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[Change]=20=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E7=89=88=E6=9D=83ID=E5=8A=A0=E5=AF=86=E9=80=A0?= =?UTF-8?q?=E6=88=90=E7=9A=84=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- app/productFlavors/fPadLenovo.gradle | 2 +- .../hmi/ui/setting/DebugSettingView.kt | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/productFlavors/fPadLenovo.gradle b/app/productFlavors/fPadLenovo.gradle index cd72bc87d6..31335d67d8 100644 --- a/app/productFlavors/fPadLenovo.gradle +++ b/app/productFlavors/fPadLenovo.gradle @@ -29,7 +29,7 @@ project.android.productFlavors { // 构建的应用身份类型,司机|乘客 buildConfigField 'int', 'APP_IDENTITY_MODE', "0x02" // 连接的工控机IP地址 - buildConfigField 'String', 'ADAS_CONNECT_IP', "\"192.168.1.102\"" + buildConfigField 'String', 'ADAS_CONNECT_IP', "\"192.168.1.104\"" // 构建的是否是演示(美化)模式 buildConfigField 'boolean', 'IS_DEMO_MODE', 'true' } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 5058f75ed1..fb7ea4c1ec 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -411,11 +411,21 @@ class DebugSettingView @JvmOverloads constructor( private fun drawAppInfo() { AppConfigInfo.appName = AppUtils.getAppName() AppConfigInfo.appName = AppUtils.getAppName() - AppConfigInfo.appVersionCode = AppUtils.getAppVersionCode() - AppConfigInfo.appVersionName = AppUtils.getAppVersionName() - AppConfigInfo.appPackageName = AppUtils.getAppPackageName() - AppConfigInfo.uniqueDeviceId = DeviceIdUtils.getDeviceId(AbsMogoApplication.getApp()) - AppConfigInfo.widevineIDMd5 = DeviceIdUtils.getWidevineIDWithMd5(AbsMogoApplication.getApp()) + if (AppConfigInfo.appVersionCode == 0) { + AppConfigInfo.appVersionCode = AppUtils.getAppVersionCode() + } + if (AppConfigInfo.appVersionName.isNullOrEmpty()) { + AppConfigInfo.appVersionName = AppUtils.getAppVersionName() + } + if (AppConfigInfo.appPackageName.isNullOrEmpty()) { + AppConfigInfo.appPackageName = AppUtils.getAppPackageName() + } + if (AppConfigInfo.uniqueDeviceId.isNullOrEmpty()) { + AppConfigInfo.uniqueDeviceId = DeviceIdUtils.getDeviceId(AbsMogoApplication.getApp()) + } + if (AppConfigInfo.widevineIDMd5.isNullOrEmpty()) { + AppConfigInfo.widevineIDMd5 = DeviceIdUtils.getWidevineIDWithMd5(AbsMogoApplication.getApp()) + } AppConfigInfo.mogoSN = MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn AppConfigInfo.mogoToken = MoGoAiCloudClient.getInstance().aiCloudClientConfig.token AppConfigInfo.netMode = DebugConfig.getNetMode()