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

Commit a7c96beb authored by Martijn Coenen's avatar Martijn Coenen Committed by Android Git Automerger
Browse files

am 04a89e0f: Merge "Add BT address and mimeType to handover intents." into jb-dev

* commit '04a89e0f':
  Add BT address and mimeType to handover intents.
parents bb421a45 04a89e0f
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -165,13 +165,19 @@ public class BluetoothOppManager {
        }
    }

    public void addToWhitelist(String address) {
    public synchronized void addToWhitelist(String address) {
        if (address == null) return;

        // Remove any existing entries
        for (Iterator<Pair<String,Long>> iter = mWhitelist.iterator(); iter.hasNext(); ) {
            Pair<String,Long> entry = iter.next();
            if (entry.first.equals(address)) {
                iter.remove();
            }
        }
        mWhitelist.add(new Pair<String, Long>(address, SystemClock.elapsedRealtime()));
    }

    public boolean isWhitelisted(String address) {
    public synchronized boolean isWhitelisted(String address) {
        cleanupWhitelist();
        for (Pair<String,Long> entry : mWhitelist) {
            if (entry.first.equals(address)) return true;
+6 −1
Original line number Diff line number Diff line
@@ -120,6 +120,8 @@ class BluetoothOppNotification {
        String description; // the text above progress bar

        boolean handoverInitiated = false; // transfer initiated by connection handover (eg NFC)

        String destination; // destination associated with this transfer
    }

    /**
@@ -232,6 +234,7 @@ class BluetoothOppNotification {
        final int dataIndex = cursor.getColumnIndexOrThrow(BluetoothShare._DATA);
        final int filenameHintIndex = cursor.getColumnIndexOrThrow(BluetoothShare.FILENAME_HINT);
        final int confirmIndex = cursor.getColumnIndexOrThrow(BluetoothShare.USER_CONFIRMATION);
        final int destinationIndex = cursor.getColumnIndexOrThrow(BluetoothShare.DESTINATION);

        mNotifications.clear();
        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
@@ -242,6 +245,7 @@ class BluetoothOppNotification {
            int current = cursor.getInt(currentBytesIndex);
            int confirmation = cursor.getInt(confirmIndex);

            String destination = cursor.getString(destinationIndex);
            String fileName = cursor.getString(dataIndex);
            if (fileName == null) {
                fileName = cursor.getString(filenameHintIndex);
@@ -273,6 +277,7 @@ class BluetoothOppNotification {
                item.totalTotal = total;
                item.handoverInitiated =
                        confirmation == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED;
                item.destination = destination;
                mNotifications.put(batchID, item);

                if (V) Log.v(TAG, "ID=" + item.id + "; batchID=" + batchID + "; totoalCurrent"
@@ -302,7 +307,7 @@ class BluetoothOppNotification {
                }
                intent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_ID, item.id);
                intent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_PROGRESS, progress);

                intent.putExtra(Constants.EXTRA_BT_OPP_ADDRESS, item.destination);
                mContext.sendBroadcast(intent, Constants.HANDOVER_STATUS_PERMISSION);
                continue;
            }
+4 −0
Original line number Diff line number Diff line
@@ -240,11 +240,15 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
                            Constants.DIRECTION_BLUETOOTH_OUTGOING);
                }
                handoverIntent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_ID, transInfo.mID);
                handoverIntent.putExtra(Constants.EXTRA_BT_OPP_ADDRESS, transInfo.mDestAddr);

                if (BluetoothShare.isStatusSuccess(transInfo.mStatus)) {
                    handoverIntent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_STATUS,
                            Constants.HANDOVER_TRANSFER_STATUS_SUCCESS);
                    handoverIntent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_URI,
                            transInfo.mFileName);
                    handoverIntent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_MIMETYPE,
                            transInfo.mFileType);
                } else {
                    handoverIntent.putExtra(Constants.EXTRA_BT_OPP_TRANSFER_STATUS,
                            Constants.HANDOVER_TRANSFER_STATUS_FAILURE);
+9 −0
Original line number Diff line number Diff line
@@ -89,6 +89,10 @@ public class Constants {
    public static final String EXTRA_BT_OPP_TRANSFER_STATUS =
            "android.btopp.intent.extra.BT_OPP_TRANSFER_STATUS";

    /** intent extra used to indicate the address associated with the transfer */
    public static final String EXTRA_BT_OPP_ADDRESS =
            "android.btopp.intent.extra.BT_OPP_ADDRESS";

    public static final int HANDOVER_TRANSFER_STATUS_SUCCESS = 0;

    public static final int HANDOVER_TRANSFER_STATUS_FAILURE = 1;
@@ -114,6 +118,11 @@ public class Constants {
    public static final String EXTRA_BT_OPP_TRANSFER_URI =
            "android.btopp.intent.extra.BT_OPP_TRANSFER_URI";

    /** intent extra used to provide the mime-type of the data in
     *  the handover transfer */
    public static final String EXTRA_BT_OPP_TRANSFER_MIMETYPE =
            "android.btopp.intent.extra.BT_OPP_TRANSFER_MIMETYPE";

    /** permission needed to be able to receive handover status requests */
    public static final String HANDOVER_STATUS_PERMISSION =
            "com.android.permission.HANDOVER_STATUS";