android build类分析 hook静态字段

本文深入探讨了Android系统中Build类获取系统信息的流程,包括静态字段如DEVICE, MODEL, VERSION等的获取。分析了Build类源码、Systemproperties类的native方法以及属性系统的运作机制。在尝试使用Xposed和反射Hook失败后,成功利用Xposed框架hook Systemproperties的get()方法,实现对Build类静态字段的Hook。" 70808991,5612996,Mysql事务与隔离级别详解,"['数据库', 'Mysql', '事务处理', '数据库理论', '隔离级别']
摘要由CSDN通过智能技术生成

一、缘由:
使用xposed hook build类下 DEVICE MODEL VERSION MANUFACTURER等静态字段

使用XposedHelpers.setStaticObjectField() hook 失败!

XposedHelpers.setStaticObjectField(android.os.Build.class, "MODEL", null);

使用 反射 hook 失败!

 Field model = Build.class.getDeclaredField("MODEL");
 model.setAccessible(true);
 model.set(Build.class, pre.getString("model", null));

二、Build源码分析
打开build源码(/frameworks/base/core/Java/android/os/Build.java)
Build类中主要是一些成员属性

public class Build {
   
    /** Value used for when a build property is unknown. */
    public static final String UNKNOWN = "unknown";

    /** Either a changelist number, or a label like "M4-rc20". */
    public static final String ID = getString("ro.build.id");

    /** A build ID string meant for displaying to the user */
    public static final String DISPLAY = getString("ro.build.display.id");

    /** The name of the overall product. */
    public static final String PRODUCT = getString("ro.product.name");

    /** The name of the industrial design. */
    public static final String DEVICE = getString("ro.product.device");

    /** The name of the underlying board, like "goldfish". */
    public static final String BOARD = getString("ro.product.board");

    /** The name of the instruction set (CPU type + ABI convention) of native code. */
    public static final String CPU_ABI = getString("ro.product.cpu.abi");

    /** The name of the second instruction set (CPU type + ABI convention) of native code. */
    public static final String CPU_ABI2 = getString("ro.product.cpu.abi2");

    /** The manufacturer of the product/hardware. */
    public static final String MANUFACTURER = getString("ro.product.manufacturer");

    /** The brand (e.g., carrier) the software is customized for, if any. */
    public 
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值