Skip to content

Commit 2417560

Browse files
committed
Release 3.6.2
1 parent 6bd616a commit 2417560

File tree

9 files changed

+198
-72
lines changed

9 files changed

+198
-72
lines changed

Makefile

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,78 @@
1+
debug:
2+
./gradlew :unity-ads:assembleDebug
3+
14
release:
25
./gradlew :unity-ads:assembleRelease
36

47
clean:
58
./gradlew :unity-ads:clean
69

7-
test: test-hosted
10+
coverage:
11+
./gradlew -i jacocoTestReport --debug
812

9-
test-local: push-test-server-address exec-tests
13+
coverage-ci: debug test-ci coverage
1014

11-
test-unit-tests: push-test-server-address exec-unit-tests
15+
zip: release
16+
cp unity-ads/build/outputs/aar/unity-ads-release.aar unity-ads.aar
17+
zip -9r unity-ads.aar.zip unity-ads.aar
18+
rm unity-ads.aar
1219

13-
build-test-apk: clean
14-
./gradlew :unity-ads:assembleAndroidTest --full-stacktrace
20+
javadoc:
21+
./gradlew :unity-ads:javadoc
1522

16-
test-emulator: exec-tests
23+
device-connected:
24+
adb get-state 1>/dev/null 2>&1 && echo 'Device Attached' && exit 0 || echo 'Device NOT Attached' && exit -1
1725

18-
test-hosted: push-test-server-address-hosted exec-tests
26+
wake-up-device:
27+
scripts/wakeUpDevice.sh
1928

20-
test-usb: push-test-server-address-local setup-adb-reverse exec-only-unit-tests dismantle-adb-reverse
29+
test: device-connected wake-up-device run-all-tests
2130

22-
exec-tests: exec-unit-tests exec-hybrid-tests
31+
test-local: device-connected wake-up-device push-test-server-address-ip run-all-tests
2332

24-
exec-unit-tests: clean
25-
adb shell input keyevent 82
26-
./gradlew :unity-ads:connectedCheck --full-stacktrace -Pandroid.testInstrumentationRunnerArguments.class=com.unity3d.ads.test.LegacyTestSuite
33+
test-local-webview-staging: device-connected wake-up-device push-test-server-address-staging run-all-tests
2734

28-
exec-hybrid-tests: clean
29-
adb shell input keyevent 82
30-
./gradlew :unity-ads:connectedCheck --full-stacktrace -Pandroid.testInstrumentationRunnerArguments.class=com.unity3d.ads.test.HybridTestSuite
35+
test-local-staging-localhost: device-connected wake-up-device push-test-server-address-localhost run-all-tests
3136

32-
push-test-server-address:
33-
echo https://$(shell ifconfig |grep "inet" |grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" |grep -v -E "^0|^127" -m 1):8080 > testServerAddress.txt
34-
adb push testServerAddress.txt /data/local/tmp
37+
run-all-tests: test-instrumentation test-legacy test-integration
3538

36-
push-test-server-address-hosted:
37-
echo "https://unity-ads-test-server.unityads.unity3d.com" > testServerAddress.txt
38-
adb push testServerAddress.txt /data/local/tmp
39+
test-ci:
40+
./gradlew connectedDebugAndroidTest -i -w --stacktrace -Pandroid.testInstrumentationRunnerArguments.class=com.unity3d.ads.test.InstrumentationTestSuite,com.unity3d.ads.test.LegacyTestSuite
3941

40-
push-test-server-address-local:
41-
echo "https://localhost:8080" > testServerAddress.txt
42-
adb push testServerAddress.txt /data/local/tmp
42+
test-instrumentation:
43+
./gradlew connectedDebugAndroidTest -i -w --stacktrace -Pandroid.testInstrumentationRunnerArguments.class=com.unity3d.ads.test.InstrumentationTestSuite
4344

44-
setup-adb-reverse:
45-
adb reverse tcp:8080 tcp:8080
45+
test-legacy:
46+
./gradlew connectedDebugAndroidTest -i -w --stacktrace -Pandroid.testInstrumentationRunnerArguments.class=com.unity3d.ads.test.LegacyTestSuite
4647

