}
}
- 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;
String description; // the text above progress bar
boolean handoverInitiated = false; // transfer initiated by connection handover (eg NFC)
+
+ String destination; // destination associated with this transfer
}
/**
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()) {
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);
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"
}
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;
}
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);
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;
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";