一、缘由:
使用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