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

Commit 68a35bf3 authored by Hieu Dang's avatar Hieu Dang Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cherrypicker-L28300000957131399:N26000001307705233" into tm-qpr-dev

* changes:
  Fix BluetoothOppBatchTest unknown URI
  Fix NullPointerException in BluetoothOppPereference
  Add BluetoothOppTransferActivityTest
  Fix BluetoothOppBatchTest doesn't work
  Add BluetoothOppUtilityTest
  Add BluetoothOppTestUtils
parents 7f8e3f67 48a8efde
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
@@ -74,6 +75,23 @@ public class BluetoothMethodProxy {
        return contentResolver.query(contentUri, projection, selection, selectionArgs, sortOrder);
    }

    /**
     * Proxies {@link ContentResolver#delete(Uri, String, String[])}.
     */
    public int contentResolverDelete(ContentResolver contentResolver, final Uri url,
            final String where,
            final String[] selectionArgs) {
        return contentResolver.delete(url, where, selectionArgs);
    }

    /**
     * Proxies {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
     */
    public int contentResolverUpdate(ContentResolver contentResolver, final Uri contentUri,
            final ContentValues contentValues, String where, String[] selectionArgs) {
        return contentResolver.update(contentUri, contentValues, where, selectionArgs);
    }

    /**
     * Proxies {@link HeaderSet#getHeader}.
     */
+5 −1
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;

import com.android.bluetooth.BluetoothMethodProxy;

import java.util.ArrayList;

/**
@@ -148,7 +150,9 @@ public class BluetoothOppBatch {

            if (info.mStatus < 200) {
                if (info.mDirection == BluetoothShare.DIRECTION_INBOUND && info.mUri != null) {
                    mContext.getContentResolver().delete(info.mUri, null, null);
                    BluetoothMethodProxy.getInstance().contentResolverDelete(
                            mContext.getContentResolver(), info.mUri, null, null
                    );
                }
                if (V) {
                    Log.v(TAG, "Cancel batch for info " + info.mId);
+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ public class BluetoothOppPreference {
    }

    public String getName(BluetoothDevice remoteDevice) {
        if (remoteDevice.getIdentityAddress().equals("FF:FF:FF:00:00:00")) {
        String identityAddress = remoteDevice.getIdentityAddress();
        if (identityAddress != null && identityAddress.equals("FF:FF:FF:00:00:00")) {
            return "localhost";
        }
        if (!mNames.isEmpty()) {
+4 −1
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import android.widget.Toast;

import com.android.bluetooth.R;

import com.google.common.annotations.VisibleForTesting;

/**
 * Handle all transfer related dialogs: -Ongoing transfer -Receiving one file
 * dialog -Sending one file dialog -sending multiple files dialog -Complete
@@ -83,7 +85,8 @@ public class BluetoothOppTransferActivity extends AlertActivity

    private TextView mLine1View, mLine2View, mLine3View, mLine5View;

    private int mWhichDialog;
    @VisibleForTesting
    int mWhichDialog;

    private BluetoothAdapter mAdapter;

+18 −8
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.os.SystemProperties;
import android.util.EventLog;
import android.util.Log;

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

import java.io.File;
@@ -88,7 +89,9 @@ public class BluetoothOppUtility {

    public static BluetoothOppTransferInfo queryRecord(Context context, Uri uri) {
        BluetoothOppTransferInfo info = new BluetoothOppTransferInfo();
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        Cursor cursor = BluetoothMethodProxy.getInstance().contentResolverQuery(
                context.getContentResolver(), uri, null, null, null, null
        );
        if (cursor != null) {
            if (cursor.moveToFirst()) {
                fillRecord(context, cursor, info);
@@ -157,10 +160,14 @@ public class BluetoothOppUtility {
    public static ArrayList<String> queryTransfersInBatch(Context context, Long timeStamp) {
        ArrayList<String> uris = new ArrayList();
        final String where = BluetoothShare.TIMESTAMP + " == " + timeStamp;
        Cursor metadataCursor =
                context.getContentResolver().query(BluetoothShare.CONTENT_URI, new String[]{
                        BluetoothShare._DATA
                }, where, null, BluetoothShare._ID);
        Cursor metadataCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(
                context.getContentResolver(),
                BluetoothShare.CONTENT_URI,
                new String[]{BluetoothShare._DATA},
                where,
                null,
                BluetoothShare._ID
        );

        if (metadataCursor == null) {
            return null;
@@ -200,8 +207,10 @@ public class BluetoothOppUtility {
        }

        Uri path = null;
        Cursor metadataCursor = context.getContentResolver().query(uri, new String[]{
                BluetoothShare.URI}, null, null, null);
        Cursor metadataCursor = BluetoothMethodProxy.getInstance().contentResolverQuery(
                context.getContentResolver(), uri, new String[]{BluetoothShare.URI},
                null, null, null
        );
        if (metadataCursor != null) {
            try {
                if (metadataCursor.moveToFirst()) {
@@ -307,7 +316,8 @@ public class BluetoothOppUtility {
    public static void updateVisibilityToHidden(Context context, Uri uri) {
        ContentValues updateValues = new ContentValues();
        updateValues.put(BluetoothShare.VISIBILITY, BluetoothShare.VISIBILITY_HIDDEN);
        context.getContentResolver().update(uri, updateValues, null, null);
        BluetoothMethodProxy.getInstance().contentResolverUpdate(context.getContentResolver(), uri,
                updateValues, null, null);
    }

    /**
Loading