uni-app中数字天堂SDK在授权行为前获取了两次IMEI

发布于 1周前 作者 gougou168 来自 Uni-App

uni-app中数字天堂SDK在授权行为前获取了两次IMEI

17 回复

请提供完整的调用栈信息。


android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:1723) java.lang.reflect.Method.invoke(Native Method) io.dcloud.common.adapter.util.PlatformUtil.invokeMethod(Unknown Source:6) io.dcloud.common.util.TelephonyUtil.getMultiIMEI(Unknown Source:34) io.dcloud.common.util.TelephonyUtil.updateIMEI(Unknown Source:3) io.dcloud.common.adapter.util.DeviceInfo.initGsmCdmaCell(Unknown Source:11) io.dcloud.g.b.a(Unknown Source:35) io.dcloud.g.b.a(Unknown Source:3) io.dcloud.g.b.processEvent(Unknown Source:165) io.dcloud.e.c.c.dispatchEvent(Unknown Source:22) io.dcloud.common.core.ui.l.processEvent(Unknown Source:2) io.dcloud.common.core.ui.b.obtainPrePlusreadyJs(Unknown Source:2) io.dcloud.common.adapter.ui.webview.WebLoadEvent.reset(Unknown Source:1) io.dcloud.common.adapter.ui.webview.WebLoadEvent.<init>(Unknown Source:957) io.dcloud.common.adapter.ui.webview.SysWebView.init(Unknown Source:136) io.dcloud.common.adapter.ui.AdaWebview.init(Unknown Source:2) io.dcloud.common.core.ui.l.a(Unknown Source:661) io.dcloud.common.core.ui.l.processEvent(Unknown Source:5731) io.dcloud.common.core.ui.l.a(Unknown Source:159) io.dcloud.common.core.ui.l.processEvent(Unknown Source:5656) io.dcloud.e.c.c.dispatchEvent(Unknown Source:20) io.dcloud.e.b.a.processEvent(Unknown Source:2) io.dcloud.e.b.e.a(Unknown Source:802) io.dcloud.e.b.e.f(Unknown Source:31) io.dcloud.e.b.a.a(Unknown Source:174) io.dcloud.e.b.a.a(Unknown Source:3) io.dcloud.e.b.a$h.onCallBack(Unknown Source:11) io.dcloud.e.b.e.a(Unknown Source:756) io.dcloud.e.b.a.a(Unknown Source:130) io.dcloud.e.b.a.processEvent(Unknown Source:1823) io.dcloud.e.c.c.dispatchEvent(Unknown Source:26) io.dcloud.e.c.c.a(Unknown Source:143) io.dcloud.e.c.c.a(Unknown Source:111) io.dcloud.e.c.c$b.onExecuteEnd(Unknown Source:1) io.dcloud.common.adapter.util.AsyncTaskHandler$1$1.run(Unknown Source:1) android.os.Handler.handleCallback(Handler.java:883) android.os.Handler.dispatchMessage(Handler.java:100) android.os.Looper.loop(Looper.java:214) android.app.ActivityThread.main(ActivityThread.java:7707) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:1650) java.lang.reflect.Method.invoke(Native Method) io.dcloud.common.adapter.util.PlatformUtil.invokeMethod(Unknown Source:6) io.dcloud.common.adapter.util.PlatformUtil.invokeMethod(Unknown Source:2) io.dcloud.common.util.TelephonyUtil.getMultiIMEI(Unknown Source:33) io.dcloud.common.util.TelephonyUtil.updateIMEI(Unknown Source:3) io.dcloud.common.adapter.util.DeviceInfo.initGsmCdmaCell(Unknown Source:11) io.dcloud.g.b.a(Unknown Source:35) io.dcloud.g.b.a(Unknown Source:3) io.dcloud.g.b.processEvent(Unknown Source:165) io.dcloud.e.c.c.dispatchEvent(Unknown Source:22) io.dcloud.common.core.ui.l.processEvent(Unknown Source:2) io.dcloud.common.core.ui.b.obtainPrePlusreadyJs(Unknown Source:2) io.dcloud.common.adapter.ui.webview.WebLoadEvent.reset(Unknown Source:1) io.dcloud.common.adapter.ui.webview.WebLoadEvent.<init>(Unknown Source:957) io.dcloud.common.adapter.ui.webview.SysWebView.init(Unknown Source:136) io.dcloud.common.adapter.ui.AdaWebview.init(Unknown Source:2) io.dcloud.common.core.ui.l.a(Unknown Source:661) io.dcloud.common.core.ui.l.processEvent(Unknown Source:5731) io.dcloud.common.core.ui.l.a(Unknown Source:159) io.dcloud.common.core.ui.l.processEvent(Unknown Source:5656) io.dcloud.e.c.c.dispatchEvent(Unknown Source:20) io.dcloud.e.b.a.processEvent(Unknown Source:2) io.dcloud.e.b.e.a(Unknown Source:802) io.dcloud.e.b.e.f(Unknown Source:31) io.dcloud.e.b.a.a(Unknown Source:174) io.dcloud.e.b.a.a(Unknown Source:3) io.dcloud.e.b.a$h.onCallBack(Unknown Source:11) io.dcloud.e.b.e.a(Unknown Source:756) io.dcloud.e.b.a.a(Unknown Source:130) io.dcloud.e.b.a.processEvent(Unknown Source:1823) io.dcloud.e.c.c.dispatchEvent(Unknown Source:26) io.dcloud.e.c.c.a(Unknown Source:143) io.dcloud.e.c.c.a(Unknown Source:111) io.dcloud.e.c.c$b.onExecuteEnd(Unknown Source:1) io.dcloud.common.adapter.util.AsyncTaskHandler$1$1.run(Unknown Source:1) android.os.Handler.handleCallback(Handler.java:883) android.os.Handler.dispatchMessage(Handler.java:100) android.os.Looper.loop(Looper.java:214) android.app.ActivityThread.main(ActivityThread.java:7707) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

