diff --git a/.gitignore b/.gitignore index 86d7192..ec9e540 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,4 @@ local.properties gradle.properties /android-sdk/gradle.properties /android-sdk-plugin-oaid/gradle.properties -/android-sdk-plugin-webbridge/gradle.properties - -/.idea/ +/android-sdk-plugin-webbridge/gradle.properties \ No newline at end of file diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md index 74accaa..acc30a6 100644 --- a/CHANGE_LOG.md +++ b/CHANGE_LOG.md @@ -1,5 +1,11 @@ -## 2.5.0 -- +## Version 2.5.1 +### Added: +- Added `setReadDeviceInfoOnceEnabled(boolean)` method to `AdTraceConfig` to indicate if device info to be read only once. +- new URL strategy. + +--- + +## Version 2.5.0 ### Added: - data residency support - Updated Samsung Install Referrer library version to 3.0.1. @@ -13,5 +19,5 @@ - support for Meta install referrer. - support for Google Play Games on PC. - Getters for certain public classes. -- `setReadDeviceInfoOnceEnabled(boolean)` method to `AdTraceConfig` to indicate if device info to be read only once. + diff --git a/README.md b/README.md index c802478..b128a11 100644 --- a/README.md +++ b/README.md @@ -105,14 +105,14 @@ These are the minimum required steps to integrate the AdTrace SDK in your Androi If you are using Maven, add the following to your `build.gradle` file: ```java -implementation 'io.adtrace:android-sdk:2.5.0' +implementation 'io.adtrace:android-sdk:2.5.1' implementation 'com.android.installreferrer:installreferrer:2.2' ``` If you would prefer to use the AdTrace SDK inside web views in your app, please include this additional dependency as well: ```java -implementation 'io.adtrace:android-sdk-plugin-webbridge:2.5.0' +implementation 'io.adtrace:android-sdk-plugin-webbridge:2.5.1' ``` **Note**: The minimum supported Android API level for the web view extension is 17 (Jelly Bean). @@ -1836,7 +1836,7 @@ And a click package added to the SDK's package handler: ``` V/AdTrace: Path: /sdk_click - ClientSdk: android2.5.0 + ClientSdk: android2.5.1 Parameters: app_token adt1exadt1ex click_time yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z diff --git a/VERSION b/VERSION index fad066f..4fd0fe3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.0 \ No newline at end of file +2.5.1 \ No newline at end of file diff --git a/android-sdk-imei-plugin/build.gradle b/android-sdk-imei-plugin/build.gradle index 550df66..c8fcf0a 100644 --- a/android-sdk-imei-plugin/build.gradle +++ b/android-sdk-imei-plugin/build.gradle @@ -24,7 +24,7 @@ dependencies { // Add SDK via module. compileOnly project(':android-sdk') // Add SDK via Maven. - // implementation 'io.adtrace:android-sdk:2.5.0' + // implementation 'io.adtrace:android-sdk:2.5.1' } // read local properties diff --git a/android-sdk-plugin-oaid/build.gradle b/android-sdk-plugin-oaid/build.gradle index 6ae412e..2674cb4 100644 --- a/android-sdk-plugin-oaid/build.gradle +++ b/android-sdk-plugin-oaid/build.gradle @@ -33,7 +33,7 @@ dependencies { // Add SDK via module. compileOnly project(':android-sdk') // Add SDK via Maven. - // implementation 'io.adtrace:android-sdk:2.5.0' + // implementation 'io.adtrace:android-sdk:2.5.1' implementation 'com.huawei.hms:ads-identifier:3.4.56.300' } diff --git a/android-sdk-plugin-webbridge/build.gradle b/android-sdk-plugin-webbridge/build.gradle index b5ba757..0551cb2 100644 --- a/android-sdk-plugin-webbridge/build.gradle +++ b/android-sdk-plugin-webbridge/build.gradle @@ -30,7 +30,7 @@ dependencies { // Add SDK via module. compileOnly project(':android-sdk') // Add SDK via Maven. - // implementation 'io.adtrace:android-sdk:2.5.0' + // implementation 'io.adtrace:android-sdk:2.5.1' } // read local properties diff --git a/android-sdk-plugin-webbridge/src/main/assets/adtrace.js b/android-sdk-plugin-webbridge/src/main/assets/adtrace.js index c6f3515..49e5b6a 100644 --- a/android-sdk-plugin-webbridge/src/main/assets/adtrace.js +++ b/android-sdk-plugin-webbridge/src/main/assets/adtrace.js @@ -211,7 +211,7 @@ var AdTrace = { if (this.adtraceConfig) { return this.adtraceConfig.getSdkPrefix(); } else { - return 'web-bridge2.5.0'; + return 'web-bridge2.5.1'; } }, diff --git a/android-sdk-plugin-webbridge/src/main/assets/adtrace_config.js b/android-sdk-plugin-webbridge/src/main/assets/adtrace_config.js index d82298e..649b818 100644 --- a/android-sdk-plugin-webbridge/src/main/assets/adtrace_config.js +++ b/android-sdk-plugin-webbridge/src/main/assets/adtrace_config.js @@ -57,6 +57,7 @@ function AdTraceConfig(appToken, environment, legacy) { this.coppaCompliantEnabled = null; this.finalAttributionEnabled = null; this.fbAppId = null; + this.readDeviceInfoOnceEnabled = null; } AdTraceConfig.EnvironmentSandbox = 'sandbox'; @@ -64,6 +65,8 @@ AdTraceConfig.EnvironmentProduction = 'production'; AdTraceConfig.UrlStrategyIndia = "url_strategy_india"; AdTraceConfig.UrlStrategyChina = "url_strategy_china"; +AdTraceConfig.UrlStrategyCn = "url_strategy_cn"; +AdTraceConfig.UrlStrategyCnOnly = "url_strategy_cn_only"; AdTraceConfig.DataResidencyEU = "data_residency_eu"; AdTraceConfig.DataResidencyTR = "data_residency_tr"; AdTraceConfig.DataResidencyUS = "data_residency_us"; @@ -267,3 +270,7 @@ AdTraceConfig.prototype.setFinalAttributionEnabled = function(isEnabled) { AdTraceConfig.prototype.setFbAppId = function(fbAppId) { this.fbAppId = fbAppId; }; + +AdjustConfig.prototype.setReadDeviceInfoOnceEnabled = function(isEnabled) { + this.readDeviceInfoOnceEnabled = isEnabled; +}; diff --git a/android-sdk-plugin-webbridge/src/main/java/io/adtrace/sdk/webbridge/AdTraceBridgeInstance.java b/android-sdk-plugin-webbridge/src/main/java/io/adtrace/sdk/webbridge/AdTraceBridgeInstance.java index 0b0e5ee..283c022 100644 --- a/android-sdk-plugin-webbridge/src/main/java/io/adtrace/sdk/webbridge/AdTraceBridgeInstance.java +++ b/android-sdk-plugin-webbridge/src/main/java/io/adtrace/sdk/webbridge/AdTraceBridgeInstance.java @@ -179,6 +179,7 @@ public void onCreate(String adtraceConfigString) { Object coppaCompliantEnabledField = jsonAdTraceConfig.get("coppaCompliantEnabled"); Object finalAttributionEnabledField = jsonAdTraceConfig.get("finalAttributionEnabled"); Object fbAppIdField = jsonAdTraceConfig.get("fbAppId"); + Object readDeviceInfoOnceEnabledField = jsonAdTraceConfig.get("readDeviceInfoOnceEnabled"); String appToken = AdTraceBridgeUtil.fieldToString(appTokenField); String environment = AdTraceBridgeUtil.fieldToString(environmentField); @@ -418,6 +419,12 @@ public boolean launchReceivedDeeplink(Uri deeplink) { adtraceConfig.setFbAppId(fbAppId); } + // read device info once + Boolean readDeviceInfoOnceEnabled = AdTraceBridgeUtil.fieldToBoolean(readDeviceInfoOnceEnabledField); + if (readDeviceInfoOnceEnabled != null) { + adtraceConfig.setReadDeviceInfoOnceEnabled(readDeviceInfoOnceEnabled); + } + // Manually call onResume() because web view initialisation will happen a bit delayed. // With this delay, it will miss lifecycle callback onResume() initial firing. AdTrace.onCreate(adtraceConfig); @@ -474,7 +481,7 @@ public void trackEvent(String adtraceEventString) { } } - // event parameters + // Value parameters String[] eventParameters = AdTraceBridgeUtil.jsonArrayToArray((JSONArray)eventParametersField); if (eventParameters != null) { for (int i = 0; i < eventParameters.length; i += 2) { @@ -484,7 +491,7 @@ public void trackEvent(String adtraceEventString) { } } - // event partner parameters + // Partner parameters String[] partnerParameters = AdTraceBridgeUtil.jsonArrayToArray((JSONArray)partnerParametersField); if (partnerParameters != null) { for (int i = 0; i < partnerParameters.length; i += 2) { diff --git a/android-sdk-vivo-plugin/build.gradle b/android-sdk-vivo-plugin/build.gradle index e2902b6..48d8b69 100644 --- a/android-sdk-vivo-plugin/build.gradle +++ b/android-sdk-vivo-plugin/build.gradle @@ -30,7 +30,7 @@ dependencies { // Add SDK via module. compileOnly project(':android-sdk') // Add SDK via Maven. - // implementation 'io.adtrace:android-sdk:2.5.0' + // implementation 'io.adtrace:android-sdk:2.5.1' } // read local properties diff --git a/android-sdk-xiaomi-plugin/build.gradle b/android-sdk-xiaomi-plugin/build.gradle index 826534b..850546f 100644 --- a/android-sdk-xiaomi-plugin/build.gradle +++ b/android-sdk-xiaomi-plugin/build.gradle @@ -31,7 +31,7 @@ dependencies { // Add SDK via module. compileOnly project(':android-sdk') // Add SDK via Maven. - // implementation 'io.adtrace:android-sdk:2.5.0' + // implementation 'io.adtrace:android-sdk:2.5.1' // Add xiaomi referrer lib via Maven. implementation 'com.miui.referrer:homereferrer:1.0.0.6' diff --git a/android-sdk/src/main/java/io/adtrace/sdk/AdTrace.java b/android-sdk/src/main/java/io/adtrace/sdk/AdTrace.java index 62db4ae..e78a790 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/AdTrace.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/AdTrace.java @@ -33,7 +33,7 @@ private AdTrace() { */ public static synchronized AdTraceInstance getDefaultInstance() { @SuppressWarnings("unused") - String VERSION = "!SDK-VERSION-STRING!:io.adtrace.sdk:adtrace-android:2.5.0"; + String VERSION = "!SDK-VERSION-STRING!:io.adtrace.sdk:adtrace-android:2.5.1"; if (defaultInstance == null) { defaultInstance = new AdTraceInstance(); @@ -326,7 +326,7 @@ public static void getGoogleAdId(Context context, OnDeviceIdsRead onDeviceIdRead public static String getAmazonAdId(final Context context) { Context appContext = extractApplicationContext(context); if (appContext != null) { - return Util.getFireAdvertisingId(appContext.getContentResolver()); + return DeviceInfo.getFireAdvertisingIdBypassConditions(appContext.getContentResolver()); } return null; diff --git a/android-sdk/src/main/java/io/adtrace/sdk/AdTraceConfig.java b/android-sdk/src/main/java/io/adtrace/sdk/AdTraceConfig.java index 97571e8..38c3adc 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/AdTraceConfig.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/AdTraceConfig.java @@ -2,6 +2,7 @@ import android.content.Context; + /** * AdTrace android SDK (https://adtrace.io) * Created by Nasser Amini (github.com/namini40) on April 2022. @@ -48,6 +49,7 @@ public class AdTraceConfig { boolean coppaCompliantEnabled; boolean finalAttributionEnabled; String fbAppId; + boolean readDeviceInfoOnceEnabled; public static final String ENVIRONMENT_SANDBOX = "sandbox"; public static final String ENVIRONMENT_PRODUCTION = "production"; @@ -55,6 +57,7 @@ public class AdTraceConfig { public static final String URL_STRATEGY_INDIA = "url_strategy_india"; public static final String URL_STRATEGY_CHINA = "url_strategy_china"; public static final String URL_STRATEGY_CN = "url_strategy_cn"; + public static final String URL_STRATEGY_CN_ONLY = "url_strategy_cn_only"; public static final String DATA_RESIDENCY_EU = "data_residency_eu"; public static final String DATA_RESIDENCY_TR = "data_residency_tr"; public static final String DATA_RESIDENCY_US = "data_residency_us"; @@ -227,6 +230,7 @@ public void setUrlStrategy(String urlStrategy) { if (!urlStrategy.equals(URL_STRATEGY_INDIA) && !urlStrategy.equals(URL_STRATEGY_CHINA) && !urlStrategy.equals(URL_STRATEGY_CN) + && !urlStrategy.equals(URL_STRATEGY_CN_ONLY) && !urlStrategy.equals(DATA_RESIDENCY_EU) && !urlStrategy.equals(DATA_RESIDENCY_TR) && !urlStrategy.equals(DATA_RESIDENCY_US)) @@ -236,6 +240,10 @@ public void setUrlStrategy(String urlStrategy) { this.urlStrategy = urlStrategy; } + public void setReadDeviceInfoOnceEnabled(boolean readDeviceInfoOnceEnabled) { + this.readDeviceInfoOnceEnabled = readDeviceInfoOnceEnabled; + } + public String getBasePath() { return basePath; } @@ -388,6 +396,10 @@ public String getFbAppId() { return fbAppId; } + public boolean isReadDeviceInfoOnceEnabled() { + return readDeviceInfoOnceEnabled; + } + private void setLogLevel(LogLevel logLevel, String environment) { logger.setLogLevel(logLevel, AdTraceConfig.ENVIRONMENT_PRODUCTION.equals(environment)); } diff --git a/android-sdk/src/main/java/io/adtrace/sdk/AdTraceEvent.java b/android-sdk/src/main/java/io/adtrace/sdk/AdTraceEvent.java index 2b104e5..6f047c4 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/AdTraceEvent.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/AdTraceEvent.java @@ -121,6 +121,8 @@ public Map getPartnerParameters() { return partnerParameters; } + public Map getEventValueParameters(){return eventValueParameters;} + public String getOrderId() { return orderId; } diff --git a/android-sdk/src/main/java/io/adtrace/sdk/Constants.java b/android-sdk/src/main/java/io/adtrace/sdk/Constants.java index 4e4a0f6..d02ebef 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/Constants.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/Constants.java @@ -26,7 +26,7 @@ public interface Constants { String SCHEME = "https"; String AUTHORITY = "app.adtrace.io"; - String CLIENT_SDK = "android2.5.0"; + String CLIENT_SDK = "android2.5.1"; String LOGTAG = "AdTrace"; String REFTAG = "reftag"; String INSTALL_REFERRER = "install_referrer"; diff --git a/android-sdk/src/main/java/io/adtrace/sdk/DeviceInfo.java b/android-sdk/src/main/java/io/adtrace/sdk/DeviceInfo.java index be3a5f1..fac97e3 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/DeviceInfo.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/DeviceInfo.java @@ -9,12 +9,20 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; +import android.net.ConnectivityManager; +import android.net.Network; +import android.net.NetworkCapabilities; +import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.text.TextUtils; import android.util.DisplayMetrics; import java.util.Date; import java.util.Locale; +import java.util.Map; import static android.content.res.Configuration.UI_MODE_TYPE_MASK; import static android.content.res.Configuration.UI_MODE_TYPE_TELEVISION; @@ -59,6 +67,8 @@ class DeviceInfo { int playAdIdAttempt = -1; Boolean isTrackingEnabled; private boolean nonGoogleIdsReadOnce = false; + private boolean playIdsReadOnce = false; + private boolean otherDeviceInfoParamsReadOnce = false; String androidId; String fbAttributionId; String clientSdk; @@ -86,17 +96,26 @@ class DeviceInfo { String appSetId; boolean isGooglePlayGamesForPC; + Map imeiParameters; + Map oaidParameters; + String fireAdId; + Boolean fireTrackingEnabled; + int connectivityType; + String mcc; + String mnc; + DeviceInfo(AdTraceConfig adtraceConfig) { Context context = adtraceConfig.context; Resources resources = context.getResources(); DisplayMetrics displayMetrics = resources.getDisplayMetrics(); Configuration configuration = resources.getConfiguration(); Locale locale = Util.getLocale(configuration); + PackageInfo packageInfo = getPackageInfo(context); int screenLayout = configuration.screenLayout; isGooglePlayGamesForPC = Util.isGooglePlayGamesForPC(context); packageName = getPackageName(context); - appVersion = getAppVersion(context); + appVersion = getAppVersion(packageInfo); deviceType = getDeviceType(configuration); deviceName = getDeviceName(); deviceManufacturer = getDeviceManufacturer(); @@ -115,8 +134,8 @@ class DeviceInfo { hardwareName = getHardwareName(); abi = getABI(); buildName = getBuildName(); - appInstallTime = getAppInstallTime(context); - appUpdateTime = getAppUpdateTime(context); + appInstallTime = getAppInstallTime(packageInfo); + appUpdateTime = getAppUpdateTime(packageInfo); uiMode = getDeviceUiMode(configuration); if (Util.canReadPlayIds(adtraceConfig)) { appSetId = Reflection.getAppSetId(context); @@ -128,6 +147,10 @@ void reloadPlayIds(final AdTraceConfig adtraceConfig) { return; } + if (playIdsReadOnce && adtraceConfig.readDeviceInfoOnceEnabled) { + return; + } + Context context = adtraceConfig.context; String previousPlayAdId = playAdId; Boolean previousIsTrackingEnabled = isTrackingEnabled; @@ -137,7 +160,6 @@ void reloadPlayIds(final AdTraceConfig adtraceConfig) { playAdIdSource = null; playAdIdAttempt = -1; - // attempt connecting to Google Play Service by own for (int serviceAttempt = 1; serviceAttempt <= 3; serviceAttempt += 1) { try { @@ -149,6 +171,7 @@ void reloadPlayIds(final AdTraceConfig adtraceConfig) { timeoutServiceMilli); if (playAdId == null) { playAdId = gpsInfo.getGpsAdid(); + playIdsReadOnce = true; } if (isTrackingEnabled == null) { isTrackingEnabled = gpsInfo.isTrackingEnabled(); @@ -176,6 +199,7 @@ void reloadPlayIds(final AdTraceConfig adtraceConfig) { // just needs a short timeout since it should be just accessing a POJO playAdId = Util.getPlayAdId( context, advertisingInfoObject, Constants.ONE_SECOND); + playIdsReadOnce = true; } if (isTrackingEnabled == null) { // just needs a short timeout since it should be just accessing a POJO @@ -193,6 +217,7 @@ void reloadPlayIds(final AdTraceConfig adtraceConfig) { // if both weren't found, use previous values if (playAdId == null) { playAdId = previousPlayAdId; + playIdsReadOnce = true; } if (isTrackingEnabled == null) { isTrackingEnabled = previousIsTrackingEnabled; @@ -207,20 +232,47 @@ void reloadNonPlayIds(final AdTraceConfig adtraceConfig) { if (nonGoogleIdsReadOnce) { return; } + androidId = Util.getAndroidId(adtraceConfig.context); nonGoogleIdsReadOnce = true; } + void reloadOtherDeviceInfoParams(final AdTraceConfig adtraceConfig, final ILogger logger) { + if (adtraceConfig.readDeviceInfoOnceEnabled && otherDeviceInfoParamsReadOnce) { + return; + } + + imeiParameters = UtilDeviceIds.getImeiParameters(adtraceConfig, logger); + oaidParameters = UtilDeviceIds.getOaidParameters(adtraceConfig, logger); + fireAdId = UtilDeviceIds.getFireAdvertisingId(adtraceConfig); + fireTrackingEnabled = UtilDeviceIds.getFireTrackingEnabled(adtraceConfig); + connectivityType = UtilDeviceIds.getConnectivityType(adtraceConfig.context, logger); + mcc = UtilDeviceIds.getMcc(adtraceConfig.context, logger); + mnc = UtilDeviceIds.getMnc(adtraceConfig.context, logger); + + otherDeviceInfoParamsReadOnce = true; + } + public static String getFireAdvertisingIdBypassConditions(ContentResolver contentResolver) { + return UtilDeviceIds.getFireAdvertisingId(contentResolver); + } + private String getPackageName(Context context) { return context.getPackageName(); } - private String getAppVersion(Context context) { + private PackageInfo getPackageInfo(Context context) { try { PackageManager packageManager = context.getPackageManager(); String name = context.getPackageName(); - PackageInfo info = packageManager.getPackageInfo(name, 0); - return info.versionName; + return packageManager.getPackageInfo(name, PackageManager.GET_PERMISSIONS); + } catch (Exception e) { + return null; + } + } + + private String getAppVersion(PackageInfo packageInfo) { + try { + return packageInfo.versionName; } catch (Exception e) { return null; } @@ -409,31 +461,171 @@ private String getABI() { return SupportedABIS[0]; } - private String getAppInstallTime(Context context) { + private String getAppInstallTime(PackageInfo packageInfo) { try { - PackageManager packageManager = context.getPackageManager(); - PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); - - String appInstallTime = Util.dateFormatter.format(new Date(packageInfo.firstInstallTime)); - - return appInstallTime; + return Util.dateFormatter.format(new Date(packageInfo.firstInstallTime)); } catch (Exception ex) { return null; } } - private String getAppUpdateTime(Context context) { + private String getAppUpdateTime(PackageInfo packageInfo) { try { - PackageManager packageManager = context.getPackageManager(); - PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); - - String appInstallTime = Util.dateFormatter.format(new Date(packageInfo.lastUpdateTime)); - - return appInstallTime; + return Util.dateFormatter.format(new Date(packageInfo.lastUpdateTime)); } catch (Exception ex) { return null; } } + private static class UtilDeviceIds { + private static Map getImeiParameters(final AdTraceConfig adtraceConfig, + final ILogger logger) + { + if (adtraceConfig.coppaCompliantEnabled) { + return null; + } + + return Reflection.getImeiParameters(adtraceConfig.context, logger); + } + private static Map getOaidParameters(final AdTraceConfig adtraceConfig, + final ILogger logger) + { + if (adtraceConfig.coppaCompliantEnabled) { + return null; + } + + return Reflection.getOaidParameters(adtraceConfig.context, logger); + } + private static String getFireAdvertisingId(final AdTraceConfig adtraceConfig) { + if (adtraceConfig.coppaCompliantEnabled) { + return null; + } + + return getFireAdvertisingId(adtraceConfig.context.getContentResolver()); + } + private static String getFireAdvertisingId(final ContentResolver contentResolver) { + if (contentResolver == null) { + return null; + } + try { + // get advertising + return Settings.Secure.getString(contentResolver, "advertising_id"); + } catch (Exception ex) { + // not supported + } + return null; + } + private static Boolean getFireTrackingEnabled(final AdTraceConfig adtraceConfig) { + if (adtraceConfig.coppaCompliantEnabled) { + return null; + } + + return getFireTrackingEnabled(adtraceConfig.context.getContentResolver()); + } + private static Boolean getFireTrackingEnabled(final ContentResolver contentResolver) { + try { + // get user's tracking preference + return Settings.Secure.getInt(contentResolver, "limit_ad_tracking") == 0; + } catch (Exception ex) { + // not supported + } + return null; + } + private static int getConnectivityType(final Context context, final ILogger logger) { + try { + ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + + if (cm == null) { + return -1; + } + + // for api 22 or lower, still need to get raw type + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); + return activeNetwork.getType(); + } + + // .getActiveNetwork() is only available from api 23 + Network activeNetwork = cm.getActiveNetwork(); + if (activeNetwork == null) { + return -1; + } + + NetworkCapabilities activeNetworkCapabilities = cm.getNetworkCapabilities(activeNetwork); + if (activeNetworkCapabilities == null) { + return -1; + } + + // check each network capability available from api 23 + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { + return NetworkCapabilities.TRANSPORT_WIFI; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { + return NetworkCapabilities.TRANSPORT_CELLULAR; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) { + return NetworkCapabilities.TRANSPORT_ETHERNET; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { + return NetworkCapabilities.TRANSPORT_VPN; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) { + return NetworkCapabilities.TRANSPORT_BLUETOOTH; + } + + // only after api 26, that more transport capabilities were added + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + return -1; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE)) { + return NetworkCapabilities.TRANSPORT_WIFI_AWARE; + } + + // and then after api 27, that more transport capabilities were added + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) { + return -1; + } + + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_LOWPAN)) { + return NetworkCapabilities.TRANSPORT_LOWPAN; + } + } catch (Exception e) { + logger.warn("Couldn't read connectivity type (%s)", e.getMessage()); + } + + return -1; + } + public static String getMcc(final Context context, final ILogger logger) { + try { + TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + String networkOperator = tel.getNetworkOperator(); + + if (TextUtils.isEmpty(networkOperator)) { + AdTraceFactory.getLogger().warn("Couldn't receive networkOperator string to read MCC"); + return null; + } + return networkOperator.substring(0, 3); + } catch (Exception ex) { + AdTraceFactory.getLogger().warn("Couldn't return mcc"); + return null; + } + } + + private static String getMnc(final Context context, final ILogger logger) { + try { + TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + String networkOperator = tel.getNetworkOperator(); + + if (TextUtils.isEmpty(networkOperator)) { + AdTraceFactory.getLogger().warn("Couldn't receive networkOperator string to read MNC"); + return null; + } + return networkOperator.substring(3); + } catch (Exception ex) { + logger.warn("Couldn't return mnc"); + return null; + } + } + } } diff --git a/android-sdk/src/main/java/io/adtrace/sdk/PackageBuilder.java b/android-sdk/src/main/java/io/adtrace/sdk/PackageBuilder.java index fd3d208..4032e6f 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/PackageBuilder.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/PackageBuilder.java @@ -280,17 +280,17 @@ ActivityPackage buildVerificationPackage(AdTracePurchase purchase, OnPurchaseVer private Map getSessionParameters(boolean isInDelay) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Callback and partner parameters. @@ -306,8 +306,8 @@ private Map getSessionParameters(boolean isInDelay) { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -323,7 +323,7 @@ private Map getSessionParameters(boolean isInDelay) { PackageBuilder.addString(parameters, "app_token", adtraceConfig.appToken); PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -344,8 +344,8 @@ private Map getSessionParameters(boolean isInDelay) { PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastInterval); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); @@ -373,17 +373,17 @@ private Map getSessionParameters(boolean isInDelay) { public Map getEventParameters(AdTraceEvent event, boolean isInDelay) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Callback and partner parameters. @@ -400,8 +400,8 @@ public Map getEventParameters(AdTraceEvent event, boolean isInDe PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -417,7 +417,7 @@ public Map getEventParameters(AdTraceEvent event, boolean isInDe PackageBuilder.addString(parameters, "app_token", adtraceConfig.appToken); PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -440,8 +440,8 @@ public Map getEventParameters(AdTraceEvent event, boolean isInDe PackageBuilder.addString(parameters, "hardware_name", deviceInfo.hardwareName); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastIntervalHardReset); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); @@ -472,17 +472,17 @@ public Map getEventParameters(AdTraceEvent event, boolean isInDe private Map getInfoParameters(String source) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -492,8 +492,8 @@ private Map getInfoParameters(String source) { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -529,17 +529,17 @@ private Map getInfoParameters(String source) { private Map getClickParameters(String source) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -549,8 +549,8 @@ private Map getClickParameters(String source) { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -578,7 +578,7 @@ private Map getClickParameters(String source) { PackageBuilder.addDateInMilliseconds(parameters, "click_time", clickTimeInMilliseconds); PackageBuilder.addDateInSeconds(parameters, "click_time", clickTimeInSeconds); PackageBuilder.addDateInSeconds(parameters, "click_time_server", clickTimeServerInSeconds); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -605,8 +605,8 @@ private Map getClickParameters(String source) { PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastIntervalHardReset); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); @@ -643,17 +643,17 @@ private Map getClickParameters(String source) { private Map getAttributionParameters(String initiatedBy) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -663,8 +663,8 @@ private Map getAttributionParameters(String initiatedBy) { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -708,17 +708,17 @@ private Map getAttributionParameters(String initiatedBy) { private Map getGdprParameters() { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -728,8 +728,8 @@ private Map getGdprParameters() { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -772,17 +772,17 @@ private Map getGdprParameters() { private Map getDisableThirdPartySharingParameters() { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -792,8 +792,8 @@ private Map getDisableThirdPartySharingParameters() { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -838,17 +838,17 @@ private Map getDisableThirdPartySharingParameters() { (final AdTraceThirdPartySharing adtraceThirdPartySharing) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Third Party Sharing @@ -870,8 +870,8 @@ private Map getDisableThirdPartySharingParameters() { PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -915,17 +915,17 @@ private Map getMeasurementConsentParameters( final boolean consentMeasurement) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Measurement Consent @@ -939,8 +939,8 @@ private Map getMeasurementConsentParameters( PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -982,17 +982,17 @@ private Map getMeasurementConsentParameters( private Map getAdRevenueParameters(String source, JSONObject adRevenueJson) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -1002,8 +1002,8 @@ private Map getAdRevenueParameters(String source, JSONObject adR PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -1019,7 +1019,7 @@ private Map getAdRevenueParameters(String source, JSONObject adR PackageBuilder.addString(parameters, "app_token", adtraceConfig.appToken); PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -1040,8 +1040,8 @@ private Map getAdRevenueParameters(String source, JSONObject adR PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastInterval); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); @@ -1071,17 +1071,17 @@ private Map getAdRevenueParameters(String source, JSONObject adR private Map getAdRevenueParameters(AdTraceAdRevenue adtraceAdRevenue, boolean isInDelay) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Callback and partner parameters. @@ -1097,8 +1097,8 @@ private Map getAdRevenueParameters(AdTraceAdRevenue adtraceAdRev PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -1114,7 +1114,7 @@ private Map getAdRevenueParameters(AdTraceAdRevenue adtraceAdRev PackageBuilder.addString(parameters, "app_token", adtraceConfig.appToken); PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -1135,8 +1135,8 @@ private Map getAdRevenueParameters(AdTraceAdRevenue adtraceAdRev PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastInterval); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); @@ -1171,17 +1171,17 @@ private Map getAdRevenueParameters(AdTraceAdRevenue adtraceAdRev private Map getSubscriptionParameters(AdTracePlayStoreSubscription subscription, boolean isInDelay) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -1191,8 +1191,8 @@ private Map getSubscriptionParameters(AdTracePlayStoreSubscripti PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); PackageBuilder.addString(parameters, "google_app_set_id", deviceInfo.appSetId); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { @@ -1214,7 +1214,7 @@ private Map getSubscriptionParameters(AdTracePlayStoreSubscripti PackageBuilder.addString(parameters, "app_token", adtraceConfig.appToken); PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -1235,8 +1235,8 @@ private Map getSubscriptionParameters(AdTracePlayStoreSubscripti PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastInterval); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); @@ -1274,17 +1274,17 @@ private Map getSubscriptionParameters(AdTracePlayStoreSubscripti private Map getVerificationParameters(AdTracePurchase purchase) { Map parameters = new HashMap(); - Map imeiParameters = Util.getImeiParameters(adtraceConfig, logger); + + deviceInfo.reloadOtherDeviceInfoParams(adtraceConfig, logger); // Check if plugin is used and if yes, add read parameters. - if (imeiParameters != null) { - parameters.putAll(imeiParameters); + if (deviceInfo.imeiParameters != null) { + parameters.putAll(deviceInfo.imeiParameters); } // Check if oaid plugin is used and if yes, add the parameter - Map oaidParameters = Util.getOaidParameters(adtraceConfig, logger); - if (oaidParameters != null) { - parameters.putAll(oaidParameters); + if (deviceInfo.oaidParameters != null) { + parameters.putAll(deviceInfo.oaidParameters); } // Device identifiers. @@ -1294,8 +1294,8 @@ private Map getVerificationParameters(AdTracePurchase purchase) PackageBuilder.addLong(parameters, "gps_adid_attempt", deviceInfo.playAdIdAttempt); PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); - PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(adtraceConfig)); - PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(adtraceConfig)); + PackageBuilder.addString(parameters, "fire_adid", deviceInfo.fireAdId); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", deviceInfo.fireTrackingEnabled); if (!containsPlayIds(parameters) && !containsFireIds(parameters)) { logger.warn("Google Advertising ID or Fire Advertising ID not detected, " + @@ -1310,7 +1310,7 @@ private Map getVerificationParameters(AdTracePurchase purchase) PackageBuilder.addString(parameters, "app_token", adtraceConfig.appToken); PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); - PackageBuilder.addLong(parameters, "connectivity_type", Util.getConnectivityType(adtraceConfig.context)); + PackageBuilder.addLong(parameters, "connectivity_type", deviceInfo.connectivityType); PackageBuilder.addString(parameters, "country", deviceInfo.country); PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); @@ -1331,8 +1331,8 @@ private Map getVerificationParameters(AdTracePurchase purchase) PackageBuilder.addString(parameters, "installed_at", deviceInfo.appInstallTime); PackageBuilder.addString(parameters, "language", deviceInfo.language); PackageBuilder.addDuration(parameters, "last_interval", activityStateCopy.lastInterval); - PackageBuilder.addString(parameters, "mcc", Util.getMcc(adtraceConfig.context)); - PackageBuilder.addString(parameters, "mnc", Util.getMnc(adtraceConfig.context)); + PackageBuilder.addString(parameters, "mcc", deviceInfo.mcc); + PackageBuilder.addString(parameters, "mnc", deviceInfo.mnc); PackageBuilder.addBoolean(parameters, "needs_response_details", true); PackageBuilder.addString(parameters, "os_build", deviceInfo.buildName); PackageBuilder.addString(parameters, "os_name", deviceInfo.osName); diff --git a/android-sdk/src/main/java/io/adtrace/sdk/Util.java b/android-sdk/src/main/java/io/adtrace/sdk/Util.java index f826256..5b5b68d 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/Util.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/Util.java @@ -1,19 +1,14 @@ package io.adtrace.sdk; -import android.content.ContentResolver; +import static io.adtrace.sdk.Constants.ENCODING; +import static io.adtrace.sdk.Constants.SHA256; + import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.net.ConnectivityManager; -import android.net.Network; -import android.net.NetworkCapabilities; -import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.LocaleList; -import android.provider.Settings.Secure; -import android.telephony.TelephonyManager; -import android.text.TextUtils; import io.adtrace.sdk.scheduler.AsyncTaskExecutor; import io.adtrace.sdk.scheduler.SingleThreadFutureScheduler; @@ -48,9 +43,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static io.adtrace.sdk.Constants.ENCODING; -import static io.adtrace.sdk.Constants.SHA256; - /** * AdTrace android SDK (https://adtrace.io) * Created by Nasser Amini (github.com/namini40) on April 2022. @@ -525,127 +517,6 @@ public static Locale getLocale(Configuration configuration) { return null; } - public static String getFireAdvertisingId(ContentResolver contentResolver) { - if (contentResolver == null) { - return null; - } - try { - // get advertising - return Secure.getString(contentResolver, "advertising_id"); - } catch (Exception ex) { - // not supported - } - return null; - } - - public static Boolean getFireTrackingEnabled(ContentResolver contentResolver) { - try { - // get user's tracking preference - return Secure.getInt(contentResolver, "limit_ad_tracking") == 0; - } catch (Exception ex) { - // not supported - } - return null; - } - - public static int getConnectivityType(Context context) { - try { - ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - - if (cm == null) { - return -1; - } - - // for api 22 or lower, still need to get raw type - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); - return activeNetwork.getType(); - } - - // .getActiveNetwork() is only available from api 23 - Network activeNetwork = cm.getActiveNetwork(); - if (activeNetwork == null) { - return -1; - } - - NetworkCapabilities activeNetworkCapabilities = cm.getNetworkCapabilities(activeNetwork); - if (activeNetworkCapabilities == null) { - return -1; - } - - // check each network capability available from api 23 - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { - return NetworkCapabilities.TRANSPORT_WIFI; - } - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { - return NetworkCapabilities.TRANSPORT_CELLULAR; - } - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) { - return NetworkCapabilities.TRANSPORT_ETHERNET; - } - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { - return NetworkCapabilities.TRANSPORT_VPN; - } - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) { - return NetworkCapabilities.TRANSPORT_BLUETOOTH; - } - - // only after api 26, that more transport capabilities were added - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { - return -1; - } - - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE)) { - return NetworkCapabilities.TRANSPORT_WIFI_AWARE; - } - - // and then after api 27, that more transport capabilities were added - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) { - return -1; - } - - if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_LOWPAN)) { - return NetworkCapabilities.TRANSPORT_LOWPAN; - } - } catch (Exception e) { - getLogger().warn("Couldn't read connectivity type (%s)", e.getMessage()); - } - - return -1; - } - - public static String getMcc(Context context) { - try { - TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - String networkOperator = tel.getNetworkOperator(); - - if (TextUtils.isEmpty(networkOperator)) { - AdTraceFactory.getLogger().warn("Couldn't receive networkOperator string to read MCC"); - return null; - } - return networkOperator.substring(0, 3); - } catch (Exception ex) { - AdTraceFactory.getLogger().warn("Couldn't return mcc"); - return null; - } - } - - public static String getMnc(Context context) { - try { - TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - String networkOperator = tel.getNetworkOperator(); - - if (TextUtils.isEmpty(networkOperator)) { - AdTraceFactory.getLogger().warn("Couldn't receive networkOperator string to read MNC"); - return null; - } - return networkOperator.substring(3); - } catch (Exception ex) { - AdTraceFactory.getLogger().warn("Couldn't return mnc"); - return null; - } - } - public static String formatString(String format, Object... args) { return String.format(Locale.US, format, args); } @@ -790,37 +661,9 @@ public static boolean canReadNonPlayIds(final AdTraceConfig adtraceConfig) { return true; } - public static Map getImeiParameters(final AdTraceConfig adtraceConfig, ILogger logger) { - if (adtraceConfig.coppaCompliantEnabled) { - return null; - } - - return Reflection.getImeiParameters(adtraceConfig.context, logger); - } - - public static Map getOaidParameters(final AdTraceConfig adtraceConfig, ILogger logger) { - if (adtraceConfig.coppaCompliantEnabled) { - return null; - } - - return Reflection.getOaidParameters(adtraceConfig.context, logger); - } - - public static String getFireAdvertisingId(final AdTraceConfig adtraceConfig) { - if (adtraceConfig.coppaCompliantEnabled) { - return null; - } - return getFireAdvertisingId(adtraceConfig.context.getContentResolver()); - } - public static Boolean getFireTrackingEnabled(final AdTraceConfig adtraceConfig) { - if (adtraceConfig.coppaCompliantEnabled) { - return null; - } - return getFireTrackingEnabled(adtraceConfig.context.getContentResolver()); - } public static boolean isGooglePlayGamesForPC(final Context context) { PackageManager pm = context.getPackageManager(); diff --git a/android-sdk/src/main/java/io/adtrace/sdk/network/UrlStrategy.java b/android-sdk/src/main/java/io/adtrace/sdk/network/UrlStrategy.java index 957a7e8..399dcfa 100644 --- a/android-sdk/src/main/java/io/adtrace/sdk/network/UrlStrategy.java +++ b/android-sdk/src/main/java/io/adtrace/sdk/network/UrlStrategy.java @@ -11,6 +11,7 @@ import static io.adtrace.sdk.AdTraceConfig.DATA_RESIDENCY_US; import static io.adtrace.sdk.AdTraceConfig.URL_STRATEGY_CHINA; import static io.adtrace.sdk.AdTraceConfig.URL_STRATEGY_CN; +import static io.adtrace.sdk.AdTraceConfig.URL_STRATEGY_CN_ONLY; import static io.adtrace.sdk.AdTraceConfig.URL_STRATEGY_INDIA; import static io.adtrace.sdk.AdTraceConfig.DATA_RESIDENCY_EU; @@ -160,14 +161,15 @@ public String targetUrlByActivityKind(final ActivityKind activityKind) { } } - private static List baseUrlChoices(final String urlStrategy) - { + private static List baseUrlChoices(final String urlStrategy) { if (URL_STRATEGY_INDIA.equals(urlStrategy)) { return Arrays.asList(BASE_URL_INDIA, Constants.BASE_URL); } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { return Arrays.asList(BASE_URL_CHINA, Constants.BASE_URL); } else if (URL_STRATEGY_CN.equals(urlStrategy)) { return Arrays.asList(BASE_URL_CN, Constants.BASE_URL); + } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { + return Arrays.asList(BASE_URL_CN); } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { return Collections.singletonList(BASE_URL_EU); } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { @@ -178,14 +180,15 @@ private static List baseUrlChoices(final String urlStrategy) return Arrays.asList(Constants.BASE_URL, BASE_URL_INDIA, BASE_URL_CHINA); } } - private static List gdprUrlChoices(final String urlStrategy) - { + private static List gdprUrlChoices(final String urlStrategy) { if (URL_STRATEGY_INDIA.equals(urlStrategy)) { return Arrays.asList(GDPR_URL_INDIA, Constants.GDPR_URL); } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { return Arrays.asList(GDPR_URL_CHINA, Constants.GDPR_URL); } else if (URL_STRATEGY_CN.equals(urlStrategy)) { return Arrays.asList(GDPR_URL_CN, Constants.GDPR_URL); + } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { + return Arrays.asList(GDPR_URL_CN); } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { return Collections.singletonList(GDPR_URL_EU); } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { @@ -196,14 +199,15 @@ private static List gdprUrlChoices(final String urlStrategy) return Arrays.asList(Constants.GDPR_URL, GDPR_URL_INDIA, GDPR_URL_CHINA); } } - private static List subscriptionUrlChoices(final String urlStrategy) - { + private static List subscriptionUrlChoices(final String urlStrategy) { if (URL_STRATEGY_INDIA.equals(urlStrategy)) { return Arrays.asList(SUBSCRIPTION_URL_INDIA, Constants.SUBSCRIPTION_URL); } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { return Arrays.asList(SUBSCRIPTION_URL_CHINA, Constants.SUBSCRIPTION_URL); } else if (URL_STRATEGY_CN.equals(urlStrategy)) { return Arrays.asList(SUBSCRIPTION_URL_CN, Constants.SUBSCRIPTION_URL); + } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { + return Arrays.asList(SUBSCRIPTION_URL_CN); } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { return Collections.singletonList(SUBSCRIPTION_URL_EU); } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { @@ -223,6 +227,8 @@ private static List purchaseVerificationUrlChoices(final String urlStrat return Arrays.asList(PURCHASE_VERIFICATION_URL_CHINA, Constants.PURCHASE_VERIFICATION_URL); } else if (URL_STRATEGY_CN.equals(urlStrategy)) { return Arrays.asList(PURCHASE_VERIFICATION_URL_CN, Constants.PURCHASE_VERIFICATION_URL); + } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { + return Arrays.asList(PURCHASE_VERIFICATION_URL_CN); } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { return Collections.singletonList(PURCHASE_VERIFICATION_URL_EU); } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { diff --git a/build.gradle b/build.gradle index 89e72d2..0e1db2f 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ ext { coreMinSdkVersion = 9 coreCompileSdkVersion = 33 coreTargetSdkVersion = 33 - coreVersionName = '2.5.0' + coreVersionName = '2.5.1' defaultVersionCode = 1 webbridgeMinSdkVersion = 17 samsungReferrerMinSdkVersion = 18 diff --git a/doc/english/oaid.md b/doc/english/oaid.md index 2bbd888..d88bca5 100644 --- a/doc/english/oaid.md +++ b/doc/english/oaid.md @@ -12,8 +12,8 @@ To enable the AdTrace SDK to collect and track OAID, follow these steps. To only If you are using Maven, add the following OAID plugin dependency to your `build.gradle` file next to the existing AdTrace SDK dependency: ```groovy -implementation 'io.adtrace:android-sdk:2.5.0' -implementation 'io.adtrace:android-sdk-plugin-oaid:2.5.0' +implementation 'io.adtrace:android-sdk:2.5.1' +implementation 'io.adtrace:android-sdk-plugin-oaid:2.5.1' ``` You can also add the AdTrace OAID plugin as JAR file, which you can download from our [releases page][releases].