refactor(device): 重构设备信息修改逻辑并集成ArmCloud API

- 将设备信息修改的硬编码字符串替换为常量。
- `changeDeviceInfo` 方法现在接收 `ArmCloudApiClient` 和 `padCodes` 作为参数。
- 优化了Bigo和AF设备信息的处理逻辑,当对应的 `bigoDeviceObject` 或 `afDeviceObject` 为空时,会跳过相关设置并记录警告。
- 对于AF设备信息的系统属性修改,现在使用 `ArmCloudApiClient` 的 `updateInstanceProperties` 方法进行更新,替代了原有的 `ShellUtils.execRootCmd` 调用。
- 新增 `addProperty` 辅助方法,用于向 `List<PropertyItem>` 中添加非空属性。
- 新增 `execRootCmdIfNotEmpty` 辅助方法,用于执行非空的Shell命令并记录结果。
- 移除了直接通过 `ShellUtils.execRootCmd` 修改系统属性的代码,例如 `setprop ro.product.brand` 等。
- 确保在发生错误时抛出原始异常类型,而不是统一包装成 `RuntimeException`。
This commit is contained in:
yjj38 2025-07-09 18:36:26 +08:00
parent 2a7132d7b0
commit 6b507223b3
1 changed files with 184 additions and 219 deletions

View File

