Fix bug where message notifications fail to be posted

Failure occurred when InMemoryPhoneBook.get is called before InMemoryPhoneBook.init. To solve this, initialize InMemoryPhoneBook before a call to get.

Bug: 183799975
Change-Id: Ibfdf2ebca4785dbf9b6fa3e0075aa2a3691dc022
Test: Tested locally and notifications are posted
diff --git a/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java b/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java
index a80a854..df1713b 100644
--- a/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java
+++ b/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java
@@ -286,29 +286,33 @@
                     null);
         }
 
-        Contact contact = InMemoryPhoneBook.get().lookupContactEntry(number);
-        if (contact != null) {
-            String name = contact.getDisplayName();
-            String nameAlt = contact.getDisplayNameAlt();
-            if (TextUtils.isEmpty(name)) {
-                name = getReadableNumber(context, number);
-            }
-            if (TextUtils.isEmpty(nameAlt)) {
-                nameAlt = name;
-            }
+        if (InMemoryPhoneBook.isInitialized()) {
+            Contact contact = InMemoryPhoneBook.get().lookupContactEntry(number);
+            if (contact != null) {
+                String name = contact.getDisplayName();
+                String nameAlt = contact.getDisplayNameAlt();
+                if (TextUtils.isEmpty(name)) {
+                    name = getReadableNumber(context, number);
+                }
+                if (TextUtils.isEmpty(nameAlt)) {
+                    nameAlt = name;
+                }
 
-            PhoneNumber phoneNumber = contact.getPhoneNumber(context, number);
-            CharSequence typeLabel = phoneNumber == null ? "" : phoneNumber.getReadableLabel(
-                    context.getResources());
+                PhoneNumber phoneNumber = contact.getPhoneNumber(context, number);
+                CharSequence typeLabel = phoneNumber == null ? "" : phoneNumber.getReadableLabel(
+                        context.getResources());
 
-            return new PhoneNumberInfo(
-                    number,
-                    name,
-                    nameAlt,
-                    contact.getInitials(),
-                    contact.getAvatarUri(),
-                    typeLabel.toString(),
-                    contact.getLookupKey());
+                return new PhoneNumberInfo(
+                        number,
+                        name,
+                        nameAlt,
+                        contact.getInitials(),
+                        contact.getAvatarUri(),
+                        typeLabel.toString(),
+                        contact.getLookupKey());
+            }
+        } else {
+          L.d(TAG, "InMemoryPhoneBook not initialized.");
         }
 
         String name = null;