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

Commit 9f97a2e9 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9428515 from d9c26a0f to tm-qpr2-release

Change-Id: I6397973d11f17c25ca4719127ca07c2cd74c2914
parents cb00fee5 d9c26a0f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@
    </target_preparer>
  <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
    <option name="run-command" value="settings put global ble_scan_always_enabled 0" />
    <option name="run-command" value="svc bluetooth disable" />
    <option name="run-command" value="cmd bluetooth_manager disable" />
    <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_OFF" />
  </target_preparer>
  <target_preparer class="com.android.tradefed.targetprep.FolderSaver">
    <option name="device-path" value="/data/vendor/ssrdump" />
+19 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
@@ -34,6 +35,7 @@ import com.android.obex.HeaderSet;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Proxy class for method calls to help with unit testing
@@ -132,6 +134,23 @@ public class BluetoothMethodProxy {
        return contentResolver.openFileDescriptor(uri, mode);
    }

    /**
     * Proxies {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
     */
    public AssetFileDescriptor contentResolverOpenAssetFileDescriptor(
            ContentResolver contentResolver, final Uri uri, final String mode)
            throws FileNotFoundException {
        return contentResolver.openAssetFileDescriptor(uri, mode);
    }

    /**
     * Proxies {@link ContentResolver#openInputStream(Uri)}.
     */
    public InputStream contentResolverOpenInputStream(ContentResolver contentResolver,
            final Uri uri) throws FileNotFoundException {
        return contentResolver.openInputStream(uri);
    }

    /**
     * Proxies {@link Context#sendBroadcast(Intent)}.
     */
