Skip to content

Commit e467406

Browse files
committed
Merge branch 'release/2.2.3'
2 parents 02e082d + 44704ab commit e467406

16 files changed

+138
-36
lines changed

AndroidSDK/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
android:protectionLevel="signature" />
1515
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
1616

17-
<application android:label="@string/app_name">
17+
<application>
1818

1919
<!-- Leanplum Push Notification Receiver for GCM and FCM -->
2020
<receiver android:name="com.leanplum.LeanplumPushReceiver" android:exported="false"

AndroidSDK/proguard-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-dontwarn com.actionbarsherlock.**
22

33
-dontnote
4+
-dontshrink
45
-keepparameternames
56
-keepattributes EnclosingMethod
67

AndroidSDK/src/com/leanplum/LeanplumInbox.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,25 @@ public List<String> messagesIds() {
306306
try {
307307
Collections.sort(messageIds, new Comparator<String>() {
308308
@Override
309-
public int compare(String firstMessage, String secondMessage) {
310-
Date firstDate = messageForId(firstMessage).getDeliveryTimestamp();
311-
Date secondDate = messageForId(secondMessage).getDeliveryTimestamp();
309+
public int compare(String firstMessageId, String secondMessageId) {
310+
// Message that is null will be moved to the back of the list.
311+
LeanplumInboxMessage firstMessage = messageForId(firstMessageId);
312+
if (firstMessage == null) {
313+
return -1;
314+
}
315+
LeanplumInboxMessage secondMessage = messageForId(secondMessageId);
316+
if (secondMessage == null) {
317+
return 1;
318+
}
319+
// Message with null date will be moved to the back of the list.
320+
Date firstDate = firstMessage.getDeliveryTimestamp();
321+
if (firstDate == null) {
322+
return -1;
323+
}
324+
Date secondDate = secondMessage.getDeliveryTimestamp();
325+
if (secondDate == null) {
326+
return 1;
327+
}
312328
return firstDate.compareTo(secondDate);
313329
}
314330
});

AndroidSDK/src/com/leanplum/LeanplumLocalPushListenerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void onHandleIntent(Intent intent) {
4747
return;
4848
}
4949
Bundle extras = intent.getExtras();
50-
if (!extras.isEmpty() && extras.containsKey(Constants.Keys.PUSH_MESSAGE_TEXT)) {
50+
if (extras != null && extras.containsKey(Constants.Keys.PUSH_MESSAGE_TEXT)) {
5151
LeanplumPushService.handleNotification(this, extras);
5252
}
5353
} catch (Throwable t) {

AndroidSDK/src/com/leanplum/LeanplumPushService.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ static void handleNotification(final Context context, final Bundle message) {
283283
* Put the message into a notification and post it.
284284
*/
285285
private static void showNotification(Context context, Bundle message) {
286+
if (context == null || message == null) {
287+
return;
288+
}
289+
286290
NotificationManager notificationManager = (NotificationManager)
287291
context.getSystemService(Context.NOTIFICATION_SERVICE);
288292

@@ -346,7 +350,15 @@ private static void showNotification(Context context, Bundle message) {
346350
notificationId = value.hashCode();
347351
}
348352
}
349-
notificationManager.notify(notificationId, builder.build());
353+
354+
try {
355+
notificationManager.notify(notificationId, builder.build());
356+
} catch (NullPointerException e) {
357+
Log.e("Unable to show push notification.", e);
358+
} catch (Throwable t) {
359+
Log.e("Unable to show push notification.", t);
360+
Util.handleException(t);
361+
}
350362
}
351363

352364
static void openNotification(Context context, final Bundle notification) {
@@ -375,6 +387,9 @@ static void openNotification(Context context, final Bundle notification) {
375387

376388
if (shouldStartActivity) {
377389
Intent actionIntent = getActionIntent(context);
390+
if (actionIntent == null) {
391+
return;
392+
}
378393
actionIntent.putExtras(notification);
379394
actionIntent.addFlags(
380395
Intent.FLAG_ACTIVITY_CLEAR_TOP |

AndroidSDK/src/com/leanplum/LocationManagerImplementation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ private void startLocationClient() {
241241

242242
private boolean isPermissionGranted() {
243243
Context context = Leanplum.getContext();
244-
return context.checkCallingOrSelfPermission(PERMISSION) == PackageManager.PERMISSION_GRANTED;
244+
try {
245+
return context.checkCallingOrSelfPermission(PERMISSION) == PackageManager.PERMISSION_GRANTED;
246+
} catch (RuntimeException ignored) {
247+
return false;
248+
}
245249
}
246250

247251
private boolean isMetaDataSet() {

AndroidSDK/src/com/leanplum/NewsfeedMessage.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,13 @@ public Date deliveryTimestamp() {
146146
}
147147

148148
/**
149-
* Returns the delivery timestamp of the newsfeed message.
149+
* Returns the delivery timestamp of the newsfeed message,
150+
* or null if delivery timestamp is not present.
150151
*/
151152
public Date getDeliveryTimestamp() {
153+
if (deliveryTimestamp == null) {
154+
return null;
155+
}
152156
return new Date(deliveryTimestamp);
153157
}
154158

AndroidSDK/src/com/leanplum/internal/ActionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static LocationManager getLocationManager() {
8686
}
8787
} catch (Throwable e) {
8888
if (!loggedLocationManagerFailure) {
89-
Log.e("Geofencing support requires Google Play Services v8.1 and higher.\n" +
89+
Log.w("Geofencing support requires Google Play Services v8.1 and higher.\n" +
9090
"Add this to your build.gradle file:\n" +
9191
"compile ('com.google.android.gms:play-services-location:8.3.0+')");
9292
loggedLocationManagerFailure = true;
@@ -240,7 +240,7 @@ public boolean onResponse(ActionContext actionContext) {
240240
}
241241

242242
// Cancel notification.
243-
Intent intentAlarm = new Intent(context, LeanplumPushService.class);
243+
Intent intentAlarm = new Intent(context, LeanplumLocalPushListenerService.class);
244244
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
245245
PendingIntent existingIntent = PendingIntent.getService(
246246
context, messageId.hashCode(), intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT);

AndroidSDK/src/com/leanplum/internal/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Constants {
3737
public static int NETWORK_TIMEOUT_SECONDS_FOR_DOWNLOADS = 10;
3838
static final String LEANPLUM_PACKAGE_IDENTIFIER = BuildConfig.LEANPLUM_PACKAGE_IDENTIFIER;
3939

40-
public static String LEANPLUM_VERSION = "2.2.2";
40+
public static String LEANPLUM_VERSION = "2.2.3";
4141
public static String CLIENT = "android";
4242

4343
static final String INVALID_MAC_ADDRESS = "02:00:00:00:00:00";

AndroidSDK/src/com/leanplum/internal/LeanplumInternal.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ protected Void doInBackground(Void... voids) {
413413
}
414414
} catch (IOException e) {
415415
Log.e("Failed to connect to Geocoder: " + e);
416+
} catch (IllegalArgumentException e) {
417+
Log.e("Invalid latitude or longitude values: " + e);
418+
} catch (Throwable ignored) {
416419
}
417420
}
418421
Request req = Request.post(Constants.Methods.SET_USER_ATTRIBUTES, params);
@@ -532,10 +535,6 @@ public static <T> Map<String, T> validateAttributes(Map<String, T> attributes, S
532535
for (Map.Entry<String, T> entry : attributes.entrySet()) {
533536
T value = entry.getValue();
534537

535-
if (value == null) {
536-
continue;
537-
}
538-
539538
// Validate lists.
540539
if (allowLists && value instanceof Iterable<?>) {
541540
boolean valid = true;
@@ -556,7 +555,7 @@ public static <T> Map<String, T> validateAttributes(Map<String, T> attributes, S
556555
Date date = CollectionUtil.uncheckedCast(value);
557556
value = CollectionUtil.uncheckedCast(date.getTime());
558557
}
559-
if (!isValidScalarValue(value, argName)) {
558+
if (value != null && !isValidScalarValue(value, argName)) {
560559
continue;
561560
}
562561
}

0 commit comments

Comments
 (0)