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

Commit bb8c811e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "HFP: use Bundle to query last dial number" into rvc-dev am: 1e29a6e3 am: 7c936d7d

Change-Id: Ib8a76205da801ae463cd2fd41ad7029bb1ed3abe
parents 5ba016f9 7c936d7d
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.PhoneLookup;
@@ -115,9 +116,13 @@ public class AtPhonebook {
    /** Returns the last dialled number, or null if no numbers have been called */
    public String getLastDialledNumber() {
        String[] projection = {Calls.NUMBER};
        Cursor cursor = mContentResolver.query(Calls.CONTENT_URI, projection,
                Calls.TYPE + "=" + Calls.OUTGOING_TYPE, null,
                Calls.DEFAULT_SORT_ORDER + " LIMIT 1");
        Bundle queryArgs = new Bundle();
        queryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
                Calls.TYPE + "=" + Calls.OUTGOING_TYPE);
        queryArgs.putString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER, Calls.DEFAULT_SORT_ORDER);
        queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT, 1);

        Cursor cursor = mContentResolver.query(Calls.CONTENT_URI, projection, queryArgs, null);
        if (cursor == null) {
            Log.w(TAG, "getLastDialledNumber, cursor is null");
            return null;
+13 −9
Original line number Diff line number Diff line
@@ -22,15 +22,19 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothProfile;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.HandlerThread;
import android.os.UserHandle;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.telephony.PhoneStateListener;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
@@ -864,8 +868,8 @@ public class HeadsetStateMachineTest {
        when(cursor.getString(magicNumber)).thenReturn(TEST_PHONE_NUMBER);
        MockContentProvider mockContentProvider = new MockContentProvider() {
            @Override
            public Cursor query(Uri uri, String[] projection, String selection,
                    String[] selectionArgs, String sortOrder) {
            public Cursor query(Uri uri, String[] projection, Bundle queryArgs,
                        CancellationSignal cancellationSignal) {
                if (uri == null || !uri.equals(CallLog.Calls.CONTENT_URI)) {
                    return null;
                }
@@ -873,15 +877,15 @@ public class HeadsetStateMachineTest {
                        CallLog.Calls.NUMBER)) {
                    return null;
                }
                if (selection == null || !selection.equals(
                        CallLog.Calls.TYPE + "=" + CallLog.Calls.OUTGOING_TYPE)) {
                if (queryArgs == null
                        || !queryArgs.getString(ContentResolver.QUERY_ARG_SQL_SELECTION).equals(
                                Calls.TYPE + "=" + Calls.OUTGOING_TYPE)
                        || !queryArgs.getString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER).equals(
                                Calls.DEFAULT_SORT_ORDER)
                        || queryArgs.getInt(ContentResolver.QUERY_ARG_LIMIT) != 1) {
                    return null;
                }
                if (selectionArgs != null) {
                    return null;
                }
                if (sortOrder == null || !sortOrder.equals(
                        CallLog.Calls.DEFAULT_SORT_ORDER + " LIMIT 1")) {
                if (cancellationSignal != null) {
                    return null;
                }
                return cursor;