Skip to content

Commit

Permalink
Merge branch 'release/3.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Dec 23, 2021
2 parents 8222fbe + 254e136 commit 14ae7ba
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 3.0.2 (2021-12-23)
--------------------------
Fix updating IDFA during app runtime (#492)

Version 3.0.1 (2021-12-17)
--------------------------
Do not allow multiple state machines with the same ID (#489)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1
3.0.2
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

subprojects {
group = 'com.snowplowanalytics'
version = '3.0.1'
version = '3.0.2'
repositories {
google()
maven {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ systemProp.org.gradle.internal.http.socketTimeout=120000
SONATYPE_STAGING_PROFILE=comsnowplowanalytics
GROUP=com.snowplowanalytics
POM_ARTIFACT_ID=snowplow-android-tracker
VERSION_NAME=3.0.1
VERSION_NAME=3.0.2

POM_NAME=snowplow-android-tracker
POM_PACKAGING=aar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

public class MockDeviceInfoMonitor extends DeviceInfoMonitor {
@NonNull private Map<String, Integer> methodAccessCounts = new HashMap<String, Integer>();
@Nullable public String customIdfa = "XJKLJSALFKJ";

@NonNull
@Override
Expand Down Expand Up @@ -67,7 +68,7 @@ public String getCarrier(@NonNull Context context) {
@Override
public String getAndroidIdfa(@NonNull Context context) {
increaseMethodAccessCount("getAndroidIdfa");
return "XJKLJSALFKJ";
return customIdfa;
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ public void doesntUpdateNonEphemeralInfo() {
assertEquals(1, deviceInfoMonitor.getMethodAccessCount("getTotalStorage"));
}

@Test
public void doesntUpdateIdfaIfNotNull() {
MockDeviceInfoMonitor deviceInfoMonitor = new MockDeviceInfoMonitor();
PlatformContext platformContext = new PlatformContext(0, 1, deviceInfoMonitor, getContext());
assertEquals(1, deviceInfoMonitor.getMethodAccessCount("getAndroidIdfa"));
platformContext.getMobileContext();
assertEquals(1, deviceInfoMonitor.getMethodAccessCount("getAndroidIdfa"));
}

@Test
public void updatesIdfaIfEmptyOrNull() {
MockDeviceInfoMonitor deviceInfoMonitor = new MockDeviceInfoMonitor();
deviceInfoMonitor.customIdfa = "";
PlatformContext platformContext = new PlatformContext(0, 1, deviceInfoMonitor, getContext());
assertEquals(1, deviceInfoMonitor.getMethodAccessCount("getAndroidIdfa"));
deviceInfoMonitor.customIdfa = null;
platformContext.getMobileContext();
assertEquals(2, deviceInfoMonitor.getMethodAccessCount("getAndroidIdfa"));
platformContext.getMobileContext();
assertEquals(3, deviceInfoMonitor.getMethodAccessCount("getAndroidIdfa"));
}

// --- PRIVATE

private Context getContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private void setPlatformDict() {
Util.addToMap(Parameters.DEVICE_MODEL, deviceInfoMonitor.getDeviceModel(), pairs);
Util.addToMap(Parameters.DEVICE_MANUFACTURER, deviceInfoMonitor.getDeviceVendor(), pairs);
Util.addToMap(Parameters.CARRIER, deviceInfoMonitor.getCarrier(context), pairs);
Util.addToMap(Parameters.ANDROID_IDFA, deviceInfoMonitor.getAndroidIdfa(context), pairs);
Util.addToMap(Parameters.PHYSICAL_MEMORY, deviceInfoMonitor.getPhysicalMemory(context), pairs);
Util.addToMap(Parameters.TOTAL_STORAGE, deviceInfoMonitor.getTotalStorage(), pairs);

Expand All @@ -109,6 +108,11 @@ private void setPlatformDict() {
private void setEphemeralPlatformDict() {
lastUpdatedEphemeralPlatformDict = System.currentTimeMillis();

Object currentIdfa = pairs.get(Parameters.ANDROID_IDFA);
if (currentIdfa == null || currentIdfa.toString().isEmpty()) {
Util.addToMap(Parameters.ANDROID_IDFA, deviceInfoMonitor.getAndroidIdfa(context), pairs);
}

Pair<String, Integer> batteryInfo = deviceInfoMonitor.getBatteryStateAndLevel(context);
if (batteryInfo != null) {
Util.addToMap(Parameters.BATTERY_STATE, batteryInfo.first, pairs);
Expand Down

0 comments on commit 14ae7ba

Please sign in to comment.