From 11b223c0dcbdb2f7bc8fad3f94005a0c29aa33e9 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 27 May 2019 17:29:48 +0200 Subject: [PATCH] Prevent crash if icon is null --- .../linphone/compatibility/ApiTwentyEightPlus.java | 14 +++++++++++--- .../org/linphone/contacts/ContactsManager.java | 10 +++++++--- .../linphone/sample/ConfigureAccountActivity.java | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/linphone/compatibility/ApiTwentyEightPlus.java b/app/src/main/java/org/linphone/compatibility/ApiTwentyEightPlus.java index 2b275d859..2e3624fde 100644 --- a/app/src/main/java/org/linphone/compatibility/ApiTwentyEightPlus.java +++ b/app/src/main/java/org/linphone/compatibility/ApiTwentyEightPlus.java @@ -42,9 +42,17 @@ class ApiTwentyEightPlus { Person me = new Person.Builder().setName(notif.getMyself()).build(); Notification.MessagingStyle style = new Notification.MessagingStyle(me); for (NotifiableMessage message : notif.getMessages()) { - Icon userIcon = Icon.createWithBitmap(message.getSenderBitmap()); - Person user = - new Person.Builder().setName(message.getSender()).setIcon(userIcon).build(); + Icon userIcon = null; + if (message.getSenderBitmap() != null) { + userIcon = Icon.createWithBitmap(message.getSenderBitmap()); + } + + Person.Builder builder = new Person.Builder().setName(message.getSender()); + if (userIcon != null) { + builder.setIcon(userIcon); + } + Person user = builder.build(); + Notification.MessagingStyle.Message msg = new Notification.MessagingStyle.Message( message.getMessage(), message.getTime(), user); diff --git a/app/src/main/java/org/linphone/contacts/ContactsManager.java b/app/src/main/java/org/linphone/contacts/ContactsManager.java index 0303baf3b..246614fab 100644 --- a/app/src/main/java/org/linphone/contacts/ContactsManager.java +++ b/app/src/main/java/org/linphone/contacts/ContactsManager.java @@ -2,7 +2,7 @@ package org.linphone.contacts; /* ContactsManager.java -Copyright (C) 2017 Belledonne Communications, Grenoble, France +Copyright (C) 2017 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -370,7 +370,11 @@ public class ContactsManager extends ContentObserver implements FriendListListen String normalized = lpc.normalizePhoneNumber(phoneNumber); if (normalized == null) { - Log.w("[Contacts Manager] Couldn't normalize phone number " + phoneNumber + ", default proxy config prefix is " + lpc.getDialPrefix()); + Log.w( + "[Contacts Manager] Couldn't normalize phone number " + + phoneNumber + + ", default proxy config prefix is " + + lpc.getDialPrefix()); normalized = phoneNumber; } @@ -386,7 +390,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen if (lf != null) { return (LinphoneContact) lf.getUserData(); } - + Log.w("[Contacts Manager] Couldn't find friend..."); return null; } diff --git a/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java b/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java index 6d4a226b6..b93b6d884 100644 --- a/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java +++ b/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java @@ -106,7 +106,7 @@ public class ConfigureAccountActivity extends Activity { } // This will automatically create the proxy config and auth info and add them to the Core - ProxyConfig cfg = mAccountCreator.configure(); + ProxyConfig cfg = mAccountCreator.createProxyConfig(); // Make sure the newly created one is the default LinphoneService.getCore().setDefaultProxyConfig(cfg); }