Loading src/com/android/bluetooth/opp/BluetoothOppManager.java +9 −3 Original line number Diff line number Diff line Loading @@ -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; Loading src/com/android/bluetooth/opp/BluetoothOppNotification.java +6 −1 Original line number Diff line number Diff line Loading @@ -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 } /** Loading Loading @@ -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()) { Loading @@ -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); Loading Loading @@ -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" Loading Loading @@ -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; } Loading src/com/android/bluetooth/opp/BluetoothOppReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -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); Loading src/com/android/bluetooth/opp/Constants.java +9 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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"; Loading Loading
src/com/android/bluetooth/opp/BluetoothOppManager.java +9 −3 Original line number Diff line number Diff line Loading @@ -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; Loading
src/com/android/bluetooth/opp/BluetoothOppNotification.java +6 −1 Original line number Diff line number Diff line Loading @@ -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 } /** Loading Loading @@ -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()) { Loading @@ -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); Loading Loading @@ -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" Loading Loading @@ -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; } Loading
src/com/android/bluetooth/opp/BluetoothOppReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
src/com/android/bluetooth/opp/Constants.java +9 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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"; Loading