Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1c6d1d5 authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by Sanket Agarwal
Browse files

MAP MCE iPhone connectivity

iPhones do not fill in the tel: field in the originators vCard upon
receipt of a text message, this was causing parsing to fail as it was
assumed that every SMS message will have an associated phone number.
Updated logic to check fields more riggorously.

Bug: 32110763
Change-Id: Ie9135167ad957a2a8054ea414d3e9ec576d3271b
(cherry picked from commit b2e57a501b1719406776c795cfed4fd271707d79)
parent 7adf1f58
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import com.android.vcard.VCardProperty;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/* The MceStateMachine is responsible for setting up and maintaining a connection to a single
 * specific Messaging Server Equipment endpoint.  Upon connect command an SDP record is retrieved,
@@ -209,7 +210,7 @@ final class MceStateMachine extends StateMachine {
                VCardEntry dest_entry = new VCardEntry();
                VCardProperty dest_entry_phone = new VCardProperty();
                if (DBG) Log.d(TAG, "Scheme " + contact.getScheme());
                if (contact.getScheme().equals(PhoneAccount.SCHEME_TEL)) {
                if (PhoneAccount.SCHEME_TEL.equals(contact.getScheme())) {
                    dest_entry_phone.setName(VCardConstants.PROPERTY_TEL);
                    dest_entry_phone.addValues(contact.getSchemeSpecificPart());
                    if (DBG) {
@@ -510,15 +511,23 @@ final class MceStateMachine extends StateMachine {

                    Intent intent = new Intent();
                    intent.setAction(BluetoothMapClient.ACTION_MESSAGE_RECEIVED);
                    intent.putExtra(android.content.Intent.EXTRA_TEXT, message.getBodyContent());
                    VCardEntry.PhoneData phoneData = message.getOriginator().getPhoneList().get(0);
                    if (phoneData != null) {
                    intent.putExtra(android.content.Intent.EXTRA_TEXT,
                            message.getBodyContent());
                    VCardEntry originator = message.getOriginator();
                    if (originator != null) {
                        if (DBG) Log.d(TAG, originator.toString());
                        List<VCardEntry.PhoneData> phoneData = originator.getPhoneList();
                        if (phoneData != null && phoneData.size() > 0) {
                            String phoneNumber = phoneData.get(0).getNumber();
                            if (DBG) {
                            Log.d(TAG,
                                    message.getOriginator().getPhoneList().get(0).getNumber());
                                Log.d(TAG, "Originator number: " + phoneNumber);
                            }
                            intent.putExtra(
                                    ContactsContract.Intents.EXTRA_RECIPIENT_CONTACT_URI,
                                    new String[]{getContactURIFromPhone(phoneNumber)});
                        }
                        intent.putExtra(ContactsContract.Intents.EXTRA_RECIPIENT_CONTACT_URI,
                                new String[]{getContactURIFromPhone(phoneData.getNumber())});
                        intent.putExtra(ContactsContract.Intents.EXTRA_RECIPIENT_CONTACT_NAME,
                                new String[]{originator.getDisplayName()});
                    }
                    mService.sendBroadcast(intent);
                    break;