@ -6,8 +6,10 @@ import static com.example.retention.utils.LogFileUtil.logAndWrite;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.example.retention.device.ArmCloudApiClient.PropertyItem;
import com.example.retention.task.AfInfo; import com.example.retention.task.AfInfo;
import com.example.retention.task.BigoInfo; import com.example.retention.task.BigoInfo;
import com.example.retention.task.DeviceInfo; import com.example.retention.task.DeviceInfo;
@ -21,6 +23,9 @@ import com.example.retention.utils.ZipUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -280,239 +285,199 @@ public class ChangeDeviceInfoUtil {
} }
public static void changeDeviceInfo(String current_pkg_name, Context context) { public static void changeDeviceInfo(String current_pkg_name, Context context, ArmCloudApiClient client, String[] padCodes) {
final String B_PREFIX = current_pkg_name + ".";
final String U_PREFIX = current_pkg_name + "_";
BigoInfo bigoDevice;
if (bigoDeviceObject != null) { if (bigoDeviceObject != null) {
// BIGO // BIGO
String cpuClockSpeed = bigoDeviceObject.optString("cpu_clock_speed"); BigoInfo bigoDevice = new BigoInfo();
String gaid = bigoDeviceObject.optString("gaid"); bigoDevice.cpuClockSpeed = bigoDeviceObject.optString("cpu_clock_speed");
String userAgent = bigoDeviceObject.optString("User-Agent"); bigoDevice.gaid = bigoDeviceObject.optString("gaid");
String osLang = bigoDeviceObject.optString("os_lang"); bigoDevice.userAgent = bigoDeviceObject.optString("User-Agent");
String osVer = bigoDeviceObject.optString("os_ver"); bigoDevice.osLang = bigoDeviceObject.optString("os_lang");
String tz = bigoDeviceObject.optString("tz"); bigoDevice.osVer = bigoDeviceObject.optString("os_ver");
String systemCountry = bigoDeviceObject.optString("system_country"); bigoDevice.tz = bigoDeviceObject.optString("tz");
String simCountry = bigoDeviceObject.optString("sim_country"); bigoDevice.systemCountry = bigoDeviceObject.optString("system_country");
long romFreeIn = bigoDeviceObject.optLong("rom_free_in"); bigoDevice.simCountry = bigoDeviceObject.optString("sim_country");
String resolution = bigoDeviceObject.optString("resolution"); bigoDevice.romFreeIn = bigoDeviceObject.optLong("rom_free_in");
String vendor = bigoDeviceObject.optString("vendor"); bigoDevice.resolution = bigoDeviceObject.optString("resolution");
int batteryScale = bigoDeviceObject.optInt("bat_scale"); bigoDevice.vendor = bigoDeviceObject.optString("vendor");
// String model = deviceObject.optString("model"); bigoDevice.batteryScale = bigoDeviceObject.optInt("bat_scale");
String net = bigoDeviceObject.optString("net"); bigoDevice.net = bigoDeviceObject.optString("net");
int dpi = bigoDeviceObject.optInt("dpi"); bigoDevice.dpi = bigoDeviceObject.optInt("dpi");
long romFreeExt = bigoDeviceObject.optLong("rom_free_ext"); bigoDevice.romFreeExt = bigoDeviceObject.optLong("rom_free_ext");
String dpiF = bigoDeviceObject.optString("dpi_f"); bigoDevice.dpiF = bigoDeviceObject.optString("dpi_f");
int cpuCoreNum = bigoDeviceObject.optInt("cpu_core_num"); bigoDevice.cpuCoreNum = bigoDeviceObject.optInt("cpu_core_num");
bigoDevice = new BigoInfo();
bigoDevice.cpuClockSpeed = cpuClockSpeed;
bigoDevice.gaid = gaid;
bigoDevice.userAgent = userAgent;
bigoDevice.osLang = osLang;
bigoDevice.osVer = osVer;
bigoDevice.tz = tz;
bigoDevice.systemCountry = systemCountry;
bigoDevice.simCountry = simCountry;
bigoDevice.romFreeIn = romFreeIn;
bigoDevice.resolution = resolution;
bigoDevice.vendor = vendor;
bigoDevice.batteryScale = batteryScale;
bigoDevice.net = net;
bigoDevice.dpi = dpi;
bigoDevice.romFreeExt = romFreeExt;
bigoDevice.dpiF = dpiF;
bigoDevice.cpuCoreNum = cpuCoreNum;
TaskUtil.setBigoDevice(bigoDevice); TaskUtil.setBigoDevice(bigoDevice);
try { try {
callVCloudSettings_put(current_pkg_name + ".system_country", systemCountry, context); Map<String, Object> bigoMap = new HashMap<>();
callVCloudSettings_put(current_pkg_name + ".sim_country", simCountry, context); bigoMap.put(B_PREFIX + "system_country", bigoDevice.systemCountry);
callVCloudSettings_put(current_pkg_name + ".rom_free_in", String.valueOf(romFreeIn), context); bigoMap.put(B_PREFIX + "sim_country", bigoDevice.simCountry);
callVCloudSettings_put(current_pkg_name + ".resolution", resolution, context); bigoMap.put(B_PREFIX + "rom_free_in", String.valueOf(bigoDevice.romFreeIn));
callVCloudSettings_put(current_pkg_name + ".vendor", vendor, context); bigoMap.put(B_PREFIX + "resolution", bigoDevice.resolution);
callVCloudSettings_put(current_pkg_name + ".battery_scale", String.valueOf(batteryScale), context); bigoMap.put(B_PREFIX + "vendor", bigoDevice.vendor);
callVCloudSettings_put(current_pkg_name + ".os_lang", osLang, context); bigoMap.put(B_PREFIX + "battery_scale", String.valueOf(bigoDevice.batteryScale));
// callVCloudSettings_put(current_pkg_name + ".model", model, context); bigoMap.put(B_PREFIX + "os_lang", bigoDevice.osLang);
callVCloudSettings_put(current_pkg_name + ".net", net, context); bigoMap.put(B_PREFIX + "net", bigoDevice.net);
callVCloudSettings_put(current_pkg_name + ".dpi", String.valueOf(dpi), context); bigoMap.put(B_PREFIX + "dpi", String.valueOf(bigoDevice.dpi));
callVCloudSettings_put(current_pkg_name + ".rom_free_ext", String.valueOf(romFreeExt), context); bigoMap.put(B_PREFIX + "rom_free_ext", String.valueOf(bigoDevice.romFreeExt));
callVCloudSettings_put(current_pkg_name + ".dpi_f", dpiF, context); bigoMap.put(B_PREFIX + "dpi_f", bigoDevice.dpiF);
callVCloudSettings_put(current_pkg_name + ".cpu_core_num", String.valueOf(cpuCoreNum), context); bigoMap.put(B_PREFIX + "cpu_core_num", String.valueOf(bigoDevice.cpuCoreNum));
callVCloudSettings_put(current_pkg_name + ".cpu_clock_speed", cpuClockSpeed, context); bigoMap.put(B_PREFIX + "cpu_clock_speed", bigoDevice.cpuClockSpeed);
callVCloudSettings_put(current_pkg_name + "_gaid", gaid, context); bigoMap.put(current_pkg_name + "_gaid", bigoDevice.gaid);
// **User-Agent** bigoMap.put(current_pkg_name + "_user_agent", bigoDevice.userAgent);
callVCloudSettings_put(current_pkg_name + "_user_agent", userAgent, context); bigoMap.put(current_pkg_name + "_os_lang", bigoDevice.osLang);
// **os_lang**系统语言 bigoMap.put(current_pkg_name + "_os_ver", bigoDevice.osVer);
callVCloudSettings_put(current_pkg_name + "_os_lang", osLang, context); bigoMap.put(current_pkg_name + "_tz", bigoDevice.tz);
// **os_ver**
callVCloudSettings_put(current_pkg_name + "_os_ver", osVer, context); for (Map.Entry<String, Object> entry : bigoMap.entrySet()) {
// **tz** (时区) callVCloudSettings_put(entry.getKey(), entry.getValue().toString(), context);
callVCloudSettings_put(current_pkg_name + "_tz", tz, context); }
} catch (Throwable e) { } catch (Throwable e) {
logAndWrite(android.util.Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred while changing device info", e); logAndWrite(android.util.Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred while changing device info", e);
throw new RuntimeException("Error occurred in changeDeviceInfo", e); throw e; // 保留原始异常类型
} }
} else {
Log.w("ChangeDeviceInfoUtil", "bigoDeviceObject is null, skipping BIGO settings.");
} }
DeviceInfo deviceInfo;
AfInfo afDevice;
if (afDeviceObject != null) { if (afDeviceObject != null) {
String advertiserId = afDeviceObject.optString(".advertiserId"); AfInfo afDevice = new AfInfo();
String model = afDeviceObject.optString(".model"); afDevice.advertiserId = afDeviceObject.optString(".advertiserId");
String brand = afDeviceObject.optString(".brand"); afDevice.model = afDeviceObject.optString(".model");
String androidId = afDeviceObject.optString(".android_id"); afDevice.brand = afDeviceObject.optString(".brand");
int xPixels = afDeviceObject.optInt(".deviceData.dim.x_px"); afDevice.androidId = afDeviceObject.optString(".android_id");
int yPixels = afDeviceObject.optInt(".deviceData.dim.y_px"); afDevice.xPixels = afDeviceObject.optInt(".deviceData.dim.x_px");
int densityDpi = afDeviceObject.optInt(".deviceData.dim.d_dpi"); afDevice.yPixels = afDeviceObject.optInt(".deviceData.dim.y_px");
String country = afDeviceObject.optString(".country"); afDevice.densityDpi = afDeviceObject.optInt(".deviceData.dim.d_dpi");
String batteryLevel = afDeviceObject.optString(".batteryLevel"); afDevice.country = afDeviceObject.optString(".country");
String stackInfo = Thread.currentThread().getStackTrace()[2].toString(); afDevice.batteryLevel = afDeviceObject.optString(".batteryLevel");
String product = afDeviceObject.optString(".product"); afDevice.stackInfo = Thread.currentThread().getStackTrace()[2].toString();
String network = afDeviceObject.optString(".network"); afDevice.product = afDeviceObject.optString(".product");
String langCode = afDeviceObject.optString(".lang_code"); afDevice.network = afDeviceObject.optString(".network");
String cpuAbi = afDeviceObject.optString(".deviceData.cpu_abi"); afDevice.langCode = afDeviceObject.optString(".lang_code");
int yDp = afDeviceObject.optInt(".deviceData.dim.ydp"); afDevice.cpuAbi = afDeviceObject.optString(".deviceData.cpu_abi");
afDevice.yDp = afDeviceObject.optInt(".deviceData.dim.ydp");
afDevice = new AfInfo();
afDevice.advertiserId = advertiserId;
afDevice.model = model;
afDevice.brand = brand;
afDevice.androidId = androidId;
afDevice.xPixels = xPixels;
afDevice.yPixels = yPixels;
afDevice.densityDpi = densityDpi;
afDevice.country = country;
afDevice.batteryLevel = batteryLevel;
afDevice.stackInfo = stackInfo;
afDevice.product = product;
afDevice.network = network;
afDevice.langCode = langCode;
afDevice.cpuAbi = cpuAbi;
afDevice.yDp = yDp;
TaskUtil.setAfDevice(afDevice); TaskUtil.setAfDevice(afDevice);
String lang = afDeviceObject.optString(".lang"); DeviceInfo deviceInfo = new DeviceInfo();
String ro_product_brand = afDeviceObject.optString("ro.product.brand", ""); deviceInfo.lang = afDeviceObject.optString(".lang");
String ro_product_model = afDeviceObject.optString("ro.product.model", ""); deviceInfo.roProductBrand = afDeviceObject.optString("ro.product.brand", "");
String ro_product_manufacturer = afDeviceObject.optString("ro.product.manufacturer", ""); deviceInfo.roProductModel = afDeviceObject.optString("ro.product.model", "");
String ro_product_device = afDeviceObject.optString("ro.product.device", ""); deviceInfo.roProductManufacturer = afDeviceObject.optString("ro.product.manufacturer", "");
String ro_product_name = afDeviceObject.optString("ro.product.name", ""); deviceInfo.roProductDevice = afDeviceObject.optString("ro.product.device", "");
String ro_build_version_incremental = afDeviceObject.optString("ro.build.version.incremental", ""); deviceInfo.roProductName = afDeviceObject.optString("ro.product.name", "");
String ro_build_fingerprint = afDeviceObject.optString("ro.build.fingerprint", ""); deviceInfo.roBuildVersionIncremental = afDeviceObject.optString("ro.build.version.incremental", "");
String ro_odm_build_fingerprint = afDeviceObject.optString("ro.odm.build.fingerprint", ""); deviceInfo.roBuildFingerprint = afDeviceObject.optString("ro.build.fingerprint", "");
String ro_product_build_fingerprint = afDeviceObject.optString("ro.product.build.fingerprint", ""); deviceInfo.roOdmBuildFingerprint = afDeviceObject.optString("ro.odm.build.fingerprint", "");
String ro_system_build_fingerprint = afDeviceObject.optString("ro.system.build.fingerprint", ""); deviceInfo.roProductBuildFingerprint = afDeviceObject.optString("ro.product.build.fingerprint", "");
String ro_system_ext_build_fingerprint = afDeviceObject.optString("ro.system_ext.build.fingerprint", ""); deviceInfo.roSystemBuildFingerprint = afDeviceObject.optString("ro.system.build.fingerprint", "");
String ro_vendor_build_fingerprint = afDeviceObject.optString("ro.vendor.build.fingerprint", ""); deviceInfo.roSystemExtBuildFingerprint = afDeviceObject.optString("ro.system_ext.build.fingerprint", "");
String ro_build_platform = afDeviceObject.optString("ro.board.platform", ""); deviceInfo.roVendorBuildFingerprint = afDeviceObject.optString("ro.vendor.build.fingerprint", "");
String persist_sys_cloud_drm_id = afDeviceObject.optString("persist.sys.cloud.drm.id", ""); deviceInfo.roBuildPlatform = afDeviceObject.optString("ro.board.platform", "");
int persist_sys_cloud_battery_capacity = afDeviceObject.optInt("persist.sys.cloud.battery.capacity", -1); deviceInfo.persistSysCloudDrmId = afDeviceObject.optString("persist.sys.cloud.drm.id", "");
String persist_sys_cloud_gpu_gl_vendor = afDeviceObject.optString("persist.sys.cloud.gpu.gl_vendor", ""); deviceInfo.persistSysCloudBatteryCapacity = afDeviceObject.optInt("persist.sys.cloud.battery.capacity", -1);
String persist_sys_cloud_gpu_gl_renderer = afDeviceObject.optString("persist.sys.cloud.gpu.gl_renderer", ""); deviceInfo.persistSysCloudGpuGlVendor = afDeviceObject.optString("persist.sys.cloud.gpu.gl_vendor", "");
String persist_sys_cloud_gpu_gl_version = afDeviceObject.optString("persist.sys.cloud.gpu.gl_version", ""); deviceInfo.persistSysCloudGpuGlRenderer = afDeviceObject.optString("persist.sys.cloud.gpu.gl_renderer", "");
String persist_sys_cloud_gpu_egl_vendor = afDeviceObject.optString("persist.sys.cloud.gpu.egl_vendor", ""); deviceInfo.persistSysCloudGpuGlVersion = afDeviceObject.optString("persist.sys.cloud.gpu.gl_version", "");
String persist_sys_cloud_gpu_egl_version = afDeviceObject.optString("persist.sys.cloud.gpu.egl_version", ""); deviceInfo.persistSysCloudGpuEglVendor = afDeviceObject.optString("persist.sys.cloud.gpu.egl_vendor", "");
String global_android_id = afDeviceObject.optString(".android_id", ""); deviceInfo.persistSysCloudGpuEglVersion = afDeviceObject.optString("persist.sys.cloud.gpu.egl_version", "");
String anticheck_pkgs = afDeviceObject.optString(".anticheck_pkgs", "");
String pm_list_features = afDeviceObject.optString(".pm_list_features", "");
String pm_list_libraries = afDeviceObject.optString(".pm_list_libraries", "");
String system_http_agent = afDeviceObject.optString("system.http.agent", "");
String webkit_http_agent = afDeviceObject.optString("webkit.http.agent", "");
String com_fk_tools_pkgInfo = afDeviceObject.optString(".pkg_info", "");
String appsflyerKey = afDeviceObject.optString(".appsflyerKey", "");
String appUserId = afDeviceObject.optString(".appUserId", "");
String disk = afDeviceObject.optString(".disk", "");
String operator = afDeviceObject.optString(".operator", "");
String cell_mcc = afDeviceObject.optString(".cell.mcc", "");
String cell_mnc = afDeviceObject.optString(".cell.mnc", "");
String date1 = afDeviceObject.optString(".date1", "");
String date2 = afDeviceObject.optString(".date2", "");
String bootId = afDeviceObject.optString("BootId", "");
deviceInfo = new DeviceInfo();
deviceInfo.lang = lang;
deviceInfo.roProductBrand = ro_product_brand;
deviceInfo.roProductModel = ro_product_model;
deviceInfo.roProductManufacturer = ro_product_manufacturer;
deviceInfo.roProductDevice = ro_product_device;
deviceInfo.roProductName = ro_product_name;
deviceInfo.roBuildVersionIncremental = ro_build_version_incremental;
deviceInfo.roBuildFingerprint = ro_build_fingerprint;
deviceInfo.roOdmBuildFingerprint = ro_odm_build_fingerprint;
deviceInfo.roProductBuildFingerprint = ro_product_build_fingerprint;
deviceInfo.roSystemBuildFingerprint = ro_system_build_fingerprint;
deviceInfo.roSystemExtBuildFingerprint = ro_system_ext_build_fingerprint;
deviceInfo.roVendorBuildFingerprint = ro_vendor_build_fingerprint;
deviceInfo.roBuildPlatform = ro_build_platform;
deviceInfo.persistSysCloudDrmId = persist_sys_cloud_drm_id;
deviceInfo.persistSysCloudBatteryCapacity = persist_sys_cloud_battery_capacity;
deviceInfo.persistSysCloudGpuGlVendor = persist_sys_cloud_gpu_gl_vendor;
deviceInfo.persistSysCloudGpuGlRenderer = persist_sys_cloud_gpu_gl_renderer;
deviceInfo.persistSysCloudGpuGlVersion = persist_sys_cloud_gpu_gl_version;
deviceInfo.persistSysCloudGpuEglVendor = persist_sys_cloud_gpu_egl_vendor;
deviceInfo.persistSysCloudGpuEglVersion = persist_sys_cloud_gpu_egl_version;
TaskUtil.setDeviceInfo(deviceInfo); TaskUtil.setDeviceInfo(deviceInfo);
try { try {
callVCloudSettings_put(current_pkg_name + ".advertiserId", advertiserId, context); Map<String, Object> afMap = new HashMap<>();
callVCloudSettings_put(current_pkg_name + ".model", model, context); afMap.put(B_PREFIX + "advertiserId", afDevice.advertiserId);
callVCloudSettings_put(current_pkg_name + ".brand", brand, context); afMap.put(B_PREFIX + "model", afDevice.model);
callVCloudSettings_put(current_pkg_name + ".android_id", androidId, context); afMap.put(B_PREFIX + "brand", afDevice.brand);
callVCloudSettings_put(current_pkg_name + ".lang", lang, context); afMap.put(B_PREFIX + "android_id", afDevice.androidId);
callVCloudSettings_put(current_pkg_name + ".country", country, context); afMap.put(B_PREFIX + "lang", afDevice.langCode);
callVCloudSettings_put(current_pkg_name + ".batteryLevel", batteryLevel, context); afMap.put(B_PREFIX + "country", afDevice.country);
callVCloudSettings_put(current_pkg_name + "_screen.optMetrics.stack", stackInfo, context); afMap.put(B_PREFIX + "batteryLevel", afDevice.batteryLevel);
callVCloudSettings_put(current_pkg_name + ".product", product, context); afMap.put(B_PREFIX + "screen.optMetrics.stack", afDevice.stackInfo);
callVCloudSettings_put(current_pkg_name + ".network", network, context); afMap.put(B_PREFIX + "product", afDevice.product);
callVCloudSettings_put(current_pkg_name + ".cpu_abi", cpuAbi, context); afMap.put(B_PREFIX + "network", afDevice.network);
callVCloudSettings_put(current_pkg_name + ".lang_code", langCode, context); afMap.put(B_PREFIX + "cpu_abi", afDevice.cpuAbi);
// **广告标识符 (advertiserId)** **启用状态** afMap.put(B_PREFIX + "lang_code", afDevice.langCode);
boolean isAdIdEnabled = true; // 默认启用广告 ID
callVCloudSettings_put(current_pkg_name + ".advertiserIdEnabled", String.valueOf(isAdIdEnabled), context); for (Map.Entry<String, Object> entry : afMap.entrySet()) {
callVCloudSettings_put(entry.getKey(), entry.getValue().toString(), context);
}
callVCloudSettings_put(current_pkg_name + ".advertiserIdEnabled", "true", context);
JSONObject displayMetrics = new JSONObject(); JSONObject displayMetrics = new JSONObject();
displayMetrics.put("widthPixels", afDevice.xPixels);
displayMetrics.put("widthPixels", xPixels); displayMetrics.put("heightPixels", afDevice.yPixels);
displayMetrics.put("densityDpi", afDevice.densityDpi);
displayMetrics.put("heightPixels", yPixels); displayMetrics.put("yDp", afDevice.yDp);
displayMetrics.put("densityDpi", densityDpi);
displayMetrics.put("yDp", yDp);
callVCloudSettings_put("screen.device.displayMetrics", displayMetrics.toString(), context); callVCloudSettings_put("screen.device.displayMetrics", displayMetrics.toString(), context);
if (!ShellUtils.hasRootAccess()) { // 使用 ArmCloud API 设置系统属性
LogFileUtil.writeLogToFile("ERROR", "ChangeDeviceInfoUtil", "Root access is required to execute system property changes"); List<PropertyItem> systemProps = new ArrayList<>();
}
// 设置机型, 直接设置属性 addProperty(systemProps, "ro.product.brand", deviceInfo.roProductBrand);
ShellUtils.execRootCmd("setprop ro.product.brand " + ro_product_brand); addProperty(systemProps, "ro.product.model", deviceInfo.roProductModel);
ShellUtils.execRootCmd("setprop ro.product.model " + ro_product_model); addProperty(systemProps, "ro.product.manufacturer", deviceInfo.roProductManufacturer);
ShellUtils.execRootCmd("setprop ro.product.manufacturer " + ro_product_manufacturer); addProperty(systemProps, "ro.product.device", deviceInfo.roProductDevice);
ShellUtils.execRootCmd("setprop ro.product.device " + ro_product_device); addProperty(systemProps, "ro.product.name", deviceInfo.roProductName);
ShellUtils.execRootCmd("setprop ro.product.name " + ro_product_name); addProperty(systemProps, "ro.build.version.incremental", deviceInfo.roBuildVersionIncremental);
ShellUtils.execRootCmd("setprop ro.build.version.incremental " + ro_build_version_incremental); addProperty(systemProps, "ro.build.fingerprint", deviceInfo.roBuildFingerprint);
ShellUtils.execRootCmd("setprop ro.build.fingerprint " + ro_build_fingerprint); addProperty(systemProps, "ro.odm.build.fingerprint", deviceInfo.roOdmBuildFingerprint);
ShellUtils.execRootCmd("setprop ro.odm.build.fingerprint " + ro_odm_build_fingerprint); addProperty(systemProps, "ro.product.build.fingerprint", deviceInfo.roProductBuildFingerprint);
ShellUtils.execRootCmd("setprop ro.product.build.fingerprint " + ro_product_build_fingerprint); addProperty(systemProps, "ro.system.build.fingerprint", deviceInfo.roSystemBuildFingerprint);
ShellUtils.execRootCmd("setprop ro.system.build.fingerprint " + ro_system_build_fingerprint); addProperty(systemProps, "ro.system_ext.build.fingerprint", deviceInfo.roSystemExtBuildFingerprint);
ShellUtils.execRootCmd("setprop ro.system_ext.build.fingerprint " + ro_system_ext_build_fingerprint); addProperty(systemProps, "ro.vendor.build.fingerprint", deviceInfo.roVendorBuildFingerprint);
ShellUtils.execRootCmd("setprop ro.vendor.build.fingerprint " + ro_vendor_build_fingerprint); addProperty(systemProps, "ro.board.platform", deviceInfo.roBuildPlatform);
ShellUtils.execRootCmd("setprop ro.board.platform " + ro_build_platform);
// 调用接口更新实例属性
try {
String response = client.updateInstanceProperties(
padCodes,
null, // modemPersistProps
null, // modemProps
null, // systemPersistProps
systemProps,
null, // settingProps
null // oaidProps
);
Log.d("ChangeDeviceInfoUtil", "updateInstanceProperties response: " + response);
} catch (IOException e) {
Log.e("ChangeDeviceInfoUtil", "Failed to update instance properties", e);
}
// Native.setBootId(bootId);
// 修改drm id
ShellUtils.execRootCmd("setprop persist.sys.cloud.drm.id " + persist_sys_cloud_drm_id);
// 电量模拟需要大于1000
ShellUtils.execRootCmd("setprop persist.sys.cloud.battery.capacity " + persist_sys_cloud_battery_capacity);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_vendor " + persist_sys_cloud_gpu_gl_vendor);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_renderer " + persist_sys_cloud_gpu_gl_renderer);
// 这个值不能随便改 必须是 OpenGL ES %d.%d 这个格式
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_version " + persist_sys_cloud_gpu_gl_version);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor " + persist_sys_cloud_gpu_egl_vendor);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version " + persist_sys_cloud_gpu_egl_version);
} catch (Throwable e) { } catch (Throwable e) {
logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred in changeDeviceInfo", e); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred in changeDeviceInfo", e);
throw new RuntimeException("Error occurred in changeDeviceInfo", e); }
} else {
Log.w("ChangeDeviceInfoUtil", "afDeviceObject is null, skipping AF settings.");
}
}
private static void addProperty(List<PropertyItem> list, String name, String value) {
if (value != null && !value.isEmpty()) {
list.add(new PropertyItem(name, value));
}
}
private static void execRootCmdIfNotEmpty(String cmd, String value) {
if (value != null && !value.isEmpty()) {
String result = ShellUtils.execRootCmdAndGetResult(cmd + value);
if (result == null) {
Log.e("ChangeDeviceInfoUtil", "Failed to execute shell command: " + cmd + value + ", result was empty or null.");
} else {
Log.d("ChangeDeviceInfoUtil", "Successfully executed command: " + cmd + value + ", output: " + result);
} }
} }
} }
private static void callVCloudSettings_put(String key, String value, Context context) { private static void callVCloudSettings_put(String key, String value, Context context) {
if (context == null) { if (context == null) {
logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Context cannot be null", null); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Context cannot be null", null);