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

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

Merge "MAP: move moveMessageToFolder to BT Utils"

parents 90768e86 56e0598b
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -19,11 +19,13 @@ package com.android.bluetooth;
import android.app.AppOpsManager;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.ContentValues;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.ParcelUuid;
@@ -31,6 +33,7 @@ import android.os.Process;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Telephony;
import android.util.Log;

import org.xmlpull.v1.XmlPullParser;
@@ -586,4 +589,30 @@ public final class Utils {
        }
        return ret.toString();
    }

    /**
     * Move a message to the given folder.
     *
     * @param context the context to use
     * @param uri the message to move
     * @param messageSent if the message is SENT or FAILED
     * @return true if the operation succeeded
     */
    public static boolean moveMessageToFolder(Context context, Uri uri, boolean messageSent) {
        if (uri == null) {
            return false;
        }

        ContentValues values = new ContentValues(3);
        if (messageSent) {
            values.put(Telephony.Sms.READ, 1);
            values.put(Telephony.Sms.TYPE, Telephony.Sms.MESSAGE_TYPE_SENT);
        } else {
            values.put(Telephony.Sms.READ, 0);
            values.put(Telephony.Sms.TYPE, Telephony.Sms.MESSAGE_TYPE_FAILED);
        }
        values.put(Telephony.Sms.ERROR_CODE, 0);

        return 1 == context.getContentResolver().update(uri, values, null, null);
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.text.format.DateUtils;
import android.util.Log;
import android.util.Xml;

import com.android.bluetooth.Utils;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.map.BluetoothMapbMessageMime.MimePart;
import com.android.bluetooth.mapapi.BluetoothMapContract;
@@ -3302,7 +3303,7 @@ public class BluetoothMapContentObserver {
                    Log.d(TAG, "actionMessageSent: result OK");
                }
                if (msgInfo.transparent == 0) {
                    if (!Sms.moveMessageToFolder(context, msgInfo.uri, Sms.MESSAGE_TYPE_SENT, 0)) {
                    if (!Utils.moveMessageToFolder(context, msgInfo.uri, true)) {
                        Log.w(TAG, "Failed to move " + msgInfo.uri + " to SENT");
                    }
                } else {
@@ -3324,8 +3325,7 @@ public class BluetoothMapContentObserver {
                    sendEvent(evt);
                } else {
                    if (msgInfo.transparent == 0) {
                        if (!Sms.moveMessageToFolder(context, msgInfo.uri, Sms.MESSAGE_TYPE_FAILED,
                                0)) {
                        if (!Utils.moveMessageToFolder(context, msgInfo.uri, false)) {
                            Log.w(TAG, "Failed to move " + msgInfo.uri + " to FAILED");
                        }
                    } else {
@@ -3539,7 +3539,7 @@ public class BluetoothMapContentObserver {
        if (result == Activity.RESULT_OK) {
            Log.d(TAG, "actionMessageSentDisconnected: result OK");
            if (transparent == 0) {
                if (!Sms.moveMessageToFolder(context, uri, Sms.MESSAGE_TYPE_SENT, 0)) {
                if (!Utils.moveMessageToFolder(context, uri, true)) {
                    Log.d(TAG, "Failed to move " + uri + " to SENT");
                }
            } else {
@@ -3552,7 +3552,7 @@ public class BluetoothMapContentObserver {
            } else */
            {
                if (transparent == 0) {
                    if (!Sms.moveMessageToFolder(context, uri, Sms.MESSAGE_TYPE_FAILED, 0)) {
                    if (!Utils.moveMessageToFolder(context, uri, false)) {
                        Log.d(TAG, "Failed to move " + uri + " to FAILED");
                    }
                } else {
@@ -3627,7 +3627,7 @@ public class BluetoothMapContentObserver {
                    if (msgInfo == null || !msgInfo.resend) {
                        continue;
                    }
                    Sms.moveMessageToFolder(mContext, msgInfo.uri, Sms.MESSAGE_TYPE_FAILED, 0);
                    Utils.moveMessageToFolder(mContext, msgInfo.uri, false);
                } while (c.moveToNext());
            }
        } finally {