This commit is contained in:
Tina Han 2020-01-27 16:33:15 -08:00
Родитель fb9148ad5d
Коммит a91c1a3bc4
9 изменённых файлов: 20 добавлений и 87 удалений

Просмотреть файл

@ -8,8 +8,8 @@ android {
applicationId "com.unity3d.ads.example"
minSdkVersion 14
targetSdkVersion 26
versionCode = 3400
versionName = "3.4.0"
versionCode = 3420
versionName = "3.4.2"
}
flavorDimensions "arEnabled"

Просмотреть файл

@ -16,7 +16,7 @@ ext {
siteUrl = 'https://github.com/Unity-Technologies/unity-ads-android'
gitUrl = 'https://github.com/Unity-Technologies/unity-ads-android.git'
libraryVersion = '3.4.0'
libraryVersion = '3.4.2'
developerId = 'sbankhead'
developerName = 'Steven Bankhead'
@ -50,8 +50,8 @@ android {
All SDK with version numbers with last two digits >= 50 will be treated
as China SDK for filtering in the backend.
*/
versionCode = 3400
versionName = "3.4.0"
versionCode = 3420
versionName = "3.4.2"
setProperty("archivesBaseName", "unity-ads")

Просмотреть файл

@ -1,76 +0,0 @@
package com.unity3d.ads.properties;
import com.unity3d.ads.IUnityAdsListener;
import com.unity3d.ads.test.instrumentation.services.ads.mocks.UnityAdsListenerMock;
import org.junit.Before;
import org.junit.Test;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class AdsPropertiesTests {
@Before
public void before() {
for (IUnityAdsListener listener : AdsProperties.getListeners()) {
AdsProperties.removeListener(listener);
}
}
@Test
public void testAddListener() {
UnityAdsListenerMock listener = new UnityAdsListenerMock();
AdsProperties.addListener(listener);
Set<IUnityAdsListener> listeners = AdsProperties.getListeners();
assertEquals(1, listeners.size());
assertTrue(listeners.contains(listener));
}
@Test
public void testAddMultipleListener() {
UnityAdsListenerMock listener1 = new UnityAdsListenerMock();
AdsProperties.addListener(listener1);
UnityAdsListenerMock listener2 = new UnityAdsListenerMock();
AdsProperties.addListener(listener2);
Set<IUnityAdsListener> listeners = AdsProperties.getListeners();
assertEquals(2, listeners.size());
assertTrue(listeners.contains(listener1));
assertTrue(listeners.contains(listener2));
}
@Test
public void testRemoveListener() {
UnityAdsListenerMock listener = new UnityAdsListenerMock();
AdsProperties.addListener(listener);
Set<IUnityAdsListener> listeners = AdsProperties.getListeners();
assertEquals(1, listeners.size());
assertTrue(listeners.contains(listener));
AdsProperties.removeListener(listener);
listeners = AdsProperties.getListeners();
assertEquals(0, listeners.size());
assertFalse(listeners.contains(listener));
}
@Test
public void testRemoveDuringIteration() {
UnityAdsListenerMock listener1 = new UnityAdsListenerMock();
AdsProperties.addListener(listener1);
UnityAdsListenerMock listener2 = new UnityAdsListenerMock();
AdsProperties.addListener(listener2);
Set<IUnityAdsListener> listeners = AdsProperties.getListeners();
try {
for (IUnityAdsListener listener : listeners) {
AdsProperties.removeListener(listener);
}
assertTrue(true);
} catch (Exception e) {
fail("An exception should not be thrown");
}
}
}

Просмотреть файл

@ -90,7 +90,7 @@ public final class UnityBanners {
private void _loadBanner(Activity activity, String placementId) {
if (_currentBannerWrapper == null) {
BannerAdRefreshView bannerAdRefreshView = new BannerAdRefreshView(activity, placementId, UnityBannerSize.getDynamicSize(activity));
BannerAdRefreshView bannerAdRefreshView = new BannerAdRefreshView(activity, placementId, new UnityBannerSize(320, 50));
final BannerWrapper bannerWrapper = new BannerWrapper(activity, bannerAdRefreshView);
bannerWrapper.setBannerPosition(_currentBannerPosition);
_currentBannerWrapper = bannerWrapper;

Просмотреть файл

@ -16,5 +16,6 @@ public enum CacheError {
CACHE_DIRECTORY_NULL,
CACHE_DIRECTORY_TYPE_NULL,
CACHE_DIRECTORY_EXISTS,
CACHE_DIRECTORY_DOESNT_EXIST
CACHE_DIRECTORY_DOESNT_EXIST,
UNKNOWN_ERROR
}

Просмотреть файл

@ -164,6 +164,11 @@ class CacheThreadHandler extends Handler {
_active = false;
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_ERROR, CacheError.NETWORK_ERROR, source, e.getMessage());
}
catch (Exception e) {
DeviceLog.exception("Unknown error", e);
_active = false;
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_ERROR, CacheError.UNKNOWN_ERROR, source, e.getMessage());
}
finally {
_currentRequest = null;
try {

Просмотреть файл

@ -117,7 +117,7 @@ public class Configuration {
return queryString;
}
protected void makeRequest () throws IOException, JSONException, IllegalStateException, NetworkIOException, IllegalArgumentException {
protected void makeRequest () throws Exception {
if (_url == null) {
throw new MalformedURLException("Base URL is null");
}

Просмотреть файл

@ -117,7 +117,7 @@ public class WebRequest {
_progressListener = listener;
}
public long makeStreamRequest(OutputStream outputStream) throws NetworkIOException, IOException, IllegalStateException {
public long makeStreamRequest(OutputStream outputStream) throws Exception {
HttpURLConnection connection = getHttpUrlConnectionWithHeaders();
connection.setDoInput(true);
@ -192,6 +192,9 @@ public class WebRequest {
catch (IOException e) {
throw new NetworkIOException("Network exception: " + e.getMessage());
}
catch (Exception e) {
throw new Exception("Unknown Exception: " + e.getMessage());
}
if (bytesRead > 0) {
outputStream.write(readTarget, 0, bytesRead);
@ -209,7 +212,7 @@ public class WebRequest {
return total;
}
public String makeRequest () throws NetworkIOException, IOException, IllegalStateException, IllegalArgumentException {
public String makeRequest () throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
makeStreamRequest(baos);
return baos.toString("UTF-8");

Просмотреть файл

@ -66,7 +66,7 @@ public class WebRequestRunnable implements Runnable {
String response;
try {
response = _currentRequest.makeRequest();
} catch (IOException | NetworkIOException | IllegalStateException | IllegalArgumentException e) {
} catch (Exception e) {
DeviceLog.exception("Error completing request", e);
onFailed(e.getClass().getName() + ": " + e.getMessage());
return;