Skip to content

Commit

Permalink
Release: version 5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Uchitel and Ryan McCormick committed Nov 28, 2018
1 parent 6f8c457 commit 2dbc463
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 195 deletions.
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
One line summary of the issue here

- [ ] I am submitting a bug report for existing functionality
- [ ] I visited https://developers.mopub.com/ and found no answer
- [ ] I checked https://twittercommunity.com/c/advertiser-api/mopub to make sure that this issue has not already been filed
- [ ] I checked to make sure that this issue has not already been filed

#### MoPub SDK Version:

#### Device model and OS Version:

#### Ad Unit IDs used in reproducing the issue:

#### Steps to reproduce the behavior:
Please list all relevant steps to reproduce the observed behavior.

#### Expected behavior:
As concisely as possible, describe the expected behavior.

#### Observed behavior:
As concisely as possible, describe the observed behavior.

#### Evidence:
Device log files, Network log file, etc.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## Version 5.4.1 (November 28, 2018)
- **Bug Fixes**
- Fixed bug with the internal state of rewarded video when the video fails to play.
- Fixed bug where initialization complete is called multiple times.
- Fixed Google Advertising ID fetching logic.
- Marked `gdprApplies` as nullable
- Added cleartextTrafficPermitted="true" to Android Sample App.
- Fixed bug where `rewardedAdsLoaders.markPlayed()` was fired before `onRewardedVideoClosed()`.
- Added `adDidFail` callback to `!isNetworkAvailable()` in `AdViewController`.