需要先确认一下离线打包SDK的版本,如果版本不能确定,建议升级到最新版之后重新提测试一下。

已经升级到最新的Android-SDK@4.36.82272_20241127再扫描了

回复 4***@qq.com: 有结果麻烦回复一下

回复 DCloud_Android_zl: 没有变化,还是两次获取

回复 4***@qq.com: 发一下包

回复 4***@qq.com: 检测报告和调用堆栈都发一下

回复 DCloud_Android_zl: 链接:https://pan.baidu.com/s/1ds-Eu4wbDRnFolELp9VBjA 提取码:s3sq 附件传不了包麻烦在网盘拿一下

回复 DCloud_Android_zl: 请问有结果了吗

回复 4***@qq.com: 这个包加固之后我导致我这边部分情况不能确认,需要提供一个加固之前的包

回复 DCloud_Android_zl: 链接:https://pan.baidu.com/s/1FFm4EjtZXmwIwq0z9cecWA 提取码:ajsf 已上传未加固包,麻烦帮忙确认情况,十分感谢

回复 4***@qq.com: 你把检测平台给我发一下,我这边也提交一次检测。我看了一下逻辑,这个只会获取一次,我需要跟平台那边确认一下

回复 DCloud_Android_zl: 是爱加密的行为检测平台

回复 4***@qq.com: 你这边换个平台检测看一下有没有问题,如果没问题的话,可以按照其他平台的结果上架,还有问题的话把对应的检测平台发给我。目前各个应用市场都有自己的监测平台,可以去上面试一下。

在uni-app中使用数字天堂SDK时,如果在授权行为前获取了两次IMEI(国际移动设备身份码),这通常意味着SDK的初始化或调用逻辑存在问题。IMEI作为敏感信息,应谨慎处理并确保只在用户授权后获取。以下是一个简化的代码示例,展示了如何在uni-app中正确地初始化数字天堂SDK,并在用户授权后获取IMEI。

首先,确保你已经在项目中引入了数字天堂SDK,并配置了必要的权限。

// main.js 或 app.js 文件中初始化SDK
import天堂SDK from 'path/to/heaven-sdk'; // 假设数字天堂SDK的引入路径

const sdk = new 天堂SDK({
  // SDK初始化所需的配置参数
  appId: 'your-app-id',
  appKey: 'your-app-key',
});

// 检查并请求权限(这里以Android为例,iOS类似处理)
#ifdef APP-PLUS
plus.android.requestPermissions(['android.permission.READ_PHONE_STATE'], function(event) {
  if (event.deniedAlways.length > 0 || event.denied.length > 0) {
    console.error('权限申请被拒绝');
  } else {
    console.log('权限申请成功');
    // 在这里调用获取IMEI的方法
    getIMEI();
  }
});
#endif

// 获取IMEI的方法
function getIMEI() {
  #ifdef APP-PLUS
  const context = plus.android.importClass('android.content.Context');
  const telephonyManager = plus.android.runtimeMainActivity().getSystemService(context.TELEPHONY_SERVICE);
  let imei = null;
  if (plus.android.apiLevel() >= 29) { // Android 10及以上版本
    // 需要额外的权限处理或使用替代方案获取设备唯一标识
    imei = telephonyManager.getImei(); // 注意:此方法在Android 10及以上可能返回null或空字符串
    if (!imei) {
      // 尝试其他方法获取唯一标识,如Settings.Secure.ANDROID_ID
      imei = plus.android.importClass('android.provider.Settings.Secure').getString(plus.android.runtimeMainActivity().getContentResolver(), 'android_id');
    }
  } else {
    imei = telephonyManager.getDeviceId();
  }
  console.log('IMEI:', imei);
  #endif
}

注意:

  1. 上述代码示例中,plus.android.requestPermissions 用于请求读取电话状态权限,这是获取IMEI所必需的。
  2. 在Android 10及以上版本中,直接获取IMEI可能受限,需要使用替代方案,如Settings.Secure.ANDROID_ID
  3. 确保在调用获取IMEI的方法前已经获得了用户授权,否则可能会返回null或空字符串。
  4. 实际应用中,应妥善处理用户拒绝授权的情况,避免应用崩溃或提供降级功能。

请根据数字天堂SDK的具体文档调整初始化参数和方法调用,以确保代码的正确性和安全性。

回到顶部