47-
dismantle-adb-reverse:
48-
adb reverse --remove-all
48+
test-integration:
49+
./gradlew connectedDebugAndroidTest -i -w --stacktrace -Pandroid.testInstrumentationRunnerArguments.class=com.unity3d.ads.test.IntegrationTestSuite
4950

50-
javadoc:
51-
./gradlew :unity-ads:javadoc
51+
push-test-server-address-ip:
52+
echo http://$(shell ifconfig |grep "inet" |grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" |grep -v -E "^0|^127" -m 1):8080 > testServerAddress.txt
53+
adb push testServerAddress.txt /data/local/tmp
5254

53-
zip: release
54-
cp unity-ads/build/outputs/aar/unity-ads-release.aar unity-ads.aar
55-
zip -9r unity-ads.aar.zip unity-ads.aar
56-
rm unity-ads.aar
55+
push-test-server-address-staging:
56+
echo "https://unity-ads-test-server.unityads.unity3d.com" > testServerAddress.txt
57+
adb push testServerAddress.txt /data/local/tmp
5758

58-
verify-release-build:
59-
if [[ -f "unity-ads.aar.zip" ]]; then \
60-
echo 'unity-ads.aar.zip exists'; \
61-
else \
62-
echo 'unity-ads.aar.zip does not exist'; \
63-
exit 1; \
64-
fi;
59+
push-test-server-address-localhost:
60+
echo "http://localhost:8080" > testServerAddress.txt
61+
adb push testServerAddress.txt /data/local/tmp
6562

6663
use-local-webview:
67-
sed -i '' 's/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/return "new-ip";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
68-
sed -i '' 's/return ".*";/return "https:\/\/$(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\/" + flavor + "\/config.json";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
64+
sed -i '' 's/return baseURI + getWebViewBranch() + "\/" + flavor + "\/config.json";/return "new-ip";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
65+
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\/" + flavor + "\/config.json";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
6966

7067
use-public-webview:
71-
sed -i '' 's/return ".*";/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
68+
sed -i '' 's/return ".*";/return baseURI + getWebViewBranch() + "\/" + flavor + "\/config.json";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
7269

7370
create-android-26-emulator:
71+
${ANDROID_HOME}/tools/bin/sdkmanager --install "system-images;android-26;google_apis;x86"
7472
echo "no" | ${ANDROID_HOME}/tools/bin/avdmanager create avd --name "android-26-test" --package "system-images;android-26;google_apis;x86" --device "Nexus 6P" --tag google_apis --abi google_apis/x86 --force
7573

7674
start-android-26-emulator:
7775
${ANDROID_HOME}/emulator/emulator -port 5556 -avd android-26-test -no-window -noaudio -no-boot-anim -memory 2048 -partition-size 1024 &
76+
77+
kill-emulator:
78+
adb emu kill

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 19
1010
targetSdkVersion 30
11-
versionCode = 3600
12-
versionName = "3.6.0"
11+
versionCode = 3620
12+
versionName = "3.6.2"
1313
}
1414

1515
flavorDimensions "arEnabled"

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ buildscript {
1111
// in the individual module build.gradle files
1212
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
1313
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
14+
classpath 'org.jacoco:org.jacoco.core:0.8.1'
1415
}
1516
}
1617

scripts/wakeUpDevice.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -e
2+
wakefulness=$(adb shell dumpsys power | grep 'mWakefulness=' | cut -d "=" -f2)
3+
4+
if [[ "$wakefulness" == "Awake" ]] ; then
5+
echo "Device Awake"
6+
exit 0;
7+
else
8+
echo "Waking up device"
9+
adb shell input keyevent KEYCODE_WAKEUP
10+
fi
11+
12+
adb shell input keyevent 82
13+
14+
displaySB2=$(adb shell dumpsys power | grep 'mHoldingDisplaySuspendBlocker=' | cut -d "=" -f2)
15+
wakeLockSB2=$(adb shell dumpsys power | grep 'mHoldingWakeLockSuspendBlocker='| cut -d "=" -f2)
16+
if [[ "$displaySB2" == "true" && "$wakeLockSB2" == "false" ]] ; then
17+
echo "Unlocking device with passcode 5168"
18+
adb shell input text 5168 && adb shell input keyevent 66
19+
fi
20+
21+
if [[ "$wakefulness" == "Awake" ]] ; then
22+
echo "Device Awake"
23+
exit 0;
24+
fi