## Version 5.4.0 (October 3, 2018)
- Upgraded target SDK version to 28 and support libraries to 28.0.0.
- Upgraded ExoPlayer dependency to 2.8.3.
Expand Down
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The MoPub SDK is available via:
}
dependencies {
implementation('com.mopub:mopub-sdk:5.4.0@aar') {
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
transitive = true
}
}
Expand All @@ -61,27 +61,27 @@ The MoPub SDK is available via:
// ... other project dependencies
// For banners
implementation('com.mopub:mopub-sdk-banner:5.4.0@aar') {
implementation('com.mopub:mopub-sdk-banner:5.4.1@aar') {
transitive = true
}
// For interstitials
implementation('com.mopub:mopub-sdk-interstitial:5.4.0@aar') {
implementation('com.mopub:mopub-sdk-interstitial:5.4.1@aar') {
transitive = true
}
// For rewarded videos. This will automatically also include interstitials
implementation('com.mopub:mopub-sdk-rewardedvideo:5.4.0@aar') {
implementation('com.mopub:mopub-sdk-rewardedvideo:5.4.1@aar') {
transitive = true
}
// For native static (images).
implementation('com.mopub:mopub-sdk-native-static:5.4.0@aar') {
implementation('com.mopub:mopub-sdk-native-static:5.4.1@aar') {
transitive = true
}
// For native video. This will automatically also include native static
implementation('com.mopub:mopub-sdk-native-video:5.4.0@aar') {
implementation('com.mopub:mopub-sdk-native-video:5.4.1@aar') {
transitive = true
}
}
Expand Down Expand Up @@ -109,10 +109,14 @@ The MoPub SDK is available via:
## New in this Version
Please view the [changelog](https://github.com/mopub/mopub-android-sdk/blob/master/CHANGELOG.md) for a complete list of additions, fixes, and enhancements in the latest release.
- Upgraded target SDK version to 28 and support libraries to 28.0.0.
- Upgraded ExoPlayer dependency to 2.8.3.
- Moved `AdvancedBiddingInitializationAsyncTask` and `RefreshAdvertisingInfoAsyncTask` to the parallel executor.
- MRAID `isViewable` now more closely follows our impression tracking instead of the ad being marked viewable as soon as it loads.
- **Bug Fixes**
- Fixed bug with the internal state of rewarded video when the video fails to play.
- Fixed bug where initialization complete is called multiple times.
- Fixed Google Advertising ID fetching logic.
- Marked `gdprApplies` as nullable
- Added cleartextTrafficPermitted="true" to Android Sample App.
- Fixed bug where `rewardedAdsLoaders.markPlayed()` was fired before `onRewardedVideoClosed()`.
- Added `adDidFail` callback to `!isNetworkAvailable()` in `AdViewController`.
## Requirements
Expand Down Expand Up @@ -141,7 +145,7 @@ Normally, to add the MoPub SDK to your app via JCenter, your `build.gradle` woul
```
dependencies {
implementation('com.mopub:mopub-sdk:5.4.0@aar') {
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
transitive = true
}
}
Expand All @@ -150,7 +154,7 @@ Update to the following to exclude one or both viewability vendors:
```
dependencies {
implementation('com.mopub:mopub-sdk:5.4.0@aar') {
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
transitive = true
exclude module: 'libAvid-mopub' // To exclude AVID
exclude module: 'moat-mobile-app-kit' // To exclude Moat
Expand Down
4 changes: 2 additions & 2 deletions mopub-sample/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mopub.simpleadsdemo"
android:versionCode="64"
android:versionName="5.4.0">
android:versionCode="65"
android:versionName="5.4.1">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand Down
6 changes: 3 additions & 3 deletions mopub-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ apply plugin: 'com.android.application'

project.group = 'com.mopub'
project.description = '''MoPub Sample App'''
project.version = '5.4.0'
project.version = '5.4.1'

android {
compileSdkVersion 28
lintOptions { abortOnError false }

defaultConfig {
versionCode 64
versionCode 65
versionName version
minSdkVersion 16
targetSdkVersion 28
Expand Down Expand Up @@ -62,7 +62,7 @@ android {
dependencies {
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-ads-identifier:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation project(':mopub-sdk')
Expand Down
2 changes: 1 addition & 1 deletion mopub-sample/proguard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# Explicitly keep any custom event classes in any package.
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.mobileads.CustomEventRewardedAd {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}
-keep class * extends com.mopub.nativeads.CustomEventRewardedAd {}

# Keep methods that are accessed via reflection
-keepclassmembers class ** { @com.mopub.common.util.ReflectionTarget *; }
Expand Down
2 changes: 1 addition & 1 deletion mopub-sample/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<string name="ad_unit_id_leaderboard">a8919cca19784497872ae69d48f678e1</string>
<string name="ad_unit_id_interstitial">24534e1901884e398f1253216226017e</string>
<string name="ad_unit_id_rewarded_video">920b6145fb1546cf8b5cf2ac34638bb7</string>
<string name="ad_unit_id_rewarded_rich_media">15173ac6d3e54c9389b9a5ddca69b34b</string>
<string name="ad_unit_id_rewarded_rich_media">a96ae2ef41d44822af45c6328c4e1eb1</string>
<string name="ad_unit_id_native">11a17b188668469fb0412708c3d16813</string>
<string name="swipe_text"><![CDATA[< Swipe Left & Right >]]></string>
</resources>
2 changes: 1 addition & 1 deletion mopub-sample/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system"/>
</trust-anchors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

public class GpsHelper {
static public final int GOOGLE_PLAY_SUCCESS_CODE = 0;
static public final int SERVICE_VERSION_UPDATE_REQUIRED = 2;
static public final String ADVERTISING_ID_KEY = "advertisingId";
static public final String IS_LIMIT_AD_TRACKING_ENABLED_KEY = "isLimitAdTrackingEnabled";
private static String sPlayServicesUtilClassName = "com.google.android.gms.common.GooglePlayServicesUtil";
private static String sAdvertisingIdClientClassName = "com.google.android.gms.ads.identifier.AdvertisingIdClient";

public static class AdvertisingInfo {
Expand All @@ -39,48 +36,13 @@ public interface GpsHelperListener {
void onFetchAdInfoCompleted();
}

public static boolean isPlayServicesAvailable(final Context context) {
try {
MethodBuilder methodBuilder = MethodBuilderFactory.create(null, "isGooglePlayServicesAvailable")
.setStatic(Class.forName(sPlayServicesUtilClassName))
.addParam(Context.class, context);

Object result = methodBuilder.execute();

Integer intResult = (Integer) result;
return (intResult != null && (intResult == GOOGLE_PLAY_SUCCESS_CODE || intResult == SERVICE_VERSION_UPDATE_REQUIRED));
} catch (Exception exception) {
return false;
}
}

static public boolean isLimitAdTrackingEnabled(Context context) {
final boolean defaultValue = false;
if (isPlayServicesAvailable(context)) {
return SharedPreferencesHelper.getSharedPreferences(context)
.getBoolean(IS_LIMIT_AD_TRACKING_ENABLED_KEY, defaultValue);
} else {
return defaultValue;
}
return SharedPreferencesHelper.getSharedPreferences(context)
.getBoolean(IS_LIMIT_AD_TRACKING_ENABLED_KEY, false); // default to disabled
}

static public void fetchAdvertisingInfoAsync(final Context context, final GpsHelperListener gpsHelperListener) {
// This method guarantees that the Google Play Services (GPS) advertising info will
// be populated if GPS is available and the ad info is not already cached
// The above will happen before the callback is run
boolean playServicesIsAvailable = isPlayServicesAvailable(context);
if (playServicesIsAvailable ) {
internalFetchAdvertisingInfoAsync(context, gpsHelperListener);
}
else {
if (gpsHelperListener != null) {
gpsHelperListener.onFetchAdInfoCompleted();
}
if (playServicesIsAvailable) {
// Kick off a request to update the ad information in the background.
internalFetchAdvertisingInfoAsync(context, null);
}
}
internalFetchAdvertisingInfoAsync(context, gpsHelperListener);
}

@Nullable
Expand All @@ -89,20 +51,22 @@ static public AdvertisingInfo fetchAdvertisingInfoSync(final Context context) {
return null;
}
Object adInfo = null;
String advertisingId = null;
boolean isLimitAdTrackingEnabled = false;

try {
MethodBuilder methodBuilder = MethodBuilderFactory.create(null, "getAdvertisingIdInfo")
.setStatic(Class.forName(sAdvertisingIdClientClassName))
.addParam(Context.class, context);

adInfo = methodBuilder.execute();
advertisingId = reflectedGetAdvertisingId(adInfo, advertisingId);
isLimitAdTrackingEnabled = reflectedIsLimitAdTrackingEnabled(adInfo, isLimitAdTrackingEnabled);
} catch (Exception e) {
MoPubLog.d("Unable to obtain Google AdvertisingIdClient.Info via reflection.");
return null;
}

String advertisingId = reflectedGetAdvertisingId(adInfo, null);
boolean isLimitAdTrackingEnabled = reflectedIsLimitAdTrackingEnabled(adInfo, false);

return new AdvertisingInfo(advertisingId, isLimitAdTrackingEnabled);
}

Expand Down Expand Up @@ -183,15 +147,5 @@ static boolean reflectedIsLimitAdTrackingEnabled(final Object adInfo, final bool
return defaultValue;
}
}

@Deprecated
static public void setClassNamesForTesting() {
// This method is used for testing only to help alleviate pain with testing
// unlinked libraries via reflection
// Set class names to something that is linked so Class.forName method doesn't throw
String className = "java.lang.Class";
sPlayServicesUtilClassName = className;
sAdvertisingIdClientClassName = className;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static com.mopub.common.ExternalViewabilitySessionManager.ViewabilityVendor;

public class MoPub {
public static final String SDK_VERSION = "5.4.0";
public static final String SDK_VERSION = "5.4.1";

public enum LocationAwareness { NORMAL, TRUNCATED, DISABLED }

Expand Down Expand Up @@ -164,7 +164,7 @@ public static void initializeSdk(@NonNull final Context context,
// This also initializes MoPubLog
MoPubLog.d("Initializing MoPub with ad unit: " + sdkConfiguration.getAdUnitId());

if (context instanceof Activity && Reflection.classFound(MOPUB_REWARDED_VIDEO_MANAGER)) {
if (context instanceof Activity) {
final Activity activity = (Activity) context;
initializeRewardedVideo(activity, sdkConfiguration);
}
Expand Down Expand Up @@ -375,6 +375,7 @@ static void clearAdvancedBidders() {
sAdvancedBiddingTokens = null;
sPersonalInfoManager = null;
sSdkInitialized = false;
sSdkInitializing = false;
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface AdvertisingIdChangeListener {
private boolean initialized;

@Nullable
private SdkInitializationListener mInitializationListener;
private volatile SdkInitializationListener mInitializationListener;

public MoPubIdentifier(@NonNull final Context appContext) {
this(appContext, null);
Expand Down Expand Up @@ -92,34 +92,24 @@ private void refreshAdvertisingInfo() {
}

void refreshAdvertisingInfoBackgroundThread() {
long time = Calendar.getInstance().getTimeInMillis();
final long time = Calendar.getInstance().getTimeInMillis();

final AdvertisingId oldInfo = mAdInfo;
AdvertisingId newInfo;

// try google
if (isPlayServicesAvailable()) {
GpsHelper.AdvertisingInfo info = GpsHelper.fetchAdvertisingInfoSync(mAppContext);
if (info != null && !TextUtils.isEmpty(info.advertisingId)) {
final AdvertisingId oldId = mAdInfo;
if (oldId.isRotationRequired()) {
setAdvertisingInfo(info.advertisingId, AdvertisingId.generateIdString(), info.limitAdTracking, time);
} else {
setAdvertisingInfo(info.advertisingId, oldId.mMopubId, info.limitAdTracking, oldId.mLastRotation.getTimeInMillis());
}
return;
} else {
MoPubLog.w("Call to 'getAdvertisingIdInfo' returned invalid value.");
}
final GpsHelper.AdvertisingInfo googleAdInfo = GpsHelper.fetchAdvertisingInfoSync(mAppContext);
if (googleAdInfo != null && !TextUtils.isEmpty(googleAdInfo.advertisingId)) {
newInfo = new AdvertisingId(googleAdInfo.advertisingId, oldInfo.mMopubId, googleAdInfo.limitAdTracking, oldInfo.mLastRotation.getTimeInMillis());
} else {
newInfo = getAmazonAdvertisingInfo(mAppContext);
}

// try amazon
final AdvertisingId info = getAmazonAdvertisingInfo(mAppContext);
if (info != null && !TextUtils.isEmpty(info.mAdvertisingId)) {
final AdvertisingId oldId = mAdInfo;
if (oldId.isRotationRequired()) {
setAdvertisingInfo(info.mAdvertisingId, AdvertisingId.generateIdString(), info.mDoNotTrack, time);
} else {
setAdvertisingInfo(info.mAdvertisingId, oldId.mMopubId, info.mDoNotTrack, oldId.mLastRotation.getTimeInMillis());
}
return;
if (newInfo != null) {
final String newMoPubId = oldInfo.isRotationRequired() ? AdvertisingId.generateIdString() : oldInfo.mMopubId;
final long newRotationTime = oldInfo.isRotationRequired() ? time : oldInfo.mLastRotation.getTimeInMillis();

setAdvertisingInfo(newInfo.mAdvertisingId, newMoPubId, newInfo.mDoNotTrack, newRotationTime);
}

// MoPub
Expand Down Expand Up @@ -216,10 +206,11 @@ void setInitializationListener(@Nullable final SdkInitializationListener initial
}
}

private void reportInitializationComplete() {
if (mInitializationListener != null) {
mInitializationListener.onInitializationFinished();
private synchronized void reportInitializationComplete() {
final SdkInitializationListener listener = mInitializationListener;
if (listener != null) {
mInitializationListener = null;
listener.onInitializationFinished();
}
}

Expand All @@ -231,10 +222,6 @@ private void notifyIdChangeListener(@NonNull final AdvertisingId oldId, @NonNull
}
}

boolean isPlayServicesAvailable() {
return GpsHelper.isPlayServicesAvailable(mAppContext);
}

// For Amazon tablets running Fire OS 5.1+ and TV devices running Fire OS 5.2.1.1+, the
// advertising info is available as System Settings.
// See https://developer.amazon.com/public/solutions/devices/fire-tv/docs/fire-tv-advertising-id
Expand Down
Loading

0 comments on commit 2dbc463

Please sign in to comment.