Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
publishNonDefault true

defaultConfig {
consumerProguardFiles 'proguard-rules.pro'
consumerProguardFiles 'consumer-proguard-rules.pro'
}

buildTypes {
Expand Down
16 changes: 16 additions & 0 deletions AndroidSDK/consumer-proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Keep default Leanplum classes.
-keepclassmembers class * {
@com.leanplum.annotations.* <fields>;
}

-keep class com.leanplum.** { *; }
-dontwarn com.leanplum.**

# Keep bytebuddy classes.
-keep class net.bytebuddy.** { *; }
-dontwarn net.bytebuddy.**

# Keep Support Library classes.
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
5 changes: 3 additions & 2 deletions AndroidSDK/src/com/leanplum/LeanplumGcmProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ public String getRegistrationId() {
Util.handleException(e);
}
} catch (Throwable t) {
Log.e("Failed to complete registration token refresh.");
Util.handleException(t);
Log.w("There was a problem setting up GCM, please make sure you follow instructions " +
"on how to set it up. Please verify that you are using correct version of " +
"Google Play Services and Android Support Library v4.");
}
return registrationId;
}
Expand Down
10 changes: 2 additions & 8 deletions AndroidSDK/src/com/leanplum/internal/ActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.Intent;
import android.content.SharedPreferences;

import com.google.android.gms.location.LocationServices;
import com.leanplum.ActionContext;
import com.leanplum.ActionContext.ContextualValues;
import com.leanplum.Leanplum;
Expand All @@ -17,7 +18,6 @@
import com.leanplum.callbacks.ActionCallback;

import java.io.Serializable;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -58,13 +58,7 @@ public static synchronized ActionManager getInstance() {
public static LocationManager getLocationManager() {
if (Util.hasPlayServices()) {
try {
Class<?> googleApiClientClass =
Class.forName("com.google.android.gms.common.api.GoogleApiClient");
if (googleApiClientClass != null
&& Modifier.isAbstract(googleApiClientClass.getModifiers())
&& Modifier.isAbstract(
googleApiClientClass.getMethod("isConnected").getModifiers())
&& Class.forName("com.google.android.gms.location.LocationServices") != null) {
if (LocationServices.API != null) {
// Reflection here prevents linker errors
// in Google Play Services is not used in the client app.
return (LocationManager) Class
Expand Down
28 changes: 11 additions & 17 deletions AndroidSDK/src/com/leanplum/internal/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.text.TextUtils;
import android.util.TypedValue;

import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.leanplum.Leanplum;
import com.leanplum.LeanplumActivityHelper;
import com.leanplum.LeanplumDeviceIdMode;
Expand Down Expand Up @@ -181,24 +182,17 @@ private static String getWifiMacAddressHash(Context context) {
*/
private static DeviceIdInfo getAdvertisingId(Context caller) throws Exception {
try {
// Using reflection because the app will either crash or print warnings
// if the app doesn't link to Google Play Services, even if this method is not called.
Object adInfo = Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient")
.getMethod("getAdvertisingIdInfo", Context.class).invoke(null, caller);
String id = checkDeviceId(
"advertising id", (String) adInfo.getClass().getMethod("getId").invoke(adInfo));
if (id != null) {
boolean limitTracking = (Boolean) adInfo.getClass()
.getMethod("isLimitAdTrackingEnabled").invoke(adInfo);
Log.v("Using advertising device id: " + id);
return new DeviceIdInfo(id, limitTracking);
}
} catch (Exception e) {
if (e.getClass().getName().equals("GooglePlayServicesNotAvailableException")) {
Log.w("Error getting advertising ID. Google Play services are not available.");
} else {
throw e;
AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(caller);
if (info != null) {
String advertisingId = info.getId();
String deviceId = checkDeviceId("advertising id", advertisingId);
if (deviceId != null) {
boolean limitedTracking = info.isLimitAdTrackingEnabled();
return new DeviceIdInfo(deviceId, limitedTracking);
}
}
} catch (Throwable ignored) {
Log.e("Error getting advertising ID. Google Play Services are not available.");
}
return null;
}
Expand Down