Dynamically fetch and apply device properties from API responses

Implemented dynamic retrieval of device properties from external APIs, parsing JSON responses, and replacing statically hardcoded values. Enhanced flexibility for device information management. Added error handling for JSON parsing and root access validation.
This commit is contained in:
yjj38 2025-06-10 11:45:44 +08:00
parent d2661f8fdb
commit c746633baf
2 changed files with 312 additions and 247 deletions

View File

@ -7,10 +7,12 @@ import android.net.Network;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.util.Log; import android.util.Log;
import com.example.studyapp.utils.HttpUtil;
import com.example.studyapp.utils.ShellUtils; import com.example.studyapp.utils.ShellUtils;
import com.google.android.gms.ads.identifier.AdvertisingIdClient; import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -18,293 +20,355 @@ import java.lang.reflect.Method;
public class ChangeDeviceInfoUtil { public class ChangeDeviceInfoUtil {
public static void changeDeviceInfo(String current_pkg_name,Context context) { private static final String BIGO_URL = "http://8.217.137.25/tt/zj/dispatcher!bigo.do?country=US&tag=2";
// 指定包名优先级高于全局 private static final JSONObject bigoDeviceObject;
callVCloudSettings_put(current_pkg_name + "_android_id", "my123456",context);
callVCloudSettings_put(current_pkg_name + "_screen_brightness", "100",context);
callVCloudSettings_put(current_pkg_name + "_adb_enabled", "1",context);
callVCloudSettings_put(current_pkg_name + "_development_settings_enabled", "1",context);
callVCloudSettings_put("pm_list_features", "my_pm_list_features",context); private static final String AF_URL = "http://8.217.137.25/tt/zj/dispatcher!bigo.do?country=US&tag=2";
callVCloudSettings_put("pm_list_libraries", "my_pm_list_libraries",context); private static final JSONObject afDeviceObject;
callVCloudSettings_put("system.http.agent", "my_system.http.agent",context);
callVCloudSettings_put("webkit.http.agent", "my_webkit.http.agent",context);
callVCloudSettings_put("global_android_id", "123456",context); static {
try {
callVCloudSettings_put("anticheck_pkgs", current_pkg_name,context); // 请求接口并获取 JSON
String bigoJson = HttpUtil.requestGet(BIGO_URL);
try { final String afJson = HttpUtil.requestGet(AF_URL);
// 解析 JSON 字符串
JSONObject pkg_info_json = new JSONObject(); JSONObject bigoObject = new JSONObject(bigoJson);
pkg_info_json.put("versionName", "1.0.0"); bigoDeviceObject = bigoObject.optJSONObject("device");
pkg_info_json.put("versionCode", 100); JSONObject afObject = new JSONObject(bigoJson);
pkg_info_json.put("firstInstallTime", 1); afDeviceObject = bigoObject.optJSONObject("device");
pkg_info_json.put("lastUpdateTime", 1); if (bigoDeviceObject == null) {
callVCloudSettings_put("com.fk.tools_pkgInfo", pkg_info_json.toString(),context); throw new JSONException("Device object is missing in the bigo response JSON");
}
JSONObject tmp_json = new JSONObject(); if (afDeviceObject == null) {
tmp_json.put("widthPixels", 1080); throw new JSONException("Device object is missing in the af response JSON");
tmp_json.put("heightPixels", 1920); }
tmp_json.put("densityDpi", 440); Log.d("Debug", "bigoDeviceObject: " + bigoDeviceObject.toString());
tmp_json.put("xdpi", 160); Log.d("Debug", "afDeviceObject: " + afDeviceObject.toString());
tmp_json.put("ydpi", 160); } catch (Exception e) {
tmp_json.put("density", 3.0); throw new IllegalStateException("Failed to load or parse the response JSON", e);
tmp_json.put("scaledDensity", 3.0); }
callVCloudSettings_put("screen.getDisplayMetrics", tmp_json.toString(),context); }
callVCloudSettings_put("screen.getMetrics", tmp_json.toString(),context);
callVCloudSettings_put("screen.getRealMetrics", tmp_json.toString(),context);
callVCloudSettings_put(current_pkg_name + "_screen.getDisplayMetrics.stack", ".getDeviceInfo",context);
String stackInfo = Thread.currentThread().getStackTrace()[2].toString();
callVCloudSettings_put(current_pkg_name + "_screen.getMetrics.stack", stackInfo, context);
callVCloudSettings_put(current_pkg_name + "_screen.getRealMetrics.stack", ".getDeviceInfo",context);
tmp_json = new JSONObject(); public static void changeDeviceInfo(String current_pkg_name, Context context) {
tmp_json.put("width", 1080);
tmp_json.put("height", 1820); try {
callVCloudSettings_put("screen.getRealSize", tmp_json.toString(),context); // 动态读取 JSON 中的值
callVCloudSettings_put(current_pkg_name + "_screen.getRealSize.stack", ".getDeviceInfo",context); String cpuClockSpeed = bigoDeviceObject.getString("cpu_clock_speed");
// String country = bigoDeviceObject.getString("country");
String gaid = bigoDeviceObject.getString("gaid");
String userAgent = bigoDeviceObject.getString("User-Agent");
String osLang = bigoDeviceObject.getString("os_lang");
String osVer = bigoDeviceObject.getString("os_ver");
// String model = bigoDeviceObject.getString("model");
String tz = bigoDeviceObject.getString("tz");
// 动态读取 JSON 中的值
String advertiserId = afDeviceObject.getString(".advertiserId");
String model = afDeviceObject.getString(".model");
String brand = afDeviceObject.getString(".brand");
String androidId = afDeviceObject.getString(".android_id");
int xPixels = afDeviceObject.optInt(".deviceData.dim.x_px");
int yPixels = afDeviceObject.optInt(".deviceData.dim.y_px");
int densityDpi = afDeviceObject.optInt(".deviceData.dim.d_dpi");
String lang = afDeviceObject.getString(".lang");
String country = afDeviceObject.getString(".country");
String batteryLevel = afDeviceObject.getString(".batteryLevel");
// 替换写死的值为 JSON 动态值
callVCloudSettings_put(current_pkg_name + ".advertiserId", advertiserId, context);
callVCloudSettings_put(current_pkg_name + ".model", model, context);
callVCloudSettings_put(current_pkg_name + ".brand", brand, context);
callVCloudSettings_put(current_pkg_name + ".android_id", androidId, context);
JSONObject displayMetrics = new JSONObject();
displayMetrics.put("widthPixels", xPixels);
displayMetrics.put("heightPixels", yPixels);
displayMetrics.put("densityDpi", densityDpi);
callVCloudSettings_put("screen.getDisplayMetrics", displayMetrics.toString(), context);
callVCloudSettings_put(current_pkg_name + ".lang", lang, context);
callVCloudSettings_put(current_pkg_name + ".country", country, context);
callVCloudSettings_put(current_pkg_name + ".batteryLevel", batteryLevel, context);
Log.d("ChangeDeviceInfoUtil", "Device info successfully updated.");
tmp_json = new JSONObject(); // 指定包名优先级高于全局
tmp_json.put("left", 0); callVCloudSettings_put(current_pkg_name + "_android_id", "my123456", context);
tmp_json.put("top", 0); callVCloudSettings_put(current_pkg_name + "_screen_brightness", "100", context);
tmp_json.put("right", 1080); callVCloudSettings_put(current_pkg_name + "_adb_enabled", "1", context);
tmp_json.put("bottom", 1920); callVCloudSettings_put(current_pkg_name + "_development_settings_enabled", "1", context);
callVCloudSettings_put("screen.getCurrentBounds", tmp_json.toString(),context);
callVCloudSettings_put("screen.getMaximumBounds", tmp_json.toString(),context);
callVCloudSettings_put(current_pkg_name + "_screen.getCurrentBounds.stack", ".getDeviceInfo",context);
callVCloudSettings_put(current_pkg_name + "_screen.getMaximumBounds.stack", ".getDeviceInfo",context);
// **User-Agent** callVCloudSettings_put("pm_list_features", "my_pm_list_features", context);
String defaultUserAgent = System.getProperty("http.agent"); // 默认 User-Agent callVCloudSettings_put("pm_list_libraries", "my_pm_list_libraries", context);
callVCloudSettings_put(current_pkg_name + "_user_agent", defaultUserAgent, context); callVCloudSettings_put("system.http.agent", "my_system.http.agent", context);
callVCloudSettings_put("webkit.http.agent", "my_webkit.http.agent", context);
// **os_ver** callVCloudSettings_put("global_android_id", "123456", context);
String osVer = System.getProperty("os.version"); // 系统版本
callVCloudSettings_put(current_pkg_name + "_os_ver", osVer, context);
// **os_lang** callVCloudSettings_put("anticheck_pkgs", current_pkg_name, context);
String osLang = context.getResources().getConfiguration().locale.getLanguage(); // 系统语言
callVCloudSettings_put(current_pkg_name + "_os_lang", osLang, context);
// **dpi** JSONObject pkg_info_json = new JSONObject();
JSONObject densityJson = new JSONObject(); pkg_info_json.put("versionName", "1.0.0");
densityJson.put("density", context.getResources().getDisplayMetrics().density); pkg_info_json.put("versionCode", 100);
callVCloudSettings_put(current_pkg_name + "_dpi", densityJson.toString(), context); pkg_info_json.put("firstInstallTime", 1);
pkg_info_json.put("lastUpdateTime", 1);
callVCloudSettings_put("com.fk.tools_pkgInfo", pkg_info_json.toString(), context);
// **dpi_f** JSONObject tmp_json = new JSONObject();
JSONObject realResolutionJson = new JSONObject(); tmp_json.put("widthPixels", 1080);
realResolutionJson.put("width", 411); tmp_json.put("heightPixels", 1920);
realResolutionJson.put("height", 731); tmp_json.put("densityDpi", 440);
callVCloudSettings_put(current_pkg_name + "_dpi_f", realResolutionJson.toString(), context); tmp_json.put("xdpi", 160);
tmp_json.put("ydpi", 160);
tmp_json.put("density", 3.0);
tmp_json.put("scaledDensity", 3.0);
callVCloudSettings_put("screen.getDisplayMetrics", tmp_json.toString(), context);
callVCloudSettings_put("screen.getMetrics", tmp_json.toString(), context);
callVCloudSettings_put("screen.getRealMetrics", tmp_json.toString(), context);
callVCloudSettings_put(current_pkg_name + "_screen.getDisplayMetrics.stack", ".getDeviceInfo", context);
String stackInfo = Thread.currentThread().getStackTrace()[2].toString();
callVCloudSettings_put(current_pkg_name + "_screen.getMetrics.stack", stackInfo, context);
callVCloudSettings_put(current_pkg_name + "_screen.getRealMetrics.stack", ".getDeviceInfo", context);
// **tz** (时区) tmp_json = new JSONObject();
String tz = java.util.TimeZone.getDefault().getID(); // 系统时区 tmp_json.put("width", 1080);
callVCloudSettings_put(current_pkg_name + "_tz", tz, context); tmp_json.put("height", 1820);
callVCloudSettings_put("screen.getRealSize", tmp_json.toString(), context);
callVCloudSettings_put(current_pkg_name + "_screen.getRealSize.stack", ".getDeviceInfo", context);
// **isp** (网络运营商) tmp_json = new JSONObject();
android.telephony.TelephonyManager telephonyManager = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); tmp_json.put("left", 0);
String isp = telephonyManager != null ? telephonyManager.getNetworkOperatorName() : "unknown"; tmp_json.put("top", 0);
callVCloudSettings_put(current_pkg_name + "_isp", isp, context); tmp_json.put("right", 1080);
tmp_json.put("bottom", 1920);
callVCloudSettings_put("screen.getCurrentBounds", tmp_json.toString(), context);
callVCloudSettings_put("screen.getMaximumBounds", tmp_json.toString(), context);
callVCloudSettings_put(current_pkg_name + "_screen.getCurrentBounds.stack", ".getDeviceInfo", context);
callVCloudSettings_put(current_pkg_name + "_screen.getMaximumBounds.stack", ".getDeviceInfo", context);
// **net** (网络类型WiFi/流量) // **User-Agent**
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); callVCloudSettings_put(current_pkg_name + "_user_agent", userAgent, context);
if (connectivityManager != null) { // **os_ver**
Network activeNetwork = connectivityManager.getActiveNetwork(); callVCloudSettings_put(current_pkg_name + "_os_ver", osVer, context);
NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(activeNetwork);
String netType = "Unknown"; // **os_lang**系统语言
if (capabilities != null) { callVCloudSettings_put(current_pkg_name + "_os_lang", osLang, context);
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
netType = "WiFi";
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
netType = "Cellular";
}
}
callVCloudSettings_put(current_pkg_name + "_net", netType, context); // **dpi**
} JSONObject densityJson = new JSONObject();
densityJson.put("density", context.getResources().getDisplayMetrics().density);
callVCloudSettings_put(current_pkg_name + "_dpi", densityJson.toString(), context);
// **广告标识符 (advertiserId)** **启用状态** // **dpi_f**
boolean isAdIdEnabled = true; // 默认启用广告 ID JSONObject realResolutionJson = new JSONObject();
String advertiserId = "test-advertiser-id"; // 模拟广告 ID realResolutionJson.put("width", 411);
callVCloudSettings_put(current_pkg_name + ".advertiserId", advertiserId, context); realResolutionJson.put("height", 731);
callVCloudSettings_put(current_pkg_name + ".advertiserIdEnabled", String.valueOf(isAdIdEnabled), context); callVCloudSettings_put(current_pkg_name + "_dpi_f", realResolutionJson.toString(), context);
// **AppsFlyer 参数** // **tz** (时区)
callVCloudSettings_put(current_pkg_name + ".af_currentstore", "Google Play", context); callVCloudSettings_put(current_pkg_name + "_tz", tz, context);
callVCloudSettings_put(current_pkg_name + ".af_events_api", "2.0", context);
callVCloudSettings_put(current_pkg_name + ".af_installstore", "official", context);
callVCloudSettings_put(current_pkg_name + ".af_timestamp", String.valueOf(System.currentTimeMillis()), context);
callVCloudSettings_put(current_pkg_name + ".af_v", "v1.0", context);
callVCloudSettings_put(current_pkg_name + ".af_v2", "v2.0", context);
// **设备信息参数** // **isp** (网络运营商)
callVCloudSettings_put(current_pkg_name + ".android_id", "android-test-id", context); android.telephony.TelephonyManager telephonyManager = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
callVCloudSettings_put(current_pkg_name + ".app_version_code", "100", context); String isp = telephonyManager != null ? telephonyManager.getNetworkOperatorName() : "unknown";
callVCloudSettings_put(current_pkg_name + ".app_version_name", "1.0.0", context); callVCloudSettings_put(current_pkg_name + "_isp", isp, context);
callVCloudSettings_put(current_pkg_name + ".brand", android.os.Build.BRAND, context);
callVCloudSettings_put(current_pkg_name + ".device", android.os.Build.DEVICE, context);
callVCloudSettings_put(current_pkg_name + ".model", android.os.Build.MODEL, context);
// **语言及区域** // **net** (网络类型WiFi/流量)
String lang = context.getResources().getConfiguration().locale.getLanguage(); ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
String langCode = context.getResources().getConfiguration().locale.toString();
String country = context.getResources().getConfiguration().locale.getCountry();
callVCloudSettings_put(current_pkg_name + ".lang", lang, context);
callVCloudSettings_put(current_pkg_name + ".lang_code", langCode, context);
callVCloudSettings_put(current_pkg_name + ".country", country, context);
// **传感器模拟数据** if (connectivityManager != null) {
JSONObject sensorsJson = new JSONObject(); Network activeNetwork = connectivityManager.getActiveNetwork();
sensorsJson.put("sN", "TestSensor"); // 传感器名称 NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(activeNetwork);
sensorsJson.put("sT", "type_sample"); // 传感器类型
sensorsJson.put("sV", "1.2"); // 传感器版本
JSONArray sensorValues = new JSONArray();
sensorValues.put("v0");
sensorValues.put("v1");
sensorValues.put("v2");
sensorsJson.put("sVE", sensorValues);
callVCloudSettings_put(current_pkg_name + ".deviceData.sensors.[0]", sensorsJson.toString(), context);
// **电量电磁 MCC/MNC** String netType = "Unknown";
callVCloudSettings_put(current_pkg_name + ".batteryLevel", "85", context); if (capabilities != null) {
callVCloudSettings_put(current_pkg_name + ".cell.mcc", "310", context); // MCC: 示例 if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
callVCloudSettings_put(current_pkg_name + ".cell.mnc", "260", context); // MNC: 示例 netType = "WiFi";
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
// **日期与时间戳** netType = "Cellular";
callVCloudSettings_put(current_pkg_name + ".date1", String.valueOf(System.currentTimeMillis()), context); }
callVCloudSettings_put(current_pkg_name + ".date2", String.valueOf(System.nanoTime()), context);
// **其他示例条目**
callVCloudSettings_put(current_pkg_name + ".appsflyerKey", "example-key", context);
callVCloudSettings_put(current_pkg_name + ".appUserId", "test-user-id", context);
callVCloudSettings_put(current_pkg_name + ".disk", "128GB", context);
callVCloudSettings_put(current_pkg_name + ".operator", "Fake Operator", context);
// **gaid** (Google 广告 ID)
try {
AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context);
String gaid = adInfo != null ? adInfo.getId() : "unknown";
callVCloudSettings_put(current_pkg_name + "_gaid", gaid, context);
} catch (Throwable e) {
Log.e("ChangeDeviceInfoUtil", "Failed to get GAID", e);
}
} catch (Throwable e) {
Log.e("ChangeDeviceInfoUtil", "Error occurred while changing device info", e);
throw new RuntimeException("Error occurred in changeDeviceInfo", e);
} }
if (!ShellUtils.hasRootAccess()) { callVCloudSettings_put(current_pkg_name + "_net", netType, context);
Log.e("ChangeDeviceInfoUtil", "Root access is required to execute system property changes"); }
return;
}
// 设置机型, 直接设置属性 // **广告标识符 (advertiserId)** **启用状态**
ShellUtils.execRootCmd("setprop ro.product.brand google"); boolean isAdIdEnabled = true; // 默认启用广告 ID
ShellUtils.execRootCmd("setprop ro.product.model raven"); String advertiserId = "test-advertiser-id"; // 模拟广告 ID
ShellUtils.execRootCmd("setprop ro.product.manufacturer google"); callVCloudSettings_put(current_pkg_name + ".advertiserId", advertiserId, context);
ShellUtils.execRootCmd("setprop ro.product.device raven"); callVCloudSettings_put(current_pkg_name + ".advertiserIdEnabled", String.valueOf(isAdIdEnabled), context);
ShellUtils.execRootCmd("setprop ro.product.name raven");
ShellUtils.execRootCmd("setprop ro.build.version.incremental 9325679");
ShellUtils.execRootCmd("setprop ro.build.fingerprint \"google/raven/raven:13/TQ1A.230105.002/9325679:user/release-keys\"");
ShellUtils.execRootCmd("setprop ro.board.platform acr980m");
Native.setBootId("400079ef55a4475558eb60a0544a43d5"); // **AppsFlyer 参数**
callVCloudSettings_put(current_pkg_name + ".af_currentstore", "Google Play", context);
callVCloudSettings_put(current_pkg_name + ".af_events_api", "2.0", context);
callVCloudSettings_put(current_pkg_name + ".af_installstore", "official", context);
callVCloudSettings_put(current_pkg_name + ".af_timestamp", String.valueOf(System.currentTimeMillis()), context);
callVCloudSettings_put(current_pkg_name + ".af_v", "v1.0", context);
callVCloudSettings_put(current_pkg_name + ".af_v2", "v2.0", context);
// 修改drm id // **设备信息参数**
ShellUtils.execRootCmd("setprop persist.sys.cloud.drm.id 400079ef55a4475558eb60a0544a43d5171258f13fdd48c10026e2847a6fc7a5"); callVCloudSettings_put(current_pkg_name + ".android_id", "android-test-id", context);
callVCloudSettings_put(current_pkg_name + ".app_version_code", "100", context);
callVCloudSettings_put(current_pkg_name + ".app_version_name", "1.0.0", context);
callVCloudSettings_put(current_pkg_name + ".brand", android.os.Build.BRAND, context);
callVCloudSettings_put(current_pkg_name + ".device", android.os.Build.DEVICE, context);
callVCloudSettings_put(current_pkg_name + ".model", model, context);
callVCloudSettings_put(current_pkg_name + ".cpu_clock_speed", cpuClockSpeed, context);
// 电量模拟需要大于1000 // **语言及区域**
ShellUtils.execRootCmd("setprop persist.sys.cloud.battery.capacity 5000"); String lang = context.getResources().getConfiguration().locale.getLanguage();
String langCode = context.getResources().getConfiguration().locale.toString();
callVCloudSettings_put(current_pkg_name + ".lang", lang, context);
callVCloudSettings_put(current_pkg_name + ".lang_code", langCode, context);
callVCloudSettings_put(current_pkg_name + ".country", country, context);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_vendor my_gl_vendor"); // **传感器模拟数据**
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_renderer my_gl_renderer"); JSONObject sensorsJson = new JSONObject();
// 这个值不能随便改 必须是 OpenGL ES %d.%d 这个格式 sensorsJson.put("sN", "TestSensor"); // 传感器名称
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_version \"OpenGL ES 3.2\""); sensorsJson.put("sT", "type_sample"); // 传感器类型
sensorsJson.put("sV", "1.2"); // 传感器版本
JSONArray sensorValues = new JSONArray();
sensorValues.put("v0");
sensorValues.put("v1");
sensorValues.put("v2");
sensorsJson.put("sVE", sensorValues);
callVCloudSettings_put(current_pkg_name + ".deviceData.sensors.[0]", sensorsJson.toString(), context);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor my_egl_vendor"); // **电量电磁 MCC/MNC**
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version my_egl_version"); callVCloudSettings_put(current_pkg_name + ".batteryLevel", "85", context);
callVCloudSettings_put(current_pkg_name + ".cell.mcc", "310", context); // MCC: 示例
callVCloudSettings_put(current_pkg_name + ".cell.mnc", "260", context); // MNC: 示例
// **日期与时间戳**
callVCloudSettings_put(current_pkg_name + ".date1", String.valueOf(System.currentTimeMillis()), context);
callVCloudSettings_put(current_pkg_name + ".date2", String.valueOf(System.nanoTime()), context);
// **其他示例条目**
callVCloudSettings_put(current_pkg_name + ".appsflyerKey", "example-key", context);
callVCloudSettings_put(current_pkg_name + ".appUserId", "test-user-id", context);
callVCloudSettings_put(current_pkg_name + ".disk", "128GB", context);
callVCloudSettings_put(current_pkg_name + ".operator", "Fake Operator", context);
// **gaid** (Google 广告 ID)
try {
callVCloudSettings_put(current_pkg_name + "_gaid", gaid, context);
} catch (Throwable e) {
Log.e("ChangeDeviceInfoUtil", "Failed to get GAID", e);
}
} catch (Throwable e) {
Log.e("ChangeDeviceInfoUtil", "Error occurred while changing device info", e);
throw new RuntimeException("Error occurred in changeDeviceInfo", e);
} }
private static void callVCloudSettings_put(String key, String value, Context context) { if (!ShellUtils.hasRootAccess()) {
if (context == null) { Log.e("ChangeDeviceInfoUtil", "Root access is required to execute system property changes");
throw new IllegalArgumentException("Context cannot be null"); return;
}
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("Key cannot be null or empty");
}
if (value == null) {
throw new IllegalArgumentException("Value cannot be null");
}
try {
// 获取类对象
Class<?> clazz = Class.forName("android.provider.VCloudSettings$Global");
Method putStringMethod = clazz.getDeclaredMethod("putString", ContentResolver.class, String.class, String.class);
putStringMethod.setAccessible(true);
// 调用方法
putStringMethod.invoke(null, context.getContentResolver(), key, value);
Log.d("Debug", "putString executed successfully.");
} catch (ClassNotFoundException e) {
Log.w("Reflection Error", "Class not found: android.provider.VCloudSettings$Global. This may not be supported on this device.");
} catch (NoSuchMethodException e) {
Log.w("Reflection Error", "Method putString not available. Ensure your target Android version supports it.");
} catch (InvocationTargetException e) {
Throwable cause = e.getTargetException();
if (cause instanceof SecurityException) {
Log.e("Reflection Error", "Permission denied. Ensure WRITE_SECURE_SETTINGS permission is granted.", cause);
} else {
Log.e("Reflection Error", "InvocationTargetException during putString invocation", e);
}
} catch (Exception e) {
Log.e("Reflection Error", "Unexpected error during putString invocation: " + e.getMessage());
}
} }
public static void resetChangedDeviceInfo(String current_pkg_name,Context context) { // 设置机型, 直接设置属性
try { ShellUtils.execRootCmd("setprop ro.product.brand google");
Native.setBootId("00000000000000000000000000000000"); ShellUtils.execRootCmd("setprop ro.product.model raven");
} catch (Exception e) { ShellUtils.execRootCmd("setprop ro.product.manufacturer google");
Log.e("resetChangedDeviceInfo", "Failed to set boot ID", e); ShellUtils.execRootCmd("setprop ro.product.device raven");
} ShellUtils.execRootCmd("setprop ro.product.name raven");
ShellUtils.execRootCmd("setprop ro.build.version.incremental 9325679");
ShellUtils.execRootCmd("setprop ro.build.fingerprint \"google/raven/raven:13/TQ1A.230105.002/9325679:user/release-keys\"");
ShellUtils.execRootCmd("setprop ro.board.platform acr980m");
if (!ShellUtils.hasRootAccess()) { Native.setBootId("400079ef55a4475558eb60a0544a43d5");
Log.e("resetChangedDeviceInfo", "Root privileges are required.");
return;
}
ShellUtils.execRootCmd("cmd settings2 delete global global_android_id");
ShellUtils.execRootCmd("cmd settings2 delete global pm_list_features");
ShellUtils.execRootCmd("cmd settings2 delete global pm_list_libraries");
ShellUtils.execRootCmd("cmd settings2 delete global anticheck_pkgs");
ShellUtils.execRootCmd("cmd settings2 delete global " + current_pkg_name + "_android_id");
ShellUtils.execRootCmd("cmd settings2 delete global " + current_pkg_name + "_adb_enabled");
ShellUtils.execRootCmd("cmd settings2 delete global " + current_pkg_name + "_development_settings_enabled");
ShellUtils.execRootCmd("setprop persist.sys.cloud.drm.id \"\""); // 修改drm id
ShellUtils.execRootCmd("setprop persist.sys.cloud.drm.id 400079ef55a4475558eb60a0544a43d5171258f13fdd48c10026e2847a6fc7a5");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_vendor \"\""); // 电量模拟需要大于1000
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_renderer \"\""); ShellUtils.execRootCmd("setprop persist.sys.cloud.battery.capacity 5000");
// 这个值不能随便改 必须是 OpenGL ES %d.%d 这个格式
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_version \"\"");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor \"\""); ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_vendor my_gl_vendor");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version \"\""); ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_renderer my_gl_renderer");
// 这个值不能随便改 必须是 OpenGL ES %d.%d 这个格式
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_version \"OpenGL ES 3.2\"");
ShellUtils.execRootCmd("setprop ro.product.brand Vortex"); ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor my_egl_vendor");
ShellUtils.execRootCmd("setprop ro.product.model HD65_Select"); ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version my_egl_version");
ShellUtils.execRootCmd("setprop ro.product.manufacturer Vortex");
ShellUtils.execRootCmd("setprop ro.product.device HD65_Select"); }
ShellUtils.execRootCmd("setprop ro.product.name HD65_Select");
ShellUtils.execRootCmd("setprop ro.build.version.incremental 20240306"); private static void callVCloudSettings_put(String key, String value, Context context) {
ShellUtils.execRootCmd("setprop ro.build.fingerprint \"Vortex/HD65_Select/HD65_Select:13/TP1A.220624.014/20240306:user/release-keys\""); if (context == null) {
ShellUtils.execRootCmd("setprop ro.board.platform sm8150p"); throw new IllegalArgumentException("Context cannot be null");
} }
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("Key cannot be null or empty");
}
if (value == null) {
throw new IllegalArgumentException("Value cannot be null");
}
try {
// 获取类对象
Class<?> clazz = Class.forName("android.provider.VCloudSettings$Global");
Method putStringMethod = clazz.getDeclaredMethod("putString", ContentResolver.class, String.class, String.class);
putStringMethod.setAccessible(true);
// 调用方法
putStringMethod.invoke(null, context.getContentResolver(), key, value);
Log.d("Debug", "putString executed successfully.");
} catch (ClassNotFoundException e) {
Log.w("Reflection Error", "Class not found: android.provider.VCloudSettings$Global. This may not be supported on this device.");
} catch (NoSuchMethodException e) {
Log.w("Reflection Error", "Method putString not available. Ensure your target Android version supports it.");
} catch (InvocationTargetException e) {
Throwable cause = e.getTargetException();
if (cause instanceof SecurityException) {
Log.e("Reflection Error", "Permission denied. Ensure WRITE_SECURE_SETTINGS permission is granted.", cause);
} else {
Log.e("Reflection Error", "InvocationTargetException during putString invocation", e);
}
} catch (Exception e) {
Log.e("Reflection Error", "Unexpected error during putString invocation: " + e.getMessage());
}
}
public static void resetChangedDeviceInfo(String current_pkg_name, Context context) {
try {
Native.setBootId("00000000000000000000000000000000");
} catch (Exception e) {
Log.e("resetChangedDeviceInfo", "Failed to set boot ID", e);
}
if (!ShellUtils.hasRootAccess()) {
Log.e("resetChangedDeviceInfo", "Root privileges are required.");
return;
}
ShellUtils.execRootCmd("cmd settings2 delete global global_android_id");
ShellUtils.execRootCmd("cmd settings2 delete global pm_list_features");
ShellUtils.execRootCmd("cmd settings2 delete global pm_list_libraries");
ShellUtils.execRootCmd("cmd settings2 delete global anticheck_pkgs");
ShellUtils.execRootCmd("cmd settings2 delete global " + current_pkg_name + "_android_id");
ShellUtils.execRootCmd("cmd settings2 delete global " + current_pkg_name + "_adb_enabled");
ShellUtils.execRootCmd("cmd settings2 delete global " + current_pkg_name + "_development_settings_enabled");
ShellUtils.execRootCmd("setprop persist.sys.cloud.drm.id \"\"");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_vendor \"\"");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_renderer \"\"");
// 这个值不能随便改 必须是 OpenGL ES %d.%d 这个格式
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.gl_version \"\"");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor \"\"");
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version \"\"");
ShellUtils.execRootCmd("setprop ro.product.brand Vortex");
ShellUtils.execRootCmd("setprop ro.product.model HD65_Select");
ShellUtils.execRootCmd("setprop ro.product.manufacturer Vortex");
ShellUtils.execRootCmd("setprop ro.product.device HD65_Select");
ShellUtils.execRootCmd("setprop ro.product.name HD65_Select");
ShellUtils.execRootCmd("setprop ro.build.version.incremental 20240306");
ShellUtils.execRootCmd("setprop ro.build.fingerprint \"Vortex/HD65_Select/HD65_Select:13/TP1A.220624.014/20240306:user/release-keys\"");
ShellUtils.execRootCmd("setprop ro.board.platform sm8150p");
}
} }

View File

@ -10,5 +10,6 @@
<domain includeSubdomains="true">47.236.153.142</domain> <domain includeSubdomains="true">47.236.153.142</domain>
<domain includeSubdomains="true">8.211.204.20</domain> <domain includeSubdomains="true">8.211.204.20</domain>
<domain includeSubdomains="true">127.0.0.1</domain> <domain includeSubdomains="true">127.0.0.1</domain>
<domain includeSubdomains="true">8.217.137.25</domain>
</domain-config> </domain-config>
</network-security-config> </network-security-config>