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

Commit 5c8c07b6 authored by Kihong Seong's avatar Kihong Seong Committed by Gerrit Code Review
Browse files

Merge "Add tests for BluetoothMapContent and BluetoothMapObexServer"

parents c5e9287c 17a00c98
Loading
Loading
Loading
Loading
+37 −27
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.Log;
import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.DeviceWorkArounds;
import com.android.bluetooth.SignedLongLong;
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;
@@ -1267,9 +1268,15 @@ public class BluetoothMapContent {
        }

        // Fix Subject Display issue with HONDA Carkit - Ignore subject Mask.
        if (DeviceWorkArounds.addressStartsWith(BluetoothMapService.getRemoteDevice().getAddress(),
                    DeviceWorkArounds.HONDA_CARKIT)
                || (ap.getParameterMask() & MASK_SUBJECT) != 0) {
        boolean isHondaCarkit;
        if (Utils.isInstrumentationTestMode()) {
            isHondaCarkit = false;
        } else {
            isHondaCarkit = DeviceWorkArounds.addressStartsWith(
                    BluetoothMapService.getRemoteDevice().getAddress(),
                    DeviceWorkArounds.HONDA_CARKIT);
        }
        if (isHondaCarkit || (ap.getParameterMask() & MASK_SUBJECT) != 0) {
            if (fi.mMsgType == FilterInfo.TYPE_SMS) {
                subject = c.getString(fi.mSmsColSubject);
            } else if (fi.mMsgType == FilterInfo.TYPE_MMS) {
@@ -2177,7 +2184,8 @@ public class BluetoothMapContent {
                    if (D) {
                        Log.d(TAG, "msgType: " + fi.mMsgType + " where: " + where);
                    }
                    smsCursor = mResolver.query(Sms.CONTENT_URI, SMS_PROJECTION, where, null,
                    smsCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                            Sms.CONTENT_URI, SMS_PROJECTION, where, null,
                            Sms.DATE + " DESC" + limit);
                    if (smsCursor != null) {
                        BluetoothMapMessageListingElement e = null;
@@ -2219,7 +2227,8 @@ public class BluetoothMapContent {
                    if (D) {
                        Log.d(TAG, "msgType: " + fi.mMsgType + " where: " + where);
                    }
                    mmsCursor = mResolver.query(Mms.CONTENT_URI, MMS_PROJECTION, where, null,
                    mmsCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                            Mms.CONTENT_URI, MMS_PROJECTION, where, null,
                            Mms.DATE + " DESC" + limit);
                    if (mmsCursor != null) {
                        BluetoothMapMessageListingElement e = null;
@@ -2262,9 +2271,8 @@ public class BluetoothMapContent {
                        Log.d(TAG, "msgType: " + fi.mMsgType + " where: " + where);
                    }
                    Uri contentUri = Uri.parse(mBaseUri + BluetoothMapContract.TABLE_MESSAGE);
                    emailCursor =
                            mResolver.query(contentUri, BluetoothMapContract.BT_MESSAGE_PROJECTION,
                                    where, null,
                    emailCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                            contentUri, BluetoothMapContract.BT_MESSAGE_PROJECTION, where, null,
                            BluetoothMapContract.MessageColumns.DATE + " DESC" + limit);
                    if (emailCursor != null) {
                        BluetoothMapMessageListingElement e = null;
@@ -2305,8 +2313,8 @@ public class BluetoothMapContent {
                }

                Uri contentUri = Uri.parse(mBaseUri + BluetoothMapContract.TABLE_MESSAGE);
                imCursor = mResolver.query(contentUri,
                        BluetoothMapContract.BT_INSTANT_MESSAGE_PROJECTION, where, null,
                imCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                        contentUri, BluetoothMapContract.BT_INSTANT_MESSAGE_PROJECTION, where, null,
                        BluetoothMapContract.MessageColumns.DATE + " DESC" + limit);
                if (imCursor != null) {
                    BluetoothMapMessageListingElement e = null;
@@ -2414,8 +2422,8 @@ public class BluetoothMapContent {
        if (smsSelected(fi, ap) && folderElement.hasSmsMmsContent()) {
            fi.mMsgType = FilterInfo.TYPE_SMS;
            String where = setWhereFilter(folderElement, fi, ap);
            Cursor c = mResolver.query(Sms.CONTENT_URI, SMS_PROJECTION, where, null,
                    Sms.DATE + " DESC");
            Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                    Sms.CONTENT_URI, SMS_PROJECTION, where, null, Sms.DATE + " DESC");
            try {
                if (c != null) {
                    cnt = c.getCount();
@@ -2430,8 +2438,8 @@ public class BluetoothMapContent {
        if (mmsSelected(ap) && folderElement.hasSmsMmsContent()) {
            fi.mMsgType = FilterInfo.TYPE_MMS;
            String where = setWhereFilter(folderElement, fi, ap);
            Cursor c = mResolver.query(Mms.CONTENT_URI, MMS_PROJECTION, where, null,
                    Mms.DATE + " DESC");
            Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                    Mms.CONTENT_URI, MMS_PROJECTION, where, null, Mms.DATE + " DESC");
            try {
                if (c != null) {
                    cnt += c.getCount();
@@ -2448,8 +2456,9 @@ public class BluetoothMapContent {
            String where = setWhereFilter(folderElement, fi, ap);
            if (!where.isEmpty()) {
                Uri contentUri = Uri.parse(mBaseUri + BluetoothMapContract.TABLE_MESSAGE);
                Cursor c = mResolver.query(contentUri, BluetoothMapContract.BT_MESSAGE_PROJECTION,
                        where, null, BluetoothMapContract.MessageColumns.DATE + " DESC");
                Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                        contentUri, BluetoothMapContract.BT_MESSAGE_PROJECTION, where, null,
                        BluetoothMapContract.MessageColumns.DATE + " DESC");
                try {
                    if (c != null) {
                        cnt += c.getCount();
@@ -2467,8 +2476,8 @@ public class BluetoothMapContent {
            String where = setWhereFilter(folderElement, fi, ap);
            if (!where.isEmpty()) {
                Uri contentUri = Uri.parse(mBaseUri + BluetoothMapContract.TABLE_MESSAGE);
                Cursor c = mResolver.query(contentUri,
                        BluetoothMapContract.BT_INSTANT_MESSAGE_PROJECTION, where, null,
                Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                        contentUri, BluetoothMapContract.BT_INSTANT_MESSAGE_PROJECTION, where, null,
                        BluetoothMapContract.MessageColumns.DATE + " DESC");
                try {
                    if (c != null) {
@@ -2510,8 +2519,8 @@ public class BluetoothMapContent {
            String where = setWhereFilterFolderType(folderElement, fi);
            where += " AND " + Sms.READ + "=0 ";
            where += setWhereFilterPeriod(ap, fi);
            Cursor c = mResolver.query(Sms.CONTENT_URI, SMS_PROJECTION, where, null,
                    Sms.DATE + " DESC");
            Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                    Sms.CONTENT_URI, SMS_PROJECTION, where, null, Sms.DATE + " DESC");
            try {
                if (c != null) {
                    cnt = c.getCount();
@@ -2528,8 +2537,8 @@ public class BluetoothMapContent {
            String where = setWhereFilterFolderType(folderElement, fi);
            where += " AND " + Mms.READ + "=0 ";
            where += setWhereFilterPeriod(ap, fi);
            Cursor c = mResolver.query(Mms.CONTENT_URI, MMS_PROJECTION, where, null,
                    Sms.DATE + " DESC");
            Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                    Mms.CONTENT_URI, MMS_PROJECTION, where, null, Sms.DATE + " DESC");
            try {
                if (c != null) {
                    cnt += c.getCount();
@@ -2549,8 +2558,9 @@ public class BluetoothMapContent {
                where += " AND " + BluetoothMapContract.MessageColumns.FLAG_READ + "=0 ";
                where += setWhereFilterPeriod(ap, fi);
                Uri contentUri = Uri.parse(mBaseUri + BluetoothMapContract.TABLE_MESSAGE);
                Cursor c = mResolver.query(contentUri, BluetoothMapContract.BT_MESSAGE_PROJECTION,
                        where, null, BluetoothMapContract.MessageColumns.DATE + " DESC");
                Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                        contentUri, BluetoothMapContract.BT_MESSAGE_PROJECTION, where, null,
                        BluetoothMapContract.MessageColumns.DATE + " DESC");
                try {
                    if (c != null) {
                        cnt += c.getCount();
@@ -2570,8 +2580,8 @@ public class BluetoothMapContent {
                where += " AND " + BluetoothMapContract.MessageColumns.FLAG_READ + "=0 ";
                where += setWhereFilterPeriod(ap, fi);
                Uri contentUri = Uri.parse(mBaseUri + BluetoothMapContract.TABLE_MESSAGE);
                Cursor c = mResolver.query(contentUri,
                        BluetoothMapContract.BT_INSTANT_MESSAGE_PROJECTION, where, null,
                Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(mResolver,
                        contentUri, BluetoothMapContract.BT_INSTANT_MESSAGE_PROJECTION, where, null,
                        BluetoothMapContract.MessageColumns.DATE + " DESC");
                try {
                    if (c != null) {
+2 −1
Original line number Diff line number Diff line
@@ -1311,7 +1311,8 @@ public class BluetoothMapObexServer extends ServerRequestHandler {
     * @param overwrite True: The msgType will be overwritten to match the message types supported
     * by this MAS instance. False: any unsupported message types will be masked out.
     */
    private void setMsgTypeFilterParams(BluetoothMapAppParams appParams, boolean overwrite) {
    @VisibleForTesting
    void setMsgTypeFilterParams(BluetoothMapAppParams appParams, boolean overwrite) {
        int masFilterMask = 0;
        if (!mEnableSmsMms) {
            masFilterMask |= BluetoothMapAppParams.FILTER_NO_SMS_CDMA;