Skip to content

Commit 9824957

Browse files
runnerrunner
authored andcommitted
Release 4.4.1
1 parent d25a3c7 commit 9824957

36 files changed

+305
-87
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.unity3d.ads.example"
88
minSdkVersion 19
99
targetSdkVersion 30
10-
versionCode = 4400
11-
versionName = "4.4.0"
10+
versionCode = 4410
11+
versionName = "4.4.1"
1212
}
1313

1414
buildTypes {

unity-ads/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ if (project.rootProject.file('local.properties').exists()) {
1010
ext {
1111
GROUP_ID = "com.unity3d.ads"
1212
ARTIFACT_ID = "unity-ads"
13-
VERSION_ID = "4.4.0"
14-
VERSION_CODE = 4400
13+
VERSION_ID = "4.4.1"
14+
VERSION_CODE = 4410
1515
SIGN_AAR = properties.getProperty("SIGN_AAR") ?: false
1616
}
1717

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/configuration/ExperimentObjectTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void testExperimentObjectWithInvalid() throws JSONException {
3232
public void testExperimentObjectWithValueOnly() throws JSONException {
3333
ExperimentObject exp = new ExperimentObject(new JSONObject("{\"value\": \"true\"}"));
3434
Assert.assertTrue(exp.getBooleanValue());
35+
Assert.assertEquals(ExperimentAppliedRule.NEXT, exp.getAppliedRule());
3536
}
3637

3738
@Test

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/configuration/ExperimentObjectsTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.unity3d.ads.test.instrumentation.services.core.configuration;
22

3-
import com.unity3d.services.core.configuration.ExperimentAppliedRule;
4-
import com.unity3d.services.core.configuration.ExperimentObject;
53
import com.unity3d.services.core.configuration.ExperimentObjects;
64
import com.unity3d.services.core.configuration.IExperiments;
75

@@ -18,22 +16,23 @@ public class ExperimentObjectsTest {
1816
@Test
1917
public void testExperimentObjectsNull() {
2018
IExperiments expo = new ExperimentObjects(null);
21-
Assert.assertFalse(expo.isTwoStageInitializationEnabled());
22-
Assert.assertFalse(expo.isNativeTokenEnabled());
19+
Assert.assertTrue(expo.isTwoStageInitializationEnabled());
20+
Assert.assertTrue(expo.isNativeTokenEnabled());
2321
}
2422

2523
@Test
2624
public void testExperimentObjectsWithInvalid() throws JSONException {
2725
ExperimentObjects expo = new ExperimentObjects(new JSONObject("{\"something\": false}"));
28-
Assert.assertFalse(expo.isTwoStageInitializationEnabled());
29-
Assert.assertFalse(expo.isNativeTokenEnabled());
26+
Assert.assertTrue(expo.isTwoStageInitializationEnabled());
27+
Assert.assertTrue(expo.isNativeTokenEnabled());
3028
}
3129

3230
@Test
3331
public void testExperimentObjects() throws JSONException {
3432
IExperiments expo = new ExperimentObjects(new JSONObject("{\"tsi\": {\"value\": \"true\"}}"));
3533
Assert.assertTrue(expo.isTwoStageInitializationEnabled());
36-
Assert.assertFalse(expo.isNativeTokenEnabled());
34+
Assert.assertTrue(expo.isNativeTokenEnabled());
35+
Assert.assertFalse(expo.isForwardExperimentsToWebViewEnabled());
3736
}
3837

3938
@Test

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/configuration/ExperimentsReaderTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@ public void testExperimentsReaderWithDefaults() {
3232
public void testExperimentsReaderWithLocalOnly() {
3333
ExperimentsReader experimentsReader = new ExperimentsReader();
3434
experimentsReader.updateLocalExperiments(_localExperimentsMock);
35+
Mockito.when(_localExperimentsMock.isTwoStageInitializationEnabled()).thenReturn(true);
3536
Assert.assertEquals(_localExperimentsMock, experimentsReader.getCurrentlyActiveExperiments());
3637
validateDefaultExperiments(experimentsReader.getCurrentlyActiveExperiments());
3738
}
3839

3940
@Test
4041
public void testExperimentsReaderWithRemoteOnly() throws JSONException {
41-
Mockito.when(_remoteExperimentsMock.getNextSessionExperiments()).thenReturn(new JSONObject("{\"tsi\":true}"));
42+
Mockito.when(_remoteExperimentsMock.getNextSessionExperiments()).thenReturn(new JSONObject("{\"tsi_upii\":true}"));
4243
Mockito.when(_remoteExperimentsMock.getCurrentSessionExperiments()).thenReturn(new JSONObject("{\"fff\":true}"));
4344

4445
ExperimentsReader experimentsReader = new ExperimentsReader();
4546
experimentsReader.updateRemoteExperiments(_remoteExperimentsMock);
4647

4748
IExperiments resultExperiments = experimentsReader.getCurrentlyActiveExperiments();
48-
Assert.assertFalse("Expected TSI flag to be false", resultExperiments.isTwoStageInitializationEnabled());
49+
Assert.assertFalse("Expected TSI_UPII flag to be false", resultExperiments.isUpdatePiiFields());
4950
Assert.assertTrue("Expected FFF flag to be true", resultExperiments.isForwardExperimentsToWebViewEnabled());
5051

5152
}
@@ -94,7 +95,7 @@ public void testExperimentsReaderWithLocalTsiEnabledAndRemoteFffEnabled() throws
9495

9596
private void validateDefaultExperiments(IExperiments experiments) {
9697
Assert.assertFalse(experiments.shouldNativeTokenAwaitPrivacy());
97-
Assert.assertFalse(experiments.isTwoStageInitializationEnabled());
98+
Assert.assertTrue(experiments.isTwoStageInitializationEnabled());
9899
Assert.assertFalse(experiments.isNativeWebViewCacheEnabled());
99100
Assert.assertFalse(experiments.isWebAssetAdCaching());
100101
}

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/configuration/ExperimentsTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public void testExperimentsGetCurrentSessionExperiments() throws JSONException {
109109

110110
private void validateDefaultExperiments(Experiments experiments) {
111111
Assert.assertFalse(experiments.shouldNativeTokenAwaitPrivacy());
112-
Assert.assertFalse(experiments.isTwoStageInitializationEnabled());
112+
Assert.assertTrue(experiments.isTwoStageInitializationEnabled());
113+
Assert.assertTrue(experiments.isNativeTokenEnabled());
114+
Assert.assertTrue(experiments.isPrivacyRequestEnabled());
113115
Assert.assertFalse(experiments.isNativeWebViewCacheEnabled());
114116
Assert.assertFalse(experiments.isWebAssetAdCaching());
115117
Assert.assertFalse(experiments.isNewLifecycleTimer());

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/device/AsyncTokenStorageTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void testGetTokenBeforeInit() {
116116

117117
@Test
118118
public void testGetTokenBeforeInitAndTimeout() {
119-
Metric _metric = TSIMetric.newAsyncTokenNull(new HashMap<String, String>(){{
119+
Metric _metric = TSIMetric.newNativeGeneratedTokenNull(new HashMap<String, String>(){{
120120
put ("state", "initializing");
121121
}});
122122

@@ -133,7 +133,7 @@ public void testGetTokenBeforeInitAndTimeout() {
133133

134134
@Test
135135
public void testGetTokenBeforeInitAndTimeoutGuard() {
136-
Metric _metric = TSIMetric.newAsyncTokenNull(new HashMap<String, String>(){{
136+
Metric _metric = TSIMetric.newNativeGeneratedTokenNull(new HashMap<String, String>(){{
137137
put ("state", "initializing");
138138
}});
139139

@@ -152,7 +152,7 @@ public void testGetTokenBeforeInitAndTimeoutGuard() {
152152

153153
@Test
154154
public void testGetTokenBeforeInitAndInitTimeTokenReady() {
155-
Metric _metric = TSIMetric.newAsyncTokenAvailable(new HashMap<String, String>(){{
155+
Metric _metric = TSIMetric.newNativeGeneratedTokenAvailable(new HashMap<String, String>(){{
156156
put ("state", "initializing");
157157
}});
158158

@@ -181,7 +181,7 @@ public void testGetTokenBeforeInitAndCreateEmptyQueue() throws JSONException {
181181

182182
@Test
183183
public void testGetTokenBeforeInitAndCreateQueueTokenReady() throws JSONException {
184-
Metric _metric = TSIMetric.newAsyncTokenAvailable(new HashMap<String, String>(){{
184+
Metric _metric = TSIMetric.newNativeGeneratedTokenAvailable(new HashMap<String, String>(){{
185185
put ("state", "initializing");
186186
}});
187187

@@ -243,7 +243,7 @@ public void testGetTokenAfterQueueTokenReady() throws JSONException {
243243

244244
@Test
245245
public void testMultipleCallsBeforeInit() throws JSONException {
246-
Metric _metric = TSIMetric.newAsyncTokenAvailable(new HashMap<String, String>(){{
246+
Metric _metric = TSIMetric.newNativeGeneratedTokenAvailable(new HashMap<String, String>(){{
247247
put ("state", "initializing");
248248
}});
249249

@@ -265,7 +265,7 @@ public void testMultipleCallsBeforeInit() throws JSONException {
265265

266266
@Test
267267
public void testMultipleCallsBeforeInitAndQueue() throws JSONException {
268-
Metric _metric = TSIMetric.newAsyncTokenAvailable(new HashMap<String, String>(){{
268+
Metric _metric = TSIMetric.newNativeGeneratedTokenAvailable(new HashMap<String, String>(){{
269269
put ("state", "initializing");
270270
}});
271271

@@ -294,7 +294,7 @@ public void testMultipleCallsBeforeInitAndQueue() throws JSONException {
294294

295295
@Test
296296
public void testMultipleCallsBeforeInitAndSingleAfterInit() throws JSONException {
297-
Metric _metric = TSIMetric.newAsyncTokenAvailable(new HashMap<String, String>(){{
297+
Metric _metric = TSIMetric.newNativeGeneratedTokenAvailable(new HashMap<String, String>(){{
298298
put ("state", "initializing");
299299
}});
300300

@@ -479,7 +479,7 @@ public void testDelayedConfigurationTwoConfigSets() throws JSONException {
479479

480480
@Test
481481
public void testDelayedConfigurationConfigurationArrivedFirst() throws JSONException {
482-
Metric _metric = TSIMetric.newAsyncTokenAvailable(new HashMap<String, String>(){{
482+
Metric _metric = TSIMetric.newNativeGeneratedTokenAvailable(new HashMap<String, String>(){{
483483
put ("state", "initializing");
484484
}});
485485
_asyncTokenStorage = new AsyncTokenStorage(_nativeTokenGenerator, _handler, _sdkMetrics);
@@ -559,4 +559,4 @@ public boolean sendEvent(Enum eventCategory, Enum eventId, Object... params) {
559559
return true;
560560
}
561561
}
562-
}
562+
}

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/device/DeviceInfoReaderBuilderTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.unity3d.services.core.configuration.PrivacyConfigStorage;
1414
import com.unity3d.services.core.device.reader.DeviceInfoReaderBuilder;
1515
import com.unity3d.services.core.device.reader.IDeviceInfoReader;
16+
import com.unity3d.services.core.device.reader.IGameSessionIdReader;
1617
import com.unity3d.services.core.lifecycle.CachedLifecycle;
1718
import com.unity3d.services.core.properties.ClientProperties;
1819

@@ -45,6 +46,9 @@ public class DeviceInfoReaderBuilderTest {
4546
@Mock
4647
PrivacyConfigStorage _privacyConfigStorageMock;
4748

49+
@Mock
50+
IGameSessionIdReader _gameSessionIdReaderMock;
51+
4852
@Before
4953
public void setup() {
5054
ClientProperties.setApplication((Application) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext());
@@ -60,7 +64,7 @@ public void setup() {
6064
@Test
6165
public void testDeviceInfoReaderBuilderWithPrivacy() {
6266
Mockito.when(_privacyConfigMock.allowedToSendPii()).thenReturn(true);
63-
DeviceInfoReaderBuilder deviceInfoReaderBuilder = new DeviceInfoReaderBuilder(_configReaderMock, _privacyConfigStorageMock);
67+
DeviceInfoReaderBuilder deviceInfoReaderBuilder = new DeviceInfoReaderBuilder(_configReaderMock, _privacyConfigStorageMock, _gameSessionIdReaderMock);
6468
IDeviceInfoReader deviceInfoReader = deviceInfoReaderBuilder.build();
6569
Map<String, Object> deviceInfoData = deviceInfoReader.getDeviceInfoData();
6670
Assert.assertNotNull(deviceInfoData.get(USER_NON_BEHAVIORAL_KEY));

unity-ads/src/androidTest/java/com/unity3d/ads/test/instrumentation/services/core/device/DeviceInfoReaderPrivacyBuilderTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.unity3d.services.core.configuration.PrivacyConfigStorage;
1212
import com.unity3d.services.core.device.reader.DeviceInfoReaderPrivacyBuilder;
1313
import com.unity3d.services.core.device.reader.IDeviceInfoReader;
14+
import com.unity3d.services.core.device.reader.IGameSessionIdReader;
1415
import com.unity3d.services.core.lifecycle.CachedLifecycle;
1516
import com.unity3d.services.core.properties.ClientProperties;
1617
import com.unity3d.services.core.properties.SdkProperties;
@@ -44,6 +45,9 @@ public class DeviceInfoReaderPrivacyBuilderTest {
4445
@Mock
4546
PrivacyConfigStorage _privacyConfigStorageMock;
4647

48+
@Mock
49+
IGameSessionIdReader _gameSessionIdReaderMock;
50+
4751
@Before
4852
public void setup() {
4953
ClientProperties.setApplication((Application) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext());
@@ -56,7 +60,7 @@ public void setup() {
5660

5761
@Test
5862
public void testDeviceInfoReaderPrivacyBuilder() {
59-
DeviceInfoReaderPrivacyBuilder deviceInfoReaderPrivacyBuilder = new DeviceInfoReaderPrivacyBuilder(_configReaderMock, _privacyConfigStorageMock);
63+
DeviceInfoReaderPrivacyBuilder deviceInfoReaderPrivacyBuilder = new DeviceInfoReaderPrivacyBuilder(_configReaderMock, _privacyConfigStorageMock, _gameSessionIdReaderMock);
6064
IDeviceInfoReader deviceInfoReader = deviceInfoReaderPrivacyBuilder.build();
6165
Map<String, Object> deviceInfoData = deviceInfoReader.getDeviceInfoData();
6266
Assert.assertEquals("privacy", deviceInfoData.get("callType"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.unity3d.ads.test.instrumentation.services.core.device;
2+
3+
import static com.unity3d.services.core.device.reader.JsonStorageKeyNames.GAME_SESSION_ID_NORMALIZED_KEY;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
7+
import com.unity3d.services.core.device.Storage;
8+
import com.unity3d.services.core.device.StorageManager;
9+
import com.unity3d.services.core.device.reader.GameSessionIdReader;
10+
import com.unity3d.services.core.properties.ClientProperties;
11+
12+
import org.junit.Assert;
13+
import org.junit.Before;
14+
import org.junit.Test;
15+
import org.junit.runner.RunWith;
16+
import org.mockito.junit.MockitoJUnitRunner;
17+
18+
@RunWith(MockitoJUnitRunner.class)
19+
public class GameSessionIdReaderTest {
20+
21+
@Before
22+
public void setup() {
23+
ClientProperties.setApplicationContext(InstrumentationRegistry.getInstrumentation().getTargetContext());
24+
}
25+
26+
@Test
27+
public void testGameSessionIdReader() {
28+
Long gameSessionId = GameSessionIdReader.getInstance().getGameSessionIdAndStore();
29+
30+
// validate we get a gameSessionId
31+
Assert.assertNotNull(gameSessionId);
32+
Assert.assertEquals(12, (Long.toString(gameSessionId)).length()) ;
33+
// validate we store the value
34+
StorageManager.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
35+
StorageManager.initStorage(StorageManager.StorageType.PRIVATE);
36+
Storage storage = StorageManager.getStorage(StorageManager.StorageType.PRIVATE);
37+
Long storedId = null;
38+
if (storage != null) {
39+
storedId = (Long) storage.get(GAME_SESSION_ID_NORMALIZED_KEY);
40+
}
41+
Assert.assertEquals(gameSessionId, storedId);
42+
// validate on consecutive requests we get the same value
43+
Long gameSessionId2 = GameSessionIdReader.getInstance().getGameSessionId();
44+
Assert.assertEquals(gameSessionId, gameSessionId2);
45+
// validate even on storage change we get same value
46+
if (storage != null) {
47+
storage.set(GAME_SESSION_ID_NORMALIZED_KEY, "newValueFromWebview");
48+
storage.writeStorage();
49+
}
50+
Long gameSessionId3 = GameSessionIdReader.getInstance().getGameSessionId();
51+
Assert.assertEquals(gameSessionId, gameSessionId3);
52+
}
53+
54+
55+
}

0 commit comments

Comments
 (0)