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

Commit fc542816 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 4939

* changes:
  mods so that we can search mms messages
parents 89c352cf f4f8a7fe
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1422,6 +1422,8 @@ public final class Telephony {
             */
            public static final String _DATA = "_data";

            public static final String TEXT = "text";

        }

        public static final class Rate {
+62 −39
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.net.Uri;
import android.provider.Telephony;
import android.provider.Telephony.Mms;
import android.provider.Telephony.MmsSms;
import android.provider.Telephony.Threads;
@@ -54,6 +55,8 @@ import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import com.google.android.mms.pdu.EncodedStringValue;

/**
 * This class is the high-level manager of PDU storage.
 */
@@ -159,6 +162,7 @@ public class PduPersister {
        Part.CONTENT_TYPE,
        Part.FILENAME,
        Part.NAME,
        Part.TEXT
    };

    private static final int PART_COLUMN_ID                  = 0;
@@ -169,6 +173,7 @@ public class PduPersister {
    private static final int PART_COLUMN_CONTENT_TYPE        = 5;
    private static final int PART_COLUMN_FILENAME            = 6;
    private static final int PART_COLUMN_NAME                = 7;
    private static final int PART_COLUMN_TEXT                = 8;

    private static final HashMap<Uri, Integer> MESSAGE_BOX_MAP;
    // These map are used for convenience in persist() and load().
@@ -414,6 +419,15 @@ public class PduPersister {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    InputStream is = null;

                    // Store simple string values directly in the database instead of an
                    // external file.  This makes the text searchable and retrieval slightly
                    // faster.
                    if ("text/plain".equals(type) || "application/smil".equals(type)) {
                        String text = c.getString(PART_COLUMN_TEXT);
                        byte [] blob = new EncodedStringValue(text).getTextString();
                        baos.write(blob, 0, blob.length);
                    } else {

                        try {
                            is = mContentResolver.openInputStream(partURI);

@@ -436,6 +450,7 @@ public class PduPersister {
                                } // Ignore
                            }
                        }
                    }
                    part.setData(baos.toByteArray());
                }
                parts[partIdx++] = part;
@@ -719,8 +734,15 @@ public class PduPersister {
        InputStream is = null;

        try {
            os = mContentResolver.openOutputStream(uri);
            byte[] data = part.getData();
            if ("text/plain".equals(contentType) || "application/smil".equals(contentType)) {
                ContentValues cv = new ContentValues();
                cv.put(Telephony.Mms.Part.TEXT, new EncodedStringValue(data).getString());
                if (mContentResolver.update(uri, cv, null, null) != 1) {
                    throw new MmsException("unable to update " + uri.toString());
                }
            } else {
                os = mContentResolver.openOutputStream(uri);
                if (data == null) {
                    Uri dataUri = part.getDataUri();
                    if ((dataUri == null) || (dataUri == uri)) {
@@ -743,6 +765,7 @@ public class PduPersister {
                    }
                    os.write(data);
                }
            }
        } catch (FileNotFoundException e) {
            Log.e(TAG, "Failed to open Input/Output stream.", e);
            throw new MmsException(e);