Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android 11 TelephonyManager.getDeviceId() #105

Open
hljdrl opened this issue Dec 29, 2020 · 9 comments
Open

android 11 TelephonyManager.getDeviceId() #105

hljdrl opened this issue Dec 29, 2020 · 9 comments

Comments

@hljdrl
Copy link

hljdrl commented Dec 29, 2020

适配android 11 和android 10发现 StatsLogReport有调用 TelephonyManager.getDeviceId(),app直接崩溃

@colorxiang
Copy link

请问解决了 我也遇到这个问题了 金山这边也联系不上。

@edmundsiah81
Copy link

有解决方案吗?

@xiaolong125
Copy link

targetSdkVersion 改成28吧,这个库几年没更新,估计停止维护了

@SpielbergGao
Copy link

字节码插桩直接把方法替换成自己的

@lgl772384055
Copy link

解决方案: 会报错的位置class文件替换掉
1.创建一个maven项目修改class文件

 <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/android-4.1.1.4.jar</systemPath>
            <!--systemPath 指定本地路径,从mvn中下载jar回来比较快-->
        </dependency>

2.编写修改代码

public class Test {
  public static void main(String[] args) throws Exception{

      javassist.ClassPool pool = javassist.ClassPool.getDefault();
      //TODO 指定本地ksylive.jar路径
      pool.insertClassPath("xxxx/ksylive.jar");
      //第一个修改的class
      {
          //覆盖sendRecordJson,避免因为高版本 没有org.apache.http.legacy 报错
          CtClass cc = pool.get("com.ksy.statlibrary.log.LogClient");
          CtMethod method = cc.getDeclaredMethod("sendRecordJson");//取得需要修改的方法
          method.setBody("{}"); //修改方法
          cc.writeFile("D:/test");//生成class的保存路径
      }

     //第二个需要改的class
      {
          //修改a私有方法,让权限校验不通过,进而避免获取deviceId
          javassist.CtClass cc = pool.get("com.ksyun.media.player.util.c");//加载指定的类
          javassist.CtClass[] params = new javassist.CtClass[] { pool.get("android.content.Context")
                  ,pool.get("java.lang.String") };
          javassist.CtMethod method = cc.getDeclaredMethod("a",params);//取得需要修改的方法
          method.setBody("{ return false;}");  //修改方法
          cc.writeFile("D:/test");//生成class的保存路径
      }
  }
}

3.使用压缩软件打开 ksylive.jar, 将 D:/test 中生成的class替换掉 ksylive.jar对应目录下的class文件
4. 报错问题解决完毕

@yuanpan66
Copy link

pool.get("android.content.Context") 这个方法出错Exception in thread "main" javassist.NotFoundException: android.content.Context

@lgl772384055
Copy link

lgl772384055 commented Nov 16, 2023

pool.get("android.content.Context") 这个方法出错Exception in thread "main" javassist.NotFoundException: android.content.Context
安卓sdk包没引入

<dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>4.1.1.4</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/android-4.1.1.4.jar</systemPath> <!--systemPath 指定本地路径,从mvn中下载jar回来比较快--> <!--从这里下回来 https://mvnrepository.com/artifact/com.google.android/android/4.1.1.4 jar放到 resources/lib/android-4.1.1.4.jar 这个目录下 --> </dependency>

@yuanpan66
Copy link

放到目录了还是报错。 能把编译好的文件发下么

@lgl772384055
Copy link

lgl772384055 commented Nov 16, 2023

com.zip

编译后的class文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants