Skip to content

Commit

Permalink
release: SDK 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Jun 13, 2024
1 parent b8811f4 commit 6de7c98
Show file tree
Hide file tree
Showing 10 changed files with 11,901 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Sources/buildSrc/src/main/java/Consts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object ProjectConsts {
}

object SDKConsts {
const val VERSION = "2.0.2"
const val VERSION = "2.0.3"
const val API_LEVEL = 200
const val MESSAGING_API_LEVEL = 12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ public void remove(@NonNull String key) {
preferences.edit().remove(key).apply();
}

/**
* Clear all values from the Shared Preferences
*/
@AnyThread
public void clear() {
preferences.edit().clear().apply();
}

/**
* Get the Shared Preferences in a Future
*
Expand Down
10 changes: 10 additions & 0 deletions Sources/sdk/src/main/java/com/batch/android/core/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,14 @@ public void remove(String key) {

KVUserPreferencesStorageProvider.get(applicationContext).remove(PARAMETERS_KEY_PREFIX + key);
}

/**
* Clear all parameters
*/
public void wipeData() {
synchronized (cacheParameters) {
cacheParameters.clear();
}
KVUserPreferencesStorageProvider.get(applicationContext).clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private SystemParameterRegistry(@NonNull Context context) {

SystemParameter deviceType = new WatchedSystemParameter(
context,
SystemParameterShortName.DEVICE_TYPE,
SystemParameterShortName.DEVICE_MODEL,
SystemParameterHelper::getDeviceModel,
Boolean.TRUE.equals(DataCollectionModuleProvider.get().getDataCollectionConfig().isDeviceModelEnabled())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum SystemParameterShortName {

OS_SDK_LEVEL("sdk", "os_sdk_level"),

DEVICE_TYPE("dty", "device_type"),
DEVICE_MODEL("dty", "device_model"),

DEVICE_LANGUAGE("dla", "device_language"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void onDataCollectionConfigChanged(@NonNull BatchDataCollectionConfig co
config.isDeviceModelEnabled() != this.dataCollectionConfig.isDeviceModelEnabled()
) {
SystemParameter deviceModelParameter = registry.getSystemParamByShortname(
SystemParameterShortName.DEVICE_TYPE.shortName
SystemParameterShortName.DEVICE_MODEL.shortName
);
if (deviceModelParameter != null) {
deviceModelParameter.setAllowed(Boolean.TRUE.equals(config.isDeviceModelEnabled()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import androidx.annotation.VisibleForTesting;
import com.batch.android.BatchOptOutResultListener;
import com.batch.android.core.Logger;
import com.batch.android.core.ParameterKeys;
import com.batch.android.core.Parameters;
import com.batch.android.core.Promise;
import com.batch.android.di.providers.DisplayReceiptModuleProvider;
Expand Down Expand Up @@ -185,17 +184,7 @@ public void wipeData(Context context) {
LocalCampaignsModuleProvider.get().wipeData(context);
DisplayReceiptModuleProvider.get().wipeData(context);
InboxDatasourceProvider.get(context).wipeData();

Parameters parameters = ParametersProvider.get(context);
parameters.remove(ParameterKeys.CUSTOM_ID);
parameters.remove(ParameterKeys.INSTALL_ID_KEY);
parameters.remove(ParameterKeys.INSTALL_TIMESTAMP_KEY);
parameters.remove(ParameterKeys.PUSH_APP_VERSION_KEY);
parameters.remove(ParameterKeys.PUSH_REGISTRATION_PROVIDER_KEY);
parameters.remove(ParameterKeys.PUSH_REGISTRATION_ID_KEY);
// Old keys
parameters.remove("push.token");
parameters.remove("push.token.provider");
ParametersProvider.get(context).wipeData();
}

//region: BatchModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DataCollectionModuleTest : DITest() {
.track(ArgumentMatchers.eq(InternalEvents.NATIVE_DATA_CHANGED), JSONObjectMockitoMatcher.eq(JSONObject().apply {
put("geoip_resolution", true)
put("device_brand", "Android")
put("device_type", "robolectric")
put("device_model", "robolectric")
}))

// Disable only geoip
Expand All @@ -88,7 +88,7 @@ class DataCollectionModuleTest : DITest() {
Mockito.verify(trackerModule, Mockito.times(1))
.track(ArgumentMatchers.eq(InternalEvents.NATIVE_DATA_CHANGED), JSONObjectMockitoMatcher.eq(JSONObject().apply {
put("device_brand", JSONObject.NULL)
put("device_type", JSONObject.NULL)
put("device_model", JSONObject.NULL)
}))

Mockito.reset(trackerModule)
Expand All @@ -106,7 +106,7 @@ class DataCollectionModuleTest : DITest() {
// Check default disabled param are not is ids
WebserviceParameterUtils.getWebserviceIdsAsJson(context).apply {
Assert.assertFalse(has(SystemParameterShortName.DEVICE_BRAND.shortName))
Assert.assertFalse(has(SystemParameterShortName.DEVICE_TYPE.shortName))
Assert.assertFalse(has(SystemParameterShortName.DEVICE_MODEL.shortName))
Assert.assertFalse(getJSONObject("data_collection").getBoolean("geoip"))
}

Expand All @@ -118,7 +118,7 @@ class DataCollectionModuleTest : DITest() {
// Check values are in the ids
WebserviceParameterUtils.getWebserviceIdsAsJson(context).apply {
Assert.assertEquals("Android", get(SystemParameterShortName.DEVICE_BRAND.shortName))
Assert.assertEquals("robolectric", get(SystemParameterShortName.DEVICE_TYPE.shortName))
Assert.assertEquals("robolectric", get(SystemParameterShortName.DEVICE_MODEL.shortName))
Assert.assertTrue(getJSONObject("data_collection").getBoolean("geoip"))
}

Expand All @@ -130,7 +130,7 @@ class DataCollectionModuleTest : DITest() {
// Check disabled param are not is ids
WebserviceParameterUtils.getWebserviceIdsAsJson(context).apply {
Assert.assertFalse(has(SystemParameterShortName.DEVICE_BRAND.shortName))
Assert.assertFalse(has(SystemParameterShortName.DEVICE_TYPE.shortName))
Assert.assertFalse(has(SystemParameterShortName.DEVICE_MODEL.shortName))
Assert.assertFalse(getJSONObject("data_collection").getBoolean("geoip"))
}
}
Expand Down
1 change: 1 addition & 0 deletions proguard-mappings/2.0.3/checksum.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8ebb9eef2671e7f8064a447e838f8dba5e600a47 public-sdk/Batch.aar
Loading

0 comments on commit 6de7c98

Please sign in to comment.