Skip to content

Commit

Permalink
Release 3.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
UnitySteven committed Mar 19, 2021
1 parent 6bd616a commit 2417560
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 72 deletions.
89 changes: 45 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,77 +1,78 @@
debug:
./gradlew :unity-ads:assembleDebug

release:
./gradlew :unity-ads:assembleRelease

clean:
./gradlew :unity-ads:clean

test: test-hosted
coverage:
./gradlew -i jacocoTestReport --debug

test-local: push-test-server-address exec-tests
coverage-ci: debug test-ci coverage

test-unit-tests: push-test-server-address exec-unit-tests
zip: release
cp unity-ads/build/outputs/aar/unity-ads-release.aar unity-ads.aar
zip -9r unity-ads.aar.zip unity-ads.aar
rm unity-ads.aar

build-test-apk: clean
./gradlew :unity-ads:assembleAndroidTest --full-stacktrace
javadoc:
./gradlew :unity-ads:javadoc

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

test-hosted: push-test-server-address-hosted exec-tests
wake-up-device:
scripts/wakeUpDevice.sh

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

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

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

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

push-test-server-address:
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
adb push testServerAddress.txt /data/local/tmp
run-all-tests: test-instrumentation test-legacy test-integration

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

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

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

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

javadoc:
./gradlew :unity-ads:javadoc
push-test-server-address-ip:
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
adb push testServerAddress.txt /data/local/tmp

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

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

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

use-public-webview:
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"
sed -i '' 's/return ".*";/return baseURI + getWebViewBranch() + "\/" + flavor + "\/config.json";/' "unity-ads/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"

create-android-26-emulator:
${ANDROID_HOME}/tools/bin/sdkmanager --install "system-images;android-26;google_apis;x86"
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

start-android-26-emulator:
${ANDROID_HOME}/emulator/emulator -port 5556 -avd android-26-test -no-window -noaudio -no-boot-anim -memory 2048 -partition-size 1024 &

kill-emulator:
adb emu kill
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.unity3d.ads.example"
minSdkVersion 19
targetSdkVersion 30
versionCode = 3600
versionName = "3.6.0"
versionCode = 3620
versionName = "3.6.2"
}

flavorDimensions "arEnabled"
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
// in the individual module build.gradle files
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'org.jacoco:org.jacoco.core:0.8.1'
}
}

Expand Down
24 changes: 24 additions & 0 deletions scripts/wakeUpDevice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -e
wakefulness=$(adb shell dumpsys power | grep 'mWakefulness=' | cut -d "=" -f2)

if [[ "$wakefulness" == "Awake" ]] ; then
echo "Device Awake"
exit 0;
else
echo "Waking up device"
adb shell input keyevent KEYCODE_WAKEUP
fi

adb shell input keyevent 82

displaySB2=$(adb shell dumpsys power | grep 'mHoldingDisplaySuspendBlocker=' | cut -d "=" -f2)
wakeLockSB2=$(adb shell dumpsys power | grep 'mHoldingWakeLockSuspendBlocker='| cut -d "=" -f2)
if [[ "$displaySB2" == "true" && "$wakeLockSB2" == "false" ]] ; then
echo "Unlocking device with passcode 5168"
adb shell input text 5168 && adb shell input keyevent 66
fi

if [[ "$wakefulness" == "Awake" ]] ; then
echo "Device Awake"
exit 0;
fi
62 changes: 41 additions & 21 deletions unity-ads/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'jacoco'

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

libraryVersion = '3.6.0'
libraryVersion = '3.6.2'

developerId = 'sbankhead'
developerName = 'Steven Bankhead'
Expand Down Expand Up @@ -50,8 +51,8 @@ android {
All SDK with version numbers with last two digits >= 50 will be treated
as China SDK for filtering in the backend.
*/
versionCode = 3600
versionName = "3.6.0"
versionCode = 3620
versionName = "3.6.2"

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

Expand All @@ -76,24 +77,24 @@ android {
}
debug {
minifyEnabled false
testCoverageEnabled false
consumerProguardFiles 'proguard-rules.pro'
}
coverage {
testCoverageEnabled true
consumerProguardFiles 'proguard-rules.pro'
signingConfig signingConfigs.debug
buildConfigField 'String', 'WEBVIEW_BRANCH', getPropertyStringWithDefaultValue('WEBVIEW_BRANCH', '"development"')
}
}

libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${variant.buildType.name}.aar"
}
}
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${variant.buildType.name}.aar"
}
}
}

testVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "../../androidTest.apk"
}
}
}

dependencies {
Expand All @@ -105,12 +106,6 @@ dependencies {
compileOnly 'com.google.ar:core:1.0.0'
}

android.testVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "../../androidTest.apk"
}
}

task javadoc(type: Javadoc, overwrite: true) {
description "Generates Javadoc for Release"
source = android.sourceSets.main.java.srcDirs
Expand Down Expand Up @@ -147,13 +142,38 @@ artifacts {
archives androidSourcesJar
}

jacoco {
toolVersion = '0.8.1'
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}

task jacocoTestReport(type: JacocoReport) {
reports {
xml.enabled = true
html.enabled = true
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def javaClasses = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
def javaSrc = "$project.projectDir/src/main/java"

sourceDirectories = files([javaSrc])
classDirectories = files([javaClasses])
executionData = fileTree(dir: project.buildDir, includes: [
'outputs/code-coverage/connected/*coverage.ec'
])
}

// Bintray
task localProperties {
if (!file("$rootDir/local.properties").exists()) {
file("$rootDir/local.properties").withWriterAppend { w -> "" }
}
}

// Bintray
bintray {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
import com.unity3d.services.core.webview.bridge.Invocation;
import com.unity3d.services.core.webview.bridge.WebViewCallback;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

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

private List<Listener> createListeners(int count) {
final List<Listener> listeners = new ArrayList<>();
for (int x=0; x<count; x++) {
listeners.add(new Listener());
}
return listeners;
}

private Thread createListenerThread(final List<Listener> listeners, final int iterations, final boolean add) {
return new Thread(new Runnable() {
@Override
public void run() {
for (int x=0; x<iterations; x++) {
for(Listener listener : listeners) {
if (add) {
ConnectivityMonitor.addListener(listener);
} else {
ConnectivityMonitor.removeListener(listener);
}
}
}
}
});
}

private Thread createConnectionThread(final int iterations, final ConditionVariable conditionVariable) {
return new Thread(new Runnable() {
@Override
public void run() {
for (int x=0; x<iterations; x++) {
ConnectivityMonitor.connected();
ConnectivityMonitor.disconnected();
}
conditionVariable.open();
}
});
}

@Test
public void testAddRemoveListenerThreadSafety() {
ConnectivityMonitor.setConnectionMonitoring(false);
final ConditionVariable cv = new ConditionVariable();

List<Listener> listeners = createListeners(10);
createListenerThread(listeners, 1000, true).start();
createListenerThread(listeners, 1000, false).start();
createConnectionThread(1000, cv).start();

boolean success = cv.block(10000);
Assert.assertThat(success, is(true));
}

private class Listener implements IConnectivityListener {
private int _onConnectedCalls = 0;
private int _onDisconnectedCalls = 0;
Expand Down
21 changes: 21 additions & 0 deletions unity-ads/src/main/java/com/unity3d/ads/metadata/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ public String getCategory () {
return _category;
}

/**
* Used by C# layer for reflective metadata set calls
*/
private synchronized boolean set (String key, boolean value) {
return set(key, (Object)value);
}

/**
* Used by C# layer for reflective metadata set calls
*/
private synchronized boolean set (String key, int value) {
return set(key, (Object)value);
}

/**
* Used by C# layer for reflective metadata set calls
*/
private synchronized boolean set (String key, long value) {
return set(key, (Object)value);
}

public synchronized boolean set (String key, Object value) {
initData();

Expand Down
Loading

0 comments on commit 2417560

Please sign in to comment.