Skip to content

Commit d812ca8

Browse files
author
Unity Ads Travis
committed
Release 2.2.1
1 parent f3f5042 commit d812ca8

File tree

15 files changed

+163
-39
lines changed

15 files changed

+163
-39
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ captures
77
testServerAddress.txt
88
app/app.iml
99
lib/lib.iml
10-
javadoc
10+
javadoc
11+
.settings
12+
.project
13+
.vscode
14+
.classpath

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ release:
44
clean:
55
./gradlew :lib:clean
66

7-
test: push-test-server-address exec-tests
7+
test: test-hosted
8+
9+
test-local: push-test-server-address exec-tests
810

911
test-unit-tests: push-test-server-address exec-unit-tests
1012

@@ -51,4 +53,11 @@ javadoc:
5153
zip: release
5254
cp lib/build/outputs/aar/unity-ads-release.aar unity-ads.aar
5355
zip -9r builds.zip unity-ads.aar
54-
rm unity-ads.aar
56+
rm unity-ads.aar
57+
58+
use-local-webview:
59+
sed -i '' 's/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/return "new-ip";/' "lib/src/main/java/com/unity3d/ads/properties/SdkProperties.java"
60+
sed -i '' 's/return ".*";/return "http:\/\/$(shell ifconfig |grep "inet" |grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" |grep -v -E "^0|^127" -m 1):8000\/build\/dev\/config.json";/' "lib/src/main/java/com/unity3d/ads/properties/SdkProperties.java"
61+
62+
use-public-webview:
63+
sed -i '' 's/return ".*";/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/' "lib/src/main/java/com/unity3d/ads/properties/SdkProperties.java"

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.unity3d.ads.example"
99
minSdkVersion 9
1010
targetSdkVersion 23
11-
versionCode = 2200
12-
versionName = "2.2.0"
11+
versionCode = 2201
12+
versionName = "2.2.1"
1313
}
1414
buildTypes {
1515
release {

lib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
defaultConfig {
1212
minSdkVersion 9
1313
targetSdkVersion 23
14-
versionCode = 2200
15-
versionName = "2.2.0"
14+
versionCode = 2201
15+
versionName = "2.2.1"
1616

1717
setProperty("archivesBaseName", "unity-ads")
1818

lib/src/androidTest/java/com/unity3d/ads/test/unit/DeviceTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public void testGetNetworkType () {
9696
assertTrue("Network type must not be negative", Device.getNetworkType() > -1);
9797
}
9898

99+
@Test
100+
public void testIsNetworkMetered () {
101+
assertNotNull("Metered network should not be null", Device.getNetworkMetered());
102+
}
103+
99104
@Test
100105
public void testNetworkOperatorName () {
101106
assertNotNull("Expected network operator name to be something else than null", Device.getNetworkOperatorName());
@@ -196,7 +201,11 @@ public void testGetFingerprint () throws Exception {
196201

197202
@Test
198203
public void testGetApkDigest () throws Exception {
199-
assertNotNull("Host should not be null", Device.getApkDigest());
204+
String digest = Device.getApkDigest();
205+
206+
assertNotNull("Apk Digest should not be null", digest);
207+
assertEquals("Wrong size", 64, digest.length());
208+
assertTrue("Contains illegal characters", digest.matches("^[0-9a-fA-F]+$"));
200209
}
201210

202211
@Test

lib/src/androidTest/java/com/unity3d/ads/test/unit/UtilitiesTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import android.util.Log;
44

5-
import com.unity3d.ads.log.DeviceLog;
65
import com.unity3d.ads.misc.Utilities;
76

87
import org.json.JSONObject;
98
import org.junit.Test;
109

10+
import java.io.ByteArrayInputStream;
11+
1112
import static org.junit.Assert.assertEquals;
1213

1314
public class UtilitiesTest {
@@ -63,4 +64,24 @@ public void testMergeJson() throws Exception {
6364

6465
assertEquals("Incorrect 'override' value", "primary", testObject.getString("override"));
6566
}
67+
68+
@Test
69+
public void testSha256Stream() throws Exception {
70+
assertHash(10240, "88278aa898609ddff1418ac55011741c563d3e3cd0d70bc07c407a3a882d8004");
71+
assertHash(8192, "9b4cd9b4977133275a2fc9ab7ec25101cfe5273808837a2490437871614f56ab");
72+
assertHash(2048, "b07cbef157ea4e7bf4e233f3e766c668bf93578e9954c64fcd6ec3d9f4c6f4f4");
73+
assertHash(1, "5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9");
74+
assertHash(0, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
75+
}
76+
77+
public void assertHash(int size, String sha256) throws Exception {
78+
byte[] buffer = new byte[size];
79+
80+
for(int i = 0; i < buffer.length; i++ ) {
81+
buffer[i] = (byte)((byte)'0' + (byte)(i % 9));
82+
}
83+
84+
ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer);
85+
assertEquals(String.format("Hash for buffer size %d is wrong", size), sha256, Utilities.Sha256(inputStream));
86+
}
6687
}

lib/src/main/java/com/unity3d/ads/UnityAds.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.unity3d.ads.misc.Utilities;
1818
import com.unity3d.ads.properties.ClientProperties;
1919
import com.unity3d.ads.properties.SdkProperties;
20+
import com.unity3d.ads.configuration.InitializeThread;
2021

2122
import org.json.JSONException;
2223
import org.json.JSONObject;
@@ -334,9 +335,8 @@ public void run() {
334335
try {
335336
if(!AdUnitOpen.open(placementId, options)) {
336337
handleShowError(placementId, UnityAdsError.INTERNAL_ERROR, "Webapp timeout, shutting down Unity Ads");
337-
Placement.reset();
338-
CacheThread.cancel();
339-
ConnectivityMonitor.stopAll();
338+
339+
InitializeThread.reset();
340340
}
341341
}
342342
catch (NoSuchMethodException exception) {
@@ -346,7 +346,10 @@ public void run() {
346346
}
347347
}).start();
348348
} else {
349-
if(!isSupported()) {
349+
if (placementId == null) {
350+
throw new IllegalArgumentException("PlacementID is null");
351+
}
352+
else if (!isSupported()) {
350353
handleShowError(placementId, UnityAdsError.NOT_INITIALIZED, "Unity Ads is not supported for this device");
351354
} else if(!isInitialized()) {
352355
handleShowError(placementId, UnityAdsError.NOT_INITIALIZED, "Unity Ads is not initialized");

lib/src/main/java/com/unity3d/ads/adunit/AdUnitActivity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@ protected void onCreate(Bundle savedInstanceState) {
9696
setOrientation(_orientation);
9797
setSystemUiVisibility(_systemUiVisibility);
9898

99-
if (_views != null && Arrays.asList(_views).contains("videoplayer")) {
100-
createVideoPlayer();
99+
if(_views != null) {
100+
if(Arrays.asList(_views).contains("videoplayer")) {
101+
createVideoPlayer();
102+
}
103+
104+
if(Arrays.asList(_views).contains("webplayer")) {
105+
createWebPlayer();
106+
}
101107
}
102108

103109
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, event, _activityId);

lib/src/main/java/com/unity3d/ads/api/DeviceInfo.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ public static void getNetworkType(WebViewCallback callback) {
119119
callback.invoke(Device.getNetworkType());
120120
}
121121

122+
@WebViewExposed
123+
public static void getNetworkMetered(WebViewCallback callback) {
124+
callback.invoke(Device.getNetworkMetered());
125+
}
126+
122127
@WebViewExposed
123128
public static void getNetworkOperator(WebViewCallback callback) {
124129
callback.invoke(Device.getNetworkOperator());
@@ -422,13 +427,10 @@ public static void getGLVersion (WebViewCallback callback) {
422427

423428
@WebViewExposed
424429
public static void getApkDigest (WebViewCallback callback) {
425-
String digest = Device.getApkDigest();
426-
427-
if (digest != null) {
428-
callback.invoke(digest);
429-
}
430-
else {
431-
callback.error(DeviceError.COULDNT_GET_DIGEST);
430+
try {
431+
callback.invoke(Device.getApkDigest());
432+
} catch(Exception e) {
433+
callback.error(DeviceError.COULDNT_GET_DIGEST, e.toString());
432434
}
433435
}
434436

lib/src/main/java/com/unity3d/ads/cache/CacheDirectory.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ public boolean testCacheDirectory(File directory) {
9797
fos.flush();
9898
fos.close();
9999

100-
if(directory.listFiles() == null) {
101-
DeviceLog.debug("Failed to list files in directory " + directory.getAbsolutePath());
102-
return false;
103-
}
104-
105100
FileInputStream fis = new FileInputStream(testFile);
106101
int readCount = fis.read(outData, 0, outData.length);
107102
fis.close();

0 commit comments

Comments
 (0)