unity-ads/build.gradle

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'com.jfrog.bintray'
33
apply plugin: 'com.github.dcendents.android-maven'
4+
apply plugin: 'jacoco'
45

56
ext {
67
bintrayRepo = "UnityAds"
@@ -16,7 +17,7 @@ ext {
1617
siteUrl = 'https://github.com/Unity-Technologies/unity-ads-android'
1718
gitUrl = 'https://github.com/Unity-Technologies/unity-ads-android.git'
1819

19-
libraryVersion = '3.6.0'
20+
libraryVersion = '3.6.2'
2021

2122
developerId = 'sbankhead'
2223
developerName = 'Steven Bankhead'
@@ -50,8 +51,8 @@ android {
5051
All SDK with version numbers with last two digits >= 50 will be treated
5152
as China SDK for filtering in the backend.
5253
*/
53-
versionCode = 3600
54-
versionName = "3.6.0"
54+
versionCode = 3620
55+
versionName = "3.6.2"
5556

5657
setProperty("archivesBaseName", "unity-ads")
5758

@@ -76,24 +77,24 @@ android {
7677
}
7778
debug {
7879
minifyEnabled false
79-
testCoverageEnabled false
80-
consumerProguardFiles 'proguard-rules.pro'
81-
}
82-
coverage {
8380
testCoverageEnabled true
8481
consumerProguardFiles 'proguard-rules.pro'
85-
signingConfig signingConfigs.debug
86-
buildConfigField 'String', 'WEBVIEW_BRANCH', getPropertyStringWithDefaultValue('WEBVIEW_BRANCH', '"development"')
8782
}
8883
}
8984

9085
libraryVariants.all { variant ->
91-
variant.outputs.all { output ->
92-
if (outputFile != null && outputFileName.endsWith('.aar')) {
93-
outputFileName = "${archivesBaseName}-${variant.buildType.name}.aar"
94-
}
95-
}
86+
variant.outputs.all { output ->
87+
if (outputFile != null && outputFileName.endsWith('.aar')) {
88+
outputFileName = "${archivesBaseName}-${variant.buildType.name}.aar"
89+
}
9690
}
91+
}
92+
93+
testVariants.all { variant ->
94+
variant.outputs.all { output ->
95+
outputFileName = "../../androidTest.apk"
96+
}
97+
}
9798
}
9899

99100
dependencies {
@@ -105,12 +106,6 @@ dependencies {
105106
compileOnly 'com.google.ar:core:1.0.0'
106107
}
107108

108-
android.testVariants.all { variant ->
109-
variant.outputs.all { output ->
110-
outputFileName = "../../androidTest.apk"
111-
}
112-
}
113-
114109
task javadoc(type: Javadoc, overwrite: true) {
115110
description "Generates Javadoc for Release"
116111
source = android.sourceSets.main.java.srcDirs
@@ -147,13 +142,38 @@ artifacts {
147142
archives androidSourcesJar
148143
}
149144

145+
jacoco {
146+
toolVersion = '0.8.1'
147+
}
148+
149+
tasks.withType(Test) {
150+
jacoco.includeNoLocationClasses = true
151+
}
152+
153+
task jacocoTestReport(type: JacocoReport) {
154+
reports {
155+
xml.enabled = true
156+
html.enabled = true
157+
}
158+
159+
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
160+
def javaClasses = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
161+
def javaSrc = "$project.projectDir/src/main/java"
162+
163+
sourceDirectories = files([javaSrc])
164+
classDirectories = files([javaClasses])
165+
executionData = fileTree(dir: project.buildDir, includes: [
166+
'outputs/code-coverage/connected/*coverage.ec'
167+
])
168+
}
169+
170+
// Bintray
150171
task localProperties {
151172
if (!file("$rootDir/local.properties").exists()) {
152173
file("$rootDir/local.properties").withWriterAppend { w -> "" }
153174
}
154175
}
155176

156-
// Bintray
157177
bintray {
158178
Properties properties = new Properties()
159179
properties.load(project.rootProject.file('local.properties').newDataInputStream())

unity-ads/src/androidTest/java/com/unity3d/ads/test/legacy/ConnectivityTest.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
import com.unity3d.services.core.webview.bridge.Invocation;
1919
import com.unity3d.services.core.webview.bridge.WebViewCallback;
2020

21+
import org.junit.Assert;
2122
import org.junit.Before;
2223
import org.junit.Test;
2324
import org.junit.runner.RunWith;
2425

26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
import static org.hamcrest.core.Is.is;
2530
import static org.junit.Assert.assertEquals;
2631
import static org.junit.Assert.assertTrue;
2732

@@ -47,6 +52,58 @@ public void testListener() {
4752
assertEquals("ConnectivityMonitor connected callbacks not equal to one", 1, listener.getOnConnectedCalls());
4853
}
4954

55+
private List<Listener> createListeners(int count) {
56+
final List<Listener> listeners = new ArrayList<>();
57+
for (int x=0; x<count; x++) {
58+
listeners.add(new Listener());
59+
}
60+
return listeners;
61+
}
62+
63+
private Thread createListenerThread(final List<Listener> listeners, final int iterations, final boolean add) {
64+
return new Thread(new Runnable() {
65+
@Override
66+
public void run() {
67+
for (int x=0; x<iterations; x++) {
68+
for(Listener listener : listeners) {
69+
if (add) {
70+
ConnectivityMonitor.addListener(listener);
71+
} else {
72+
ConnectivityMonitor.removeListener(listener);
73+
}
74+
}
75+
}
76+
}
77+
});
78+
}
79+
80+
private Thread createConnectionThread(final int iterations, final ConditionVariable conditionVariable) {
81+
return new Thread(new Runnable() {
82+
@Override
83+
public void run() {
84+
for (int x=0; x<iterations; x++) {
85+
ConnectivityMonitor.connected();
86+
ConnectivityMonitor.disconnected();
87+
}
88+
conditionVariable.open();
89+
}
90+
});
91+
}
92+
93+
@Test
94+
public void testAddRemoveListenerThreadSafety() {
95+
ConnectivityMonitor.setConnectionMonitoring(false);
96+
final ConditionVariable cv = new ConditionVariable();
97+
98+
List<Listener> listeners = createListeners(10);
99+
createListenerThread(listeners, 1000, true).start();
100+
createListenerThread(listeners, 1000, false).start();
101+
createConnectionThread(1000, cv).start();
102+
103+
boolean success = cv.block(10000);
104+
Assert.assertThat(success, is(true));
105+
}
106+
50107
private class Listener implements IConnectivityListener {
51108
private int _onConnectedCalls = 0;
52109
private int _onDisconnectedCalls = 0;

unity-ads/src/main/java/com/unity3d/ads/metadata/MetaData.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ public String getCategory () {
2929
return _category;
3030
}
3131

32+
/**
33+
* Used by C# layer for reflective metadata set calls
34+
*/
35+
private synchronized boolean set (String key, boolean value) {
36+
return set(key, (Object)value);
37+
}
38+
39+
/**
40+
* Used by C# layer for reflective metadata set calls
41+
*/
42+
private synchronized boolean set (String key, int value) {
43+
return set(key, (Object)value);
44+
}
45+
46+
/**
47+
* Used by C# layer for reflective metadata set calls
48+
*/
49+
private synchronized boolean set (String key, long value) {
50+
return set(key, (Object)value);
51+
}
52+
3253
public synchronized boolean set (String key, Object value) {
3354
initData();
3455

0 commit comments

Comments
 (0)