+24 −14
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ public class BluetoothMapContent {

    // Parameter Mask for selection of parameters to return in listings
    private static final int MASK_SUBJECT = 0x00000001;
    private static final int MASK_DATETIME = 0x00000002;
    @VisibleForTesting
    static final int MASK_DATETIME = 0x00000002;
    private static final int MASK_SENDER_NAME = 0x00000004;
    private static final int MASK_SENDER_ADDRESSING = 0x00000008;
    private static final int MASK_RECIPIENT_NAME = 0x00000010;
@@ -80,7 +81,8 @@ public class BluetoothMapContent {
    private static final int MASK_SIZE = 0x00000080;
    private static final int MASK_RECEPTION_STATUS = 0x00000100;
    private static final int MASK_TEXT = 0x00000200;
    private static final int MASK_ATTACHMENT_SIZE = 0x00000400;
    @VisibleForTesting
    static final int MASK_ATTACHMENT_SIZE = 0x00000400;
    private static final int MASK_PRIORITY = 0x00000800;
    private static final int MASK_READ = 0x00001000;
    private static final int MASK_SENT = 0x00002000;
@@ -88,7 +90,8 @@ public class BluetoothMapContent {
    private static final int MASK_REPLYTO_ADDRESSING = 0x00008000;
    // TODO: Duplicate in proposed spec
    // private static final int MASK_RECEPTION_STATE       = 0x00010000;
    private static final int MASK_DELIVERY_STATUS = 0x00010000;
    @VisibleForTesting
    static final int MASK_DELIVERY_STATUS = 0x00010000;
    private static final int MASK_CONVERSATION_ID = 0x00020000;
    private static final int MASK_CONVERSATION_NAME = 0x00040000;
    private static final int MASK_FOLDER_TYPE = 0x00100000;
@@ -154,7 +157,8 @@ public class BluetoothMapContent {
    private String mMessageVersion = BluetoothMapUtils.MAP_V10_STR;

    private int mRemoteFeatureMask = BluetoothMapUtils.MAP_FEATURE_DEFAULT_BITMASK;
    private int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10;
    @VisibleForTesting
    int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10;

    static final String[] SMS_PROJECTION = new String[]{
            BaseColumns._ID,
@@ -592,7 +596,8 @@ public class BluetoothMapContent {
     * the total message size. To provide a more accurate attachment size, one could
     * extract the length (in bytes) of the text parts.
     */
    private void setAttachment(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi,
    @VisibleForTesting
    void setAttachment(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi,
            BluetoothMapAppParams ap) {
        if ((ap.getParameterMask() & MASK_ATTACHMENT_SIZE) != 0) {
            int size = 0;
@@ -687,7 +692,8 @@ public class BluetoothMapContent {
        }
    }

    private void setDeliveryStatus(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi,
    @VisibleForTesting
    void setDeliveryStatus(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi,
            BluetoothMapAppParams ap) {
        if ((ap.getParameterMask() & MASK_DELIVERY_STATUS) != 0) {
            String deliveryStatus = "delivered";
@@ -1247,8 +1253,8 @@ public class BluetoothMapContent {
        }
    }


    private void setDateTime(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi,
    @VisibleForTesting
    void setDateTime(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi,
            BluetoothMapAppParams ap) {
        if ((ap.getParameterMask() & MASK_DATETIME) != 0) {
            long date = 0;
@@ -2036,8 +2042,9 @@ public class BluetoothMapContent {


    /* Used only for SMS/MMS */
    private void setConvoWhereFilterSmsMms(StringBuilder selection, ArrayList<String> selectionArgs,
            FilterInfo fi, BluetoothMapAppParams ap) {
    @VisibleForTesting
    void setConvoWhereFilterSmsMms(StringBuilder selection, FilterInfo fi,
            BluetoothMapAppParams ap) {

        if (smsSelected(fi, ap) || mmsSelected(ap)) {

@@ -2088,7 +2095,8 @@ public class BluetoothMapContent {
     * @param ap
     * @return boolean true if sms is selected, false if not
     */
    private boolean smsSelected(FilterInfo fi, BluetoothMapAppParams ap) {
    @VisibleForTesting
    boolean smsSelected(FilterInfo fi, BluetoothMapAppParams ap) {
        int msgType = ap.getFilterMessageType();
        int phoneType = fi.mPhoneType;

@@ -2125,7 +2133,8 @@ public class BluetoothMapContent {
     * @param ap
     * @return boolean true if mms is selected, false if not
     */
    private boolean mmsSelected(BluetoothMapAppParams ap) {
    @VisibleForTesting
    boolean mmsSelected(BluetoothMapAppParams ap) {
        int msgType = ap.getFilterMessageType();

        if (D) {
@@ -2193,7 +2202,8 @@ public class BluetoothMapContent {
        return false;
    }

    private void setFilterInfo(FilterInfo fi) {
    @VisibleForTesting
    void setFilterInfo(FilterInfo fi) {
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        if (tm != null) {
            fi.mPhoneType = tm.getPhoneType();
@@ -2762,7 +2772,7 @@ public class BluetoothMapContent {
                StringBuilder selection = new StringBuilder(120); // This covers most cases
                ArrayList<String> selectionArgs = new ArrayList<String>(12); // Covers all cases
                selection.append("1=1 "); // just to simplify building the where-clause
                setConvoWhereFilterSmsMms(selection, selectionArgs, fi, ap);
                setConvoWhereFilterSmsMms(selection, fi, ap);
                String[] args = null;
                if (selectionArgs.size() > 0) {
                    args = new String[selectionArgs.size()];
+13 −5
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ import android.provider.Telephony.CanonicalAddressesColumns;
import android.provider.Telephony.MmsSms;
import android.util.Log;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.internal.annotations.VisibleForTesting;

import java.util.Arrays;
import java.util.HashMap;
import java.util.regex.Pattern;
@@ -40,7 +43,8 @@ public class SmsMmsContacts {
    private static final String TAG = "SmsMmsContacts";

    private HashMap<Long, String> mPhoneNumbers = null;
    private final HashMap<String, MapContact> mNames = new HashMap<String, MapContact>(10);
    @VisibleForTesting
    final HashMap<String, MapContact> mNames = new HashMap<String, MapContact>(10);

    private static final Uri ADDRESS_URI =
            MmsSms.CONTENT_URI.buildUpon().appendPath("canonical-addresses").build();
@@ -78,7 +82,8 @@ public class SmsMmsContacts {

    public static String getPhoneNumberUncached(ContentResolver resolver, long id) {
        String where = CanonicalAddressesColumns._ID + " = " + id;
        Cursor c = resolver.query(ADDRESS_URI, ADDRESS_PROJECTION, where, null, null);
        Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, ADDRESS_URI,
                ADDRESS_PROJECTION, where, null, null);
        try {
            if (c != null) {
                if (c.moveToPosition(0)) {
@@ -111,8 +116,10 @@ public class SmsMmsContacts {
     * a new query.
     * @param resolver the ContantResolver to be used.
     */
    private void fillPhoneCache(ContentResolver resolver) {
        Cursor c = resolver.query(ADDRESS_URI, ADDRESS_PROJECTION, null, null, null);
    @VisibleForTesting
    void fillPhoneCache(ContentResolver resolver) {
        Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, ADDRESS_URI,
                ADDRESS_PROJECTION, null, null, null);
        if (mPhoneNumbers == null) {
            int size = 0;
            if (c != null) {
@@ -184,7 +191,8 @@ public class SmsMmsContacts {
            selectionArgs = new String[]{"%" + contactNameFilter.replace("*", "%") + "%"};
        }

        Cursor c = resolver.query(uri, CONTACT_PROJECTION, selection, selectionArgs, null);
        Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, uri,
                CONTACT_PROJECTION, selection, selectionArgs, null);
        try {
            if (c != null && c.getCount() >= 1) {
                c.moveToFirst();
+13 −7
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.provider.OpenableColumns;
import android.util.EventLog;
import android.util.Log;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;

import java.io.File;
@@ -119,7 +120,8 @@ public class BluetoothOppSendFileInfo {
            contentType = contentResolver.getType(uri);
            Cursor metadataCursor;
            try {
                metadataCursor = contentResolver.query(uri, new String[]{
                metadataCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(
                        contentResolver, uri, new String[]{
                                OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE
                        }, null, null, null);
            } catch (SQLiteException e) {
@@ -180,7 +182,8 @@ public class BluetoothOppSendFileInfo {
                // right size in _OpenableColumns.SIZE
                // As a second source of getting the correct file length,
                // get a file descriptor and get the stat length
                AssetFileDescriptor fd = contentResolver.openAssetFileDescriptor(uri, "r");
                AssetFileDescriptor fd = BluetoothMethodProxy.getInstance()
                        .contentResolverOpenAssetFileDescriptor(contentResolver, uri, "r");
                long statLength = fd.getLength();
                if (length != statLength && statLength > 0) {
                    Log.e(TAG, "Content provider length is wrong (" + Long.toString(length)
@@ -200,7 +203,8 @@ public class BluetoothOppSendFileInfo {
                        length = getStreamSize(is);
                        Log.w(TAG, "File length not provided. Length from stream = " + length);
                        // Reset the stream
                        fd = contentResolver.openAssetFileDescriptor(uri, "r");
                        fd = BluetoothMethodProxy.getInstance()
                                .contentResolverOpenAssetFileDescriptor(contentResolver, uri, "r");
                        is = fd.createInputStream();
                    }
                } catch (IOException e) {
@@ -219,14 +223,16 @@ public class BluetoothOppSendFileInfo {

        if (is == null) {
            try {
                is = (FileInputStream) contentResolver.openInputStream(uri);
                is = (FileInputStream) BluetoothMethodProxy.getInstance()
                        .contentResolverOpenInputStream(contentResolver, uri);

                // If the database doesn't contain the file size, get the size
                // by reading through the entire stream
                if (length == 0) {
                    length = getStreamSize(is);
                    // Reset the stream
                    is = (FileInputStream) contentResolver.openInputStream(uri);
                    is = (FileInputStream) BluetoothMethodProxy.getInstance()
                            .contentResolverOpenInputStream(contentResolver, uri);
                }
            } catch (FileNotFoundException e) {
                return SEND_FILE_INFO_ERROR;
Loading