diff options
author | Juffin Alex Varghese <jalex@codeaurora.org> | 2014-04-25 19:03:35 +0530 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2014-06-05 12:29:05 -0700 |
commit | fcd16d32cb7c3c14da7b54722ce3456840cb9289 (patch) | |
tree | a308f1472e204a6183a5869938ebec17f8067881 | |
parent | 38c152f9eda6b2854a638d2d754db79f775fbc83 (diff) | |
download | android_packages_apps_Bluetooth-fcd16d32cb7c3c14da7b54722ce3456840cb9289.tar.gz android_packages_apps_Bluetooth-fcd16d32cb7c3c14da7b54722ce3456840cb9289.tar.bz2 android_packages_apps_Bluetooth-fcd16d32cb7c3c14da7b54722ce3456840cb9289.zip |
Bluetooth-OPP: Avoid calling incoming notification if already notified
This change will ensure that incoming notification will not be shown
again if its already displayed. Otherwise, if there is an ongoing
transfer updatenotification thread will be called every 1 sec which
will update the pendingnotification even if its already notified.
Cleaning up Tx/Rx sessions if user abort occurs. Otherwise, cleanup
happens only transfer is successful this may cause Tx/Rx failure.
CRs-Fixed: 653842
Change-Id: Ifc1335849914f3032459117836473e0cd443060f
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppNotification.java | 36 | ||||
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppService.java | 13 |
2 files changed, 31 insertions, 18 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/src/com/android/bluetooth/opp/BluetoothOppNotification.java index 28e3fb909..c0061183e 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppNotification.java +++ b/src/com/android/bluetooth/opp/BluetoothOppNotification.java @@ -112,6 +112,7 @@ class BluetoothOppNotification { private int mInboundActiveNotificationId = 0; private int mOutboundActiveNotificationId = 0; + private int mIncomingShownId = 0; /** * This inner class is used to describe some properties for one transfer. @@ -596,27 +597,30 @@ class BluetoothOppNotification { long timeStamp = cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP)); Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + id); - Notification n = new Notification(); - n.icon = R.drawable.bt_incomming_file_notification; - n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; - n.flags |= Notification.FLAG_ONGOING_EVENT; - n.defaults = Notification.DEFAULT_SOUND; - n.tickerText = title; + if (mIncomingShownId != id) { + Notification n = new Notification(); + n.icon = R.drawable.bt_incomming_file_notification; + n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; + n.flags |= Notification.FLAG_ONGOING_EVENT; + n.defaults = Notification.DEFAULT_SOUND; + n.tickerText = title; - Intent intent = new Intent(Constants.ACTION_INCOMING_FILE_CONFIRM); - intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); - intent.setDataAndNormalize(contentUri); + Intent intent = new Intent(Constants.ACTION_INCOMING_FILE_CONFIRM); + intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); + intent.setDataAndNormalize(contentUri); - n.when = timeStamp; - n.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(mContext, 0, + n.when = timeStamp; + n.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(mContext, 0, intent, 0)); - intent = new Intent(Constants.ACTION_HIDE); - intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); - intent.setDataAndNormalize(contentUri); - n.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); + intent = new Intent(Constants.ACTION_HIDE); + intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); + intent.setDataAndNormalize(contentUri); + n.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); - mNotificationMgr.notify(id, n); + mNotificationMgr.notify(id, n); + mIncomingShownId = id; + } } cursor.close(); if (V) Log.v(TAG, "Freeing cursor: " + cursor); diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java index 8e7b836c6..945d5475c 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppService.java +++ b/src/com/android/bluetooth/opp/BluetoothOppService.java @@ -886,11 +886,20 @@ public class BluetoothOppService extends Service { if (V) Log.v(TAG, "Service cancel batch for share " + info.mId); batch.cancelBatch(); } - if (mTransfer != null) { - if (V) Log.v(TAG, "Stop transfer session"); + + /* Server/Client transfer cleanup */ + if ((batch.mDirection == BluetoothShare.DIRECTION_OUTBOUND) + && (mTransfer != null)) { + if (V) Log.v(TAG, "Stop Client Transfer"); mTransfer.stop(); mTransfer = null; + } else if ((batch.mDirection == BluetoothShare.DIRECTION_INBOUND) + && (mServerTransfer != null)) { + if (V) Log.v(TAG, "Stop Server Transfer"); + mServerTransfer.stop(); + mServerTransfer = null; } + if (batch.isEmpty()) { if (V) Log.v(TAG, "Service remove batch " + batch.mId); removeBatch(batch); |