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

Commit db875835 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "MAP: move addMessageToUri to BluetoothMapContentObserver"

parents a5f9606b 35bfc7aa
Loading
Loading
Loading
Loading
+34 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.provider.Telephony.Sms.Inbox;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
@@ -2544,6 +2545,37 @@ public class BluetoothMapContentObserver {
    private Map<Long, PushMsgInfo> mPushMsgList =
            Collections.synchronizedMap(new HashMap<Long, PushMsgInfo>());

    /**
     * Add an SMS to the given URI.
     *
     * @param resolver the content resolver to use
     * @param uri the URI to add the message to
     * @param address the address of the sender
     * @param body the body of the message
     * @param subject the pseudo-subject of the message
     * @param date the timestamp for the message
     * @return the URI for the new message
     */
    private static Uri addMessageToUri(ContentResolver resolver, Uri uri,
                                      String address, String body, String subject,
                                      Long date) {
        ContentValues values = new ContentValues(7);
        final int statusPending = 32;
        final int subId = SubscriptionManager.getDefaultSmsSubscriptionId();
        Log.v(TAG, "Telephony addMessageToUri sub id: " + subId);

        values.put(Telephony.Sms.SUBSCRIPTION_ID, subId);
        values.put(Telephony.Sms.ADDRESS, address);
        if (date != null) {
            values.put(Telephony.Sms.DATE, date);
        }
        values.put(Telephony.Sms.READ, 0);
        values.put(Telephony.Sms.SUBJECT, subject);
        values.put(Telephony.Sms.BODY, body);
        values.put(Telephony.Sms.STATUS, statusPending);
        return resolver.insert(uri, values);
    }

    public long pushMessage(BluetoothMapbMessage msg, BluetoothMapFolderElement folderElement,
            BluetoothMapAppParams ap, String emailBaseUri)
            throws IllegalArgumentException, RemoteException, IOException {
@@ -2649,8 +2681,6 @@ public class BluetoothMapContentObserver {
                    String phone = recipient.getFirstPhoneNumber();
                    String email = recipient.getFirstEmail();
                    String folder = folderElement.getName();
                    boolean read = false;
                    boolean deliveryReport = true;
                    String msgBody = null;

                    /* If MMS contains text only and the size is less than ten SMS's
@@ -2699,8 +2729,8 @@ public class BluetoothMapContentObserver {
                        Uri contentUri = Uri.parse(Sms.CONTENT_URI + "/" + folder);
                        Uri uri;
                        synchronized (getMsgListSms()) {
                            uri = Sms.addMessageToUri(mResolver, contentUri, phone, msgBody, "",
                                    System.currentTimeMillis(), read, deliveryReport);
                            uri = addMessageToUri(mResolver, contentUri, phone, msgBody, "",
                                    System.currentTimeMillis());

                            if (V) {
                                Log.v(TAG, "Sms.addMessageToUri() returned: " + uri);