Loading src/com/android/bluetooth/Utils.java +29 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } } src/com/android/bluetooth/map/BluetoothMapContentObserver.java +6 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading @@ -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 { Loading Loading @@ -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 { Loading @@ -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 { Loading Loading @@ -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 { Loading Loading
src/com/android/bluetooth/Utils.java +29 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } }
src/com/android/bluetooth/map/BluetoothMapContentObserver.java +6 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading @@ -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 { Loading Loading @@ -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 { Loading @@ -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 { Loading Loading @@ -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 { Loading