Collect detailed device and environment info for VCloud
Added system-level data collection for properties like User-Agent, OS version, language, DPI, time zone, network type, ISP, country, and Google Advertising ID (GAID). Integrated `play-services-ads-identifier` dependency for retrieving GAID. Updated `build.gradle` and `libs.versions.toml` accordingly.
This commit is contained in:
parent
3bde5cadb7
commit
23e9b730bf
|
@ -59,6 +59,7 @@ dependencies {
|
||||||
implementation libs.material
|
implementation libs.material
|
||||||
implementation libs.activity
|
implementation libs.activity
|
||||||
implementation libs.constraintlayout
|
implementation libs.constraintlayout
|
||||||
|
implementation libs.play.services.ads.identifier
|
||||||
testImplementation libs.junit
|
testImplementation libs.junit
|
||||||
androidTestImplementation libs.ext.junit
|
androidTestImplementation libs.ext.junit
|
||||||
androidTestImplementation libs.espresso.core
|
androidTestImplementation libs.espresso.core
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.example.studyapp.utils.ShellUtils;
|
import com.example.studyapp.utils.ShellUtils;
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -72,6 +73,58 @@ public class ChangeDeviceInfoUtil {
|
||||||
callVCloudSettings_put(current_pkg_name + "_screen.getCurrentBounds.stack", ".getDeviceInfo",context);
|
callVCloudSettings_put(current_pkg_name + "_screen.getCurrentBounds.stack", ".getDeviceInfo",context);
|
||||||
callVCloudSettings_put(current_pkg_name + "_screen.getMaximumBounds.stack", ".getDeviceInfo",context);
|
callVCloudSettings_put(current_pkg_name + "_screen.getMaximumBounds.stack", ".getDeviceInfo",context);
|
||||||
|
|
||||||
|
// **User-Agent**
|
||||||
|
String defaultUserAgent = System.getProperty("http.agent"); // 默认 User-Agent
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_user_agent", defaultUserAgent, context);
|
||||||
|
|
||||||
|
// **os_ver**
|
||||||
|
String osVer = System.getProperty("os.version"); // 系统版本
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_os_ver", osVer, context);
|
||||||
|
|
||||||
|
// **os_lang**
|
||||||
|
String osLang = context.getResources().getConfiguration().locale.getLanguage(); // 系统语言
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_os_lang", osLang, context);
|
||||||
|
|
||||||
|
// **dpi**
|
||||||
|
JSONObject densityJson = new JSONObject();
|
||||||
|
densityJson.put("density", context.getResources().getDisplayMetrics().density);
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_dpi", densityJson.toString(), context);
|
||||||
|
|
||||||
|
// **dpi_f**
|
||||||
|
JSONObject realResolutionJson = new JSONObject();
|
||||||
|
realResolutionJson.put("width", 411);
|
||||||
|
realResolutionJson.put("height", 731);
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_dpi_f", realResolutionJson.toString(), context);
|
||||||
|
|
||||||
|
// **tz** (时区)
|
||||||
|
String tz = java.util.TimeZone.getDefault().getID(); // 系统时区
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_tz", tz, context);
|
||||||
|
|
||||||
|
// **isp** (网络运营商)
|
||||||
|
android.telephony.TelephonyManager telephonyManager = (android.telephony.TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
String isp = telephonyManager != null ? telephonyManager.getNetworkOperatorName() : "unknown";
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_isp", isp, context);
|
||||||
|
|
||||||
|
// **country**
|
||||||
|
String country = context.getResources().getConfiguration().locale.getCountry();
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_country", country, context);
|
||||||
|
|
||||||
|
// **net** (网络类型:WiFi/流量)
|
||||||
|
android.net.ConnectivityManager connectivityManager = (android.net.ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
String netType = (connectivityManager != null &&
|
||||||
|
connectivityManager.getActiveNetworkInfo() != null &&
|
||||||
|
connectivityManager.getActiveNetworkInfo().isConnected()) ?
|
||||||
|
connectivityManager.getActiveNetworkInfo().getTypeName() : "unknown";
|
||||||
|
callVCloudSettings_put(current_pkg_name + "_net", netType, 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) {
|
} catch (Throwable e) {
|
||||||
Log.e("ChangeDeviceInfoUtil", "Error occurred while changing device info", e);
|
Log.e("ChangeDeviceInfoUtil", "Error occurred while changing device info", e);
|
||||||
|
|
|
@ -7,6 +7,7 @@ appcompat = "1.7.0"
|
||||||
material = "1.12.0"
|
material = "1.12.0"
|
||||||
activity = "1.10.1"
|
activity = "1.10.1"
|
||||||
constraintlayout = "2.2.1"
|
constraintlayout = "2.2.1"
|
||||||
|
playServicesAdsIdentifier = "18.2.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
|
@ -16,6 +17,7 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a
|
||||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||||
|
play-services-ads-identifier = { group = "com.google.android.gms", name = "play-services-ads-identifier", version.ref = "playServicesAdsIdentifier" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|
Loading…
Reference in New Issue