Loading android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +12 −18 Original line number Diff line number Diff line Loading @@ -99,10 +99,6 @@ class BluetoothOppNotification { private int mActiveNotificationId = 0; private Notification mOutNoti = null; private Notification mInNoti = null; /** * This inner class is used to describe some properties for one transfer. */ Loading Loading @@ -348,21 +344,20 @@ class BluetoothOppNotification { outboundNum = outboundSuccNumber + outboundFailNumber; // create the outbound notification if (outboundNum > 0) { mOutNoti = new Notification(); mOutNoti.icon = android.R.drawable.stat_sys_upload_done; Notification outNoti = new Notification(); outNoti.icon = android.R.drawable.stat_sys_upload_done; title = mContext.getString(R.string.outbound_noti_title); caption = mContext.getString(R.string.noti_caption, outboundSuccNumber, outboundFailNumber); intent = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER); intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); mOutNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( outNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( mContext, 0, intent, 0)); mOutNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_OUTBOUND, mOutNoti); outNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_OUTBOUND, outNoti); } else { if (mNotificationMgr != null && mOutNoti != null) { if (mNotificationMgr != null) { mNotificationMgr.cancel(NOTIFICATION_ID_OUTBOUND); mOutNoti = null; if (V) Log.v(TAG, "outbound notification was removed."); } } Loading Loading @@ -393,21 +388,20 @@ class BluetoothOppNotification { inboundNum = inboundSuccNumber + inboundFailNumber; // create the inbound notification if (inboundNum > 0) { mInNoti = new Notification(); mInNoti.icon = android.R.drawable.stat_sys_download_done; Notification inNoti = new Notification(); inNoti.icon = android.R.drawable.stat_sys_download_done; title = mContext.getString(R.string.inbound_noti_title); caption = mContext.getString(R.string.noti_caption, inboundSuccNumber, inboundFailNumber); intent = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER); intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); mInNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( inNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( mContext, 0, intent, 0)); mInNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_INBOUND, mInNoti); inNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_INBOUND, inNoti); } else { if (mNotificationMgr != null && mInNoti != null) { if (mNotificationMgr != null) { mNotificationMgr.cancel(NOTIFICATION_ID_INBOUND); mInNoti = null; if (V) Log.v(TAG, "inbound notification was removed."); } } Loading android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java +23 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.bluetooth.R; import android.app.Activity; import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; Loading Loading @@ -75,6 +76,9 @@ public class BluetoothOppTransferHistory extends Activity implements private int mContextMenuPosition; /** Class to handle Notification Manager updates */ private BluetoothOppNotification mNotifier; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Loading Loading @@ -117,6 +121,8 @@ public class BluetoothOppTransferHistory extends Activity implements mListView.setOnCreateContextMenuListener(this); mListView.setOnItemClickListener(this); } mNotifier = new BluetoothOppNotification(this); } @Override Loading Loading @@ -151,12 +157,14 @@ public class BluetoothOppTransferHistory extends Activity implements switch (item.getItemId()) { case R.id.transfer_menu_open: openCompleteTransfer(); updateNotificationWhenBtDisabled(); return true; case R.id.transfer_menu_clear: int sessionId = mTransferCursor.getInt(mIdColumnId); Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + sessionId); BluetoothOppUtility.updateVisibilityToHidden(this, contentUri); updateNotificationWhenBtDisabled(); return true; } return false; Loading Loading @@ -224,6 +232,7 @@ public class BluetoothOppTransferHistory extends Activity implements mTransferCursor.moveToNext(); } updateNotificationWhenBtDisabled(); } } Loading @@ -237,6 +246,7 @@ public class BluetoothOppTransferHistory extends Activity implements // Open the selected item mTransferCursor.moveToPosition(position); openCompleteTransfer(); updateNotificationWhenBtDisabled(); } /** Loading Loading @@ -265,4 +275,17 @@ public class BluetoothOppTransferHistory extends Activity implements this.startActivity(in); } } /** * When Bluetooth is disabled, notification can not be updated by * ContentObserver in OppService, so need update manually. */ private void updateNotificationWhenBtDisabled() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (!adapter.isEnabled()) { if (V) Log.v(TAG, "Bluetooth is not enabled, update notification manually."); mNotifier.updateNotification(); mNotifier.finishNotification(); } } } Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +12 −18 Original line number Diff line number Diff line Loading @@ -99,10 +99,6 @@ class BluetoothOppNotification { private int mActiveNotificationId = 0; private Notification mOutNoti = null; private Notification mInNoti = null; /** * This inner class is used to describe some properties for one transfer. */ Loading Loading @@ -348,21 +344,20 @@ class BluetoothOppNotification { outboundNum = outboundSuccNumber + outboundFailNumber; // create the outbound notification if (outboundNum > 0) { mOutNoti = new Notification(); mOutNoti.icon = android.R.drawable.stat_sys_upload_done; Notification outNoti = new Notification(); outNoti.icon = android.R.drawable.stat_sys_upload_done; title = mContext.getString(R.string.outbound_noti_title); caption = mContext.getString(R.string.noti_caption, outboundSuccNumber, outboundFailNumber); intent = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER); intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); mOutNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( outNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( mContext, 0, intent, 0)); mOutNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_OUTBOUND, mOutNoti); outNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_OUTBOUND, outNoti); } else { if (mNotificationMgr != null && mOutNoti != null) { if (mNotificationMgr != null) { mNotificationMgr.cancel(NOTIFICATION_ID_OUTBOUND); mOutNoti = null; if (V) Log.v(TAG, "outbound notification was removed."); } } Loading Loading @@ -393,21 +388,20 @@ class BluetoothOppNotification { inboundNum = inboundSuccNumber + inboundFailNumber; // create the inbound notification if (inboundNum > 0) { mInNoti = new Notification(); mInNoti.icon = android.R.drawable.stat_sys_download_done; Notification inNoti = new Notification(); inNoti.icon = android.R.drawable.stat_sys_download_done; title = mContext.getString(R.string.inbound_noti_title); caption = mContext.getString(R.string.noti_caption, inboundSuccNumber, inboundFailNumber); intent = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER); intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); mInNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( inNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast( mContext, 0, intent, 0)); mInNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_INBOUND, mInNoti); inNoti.when = timeStamp; mNotificationMgr.notify(NOTIFICATION_ID_INBOUND, inNoti); } else { if (mNotificationMgr != null && mInNoti != null) { if (mNotificationMgr != null) { mNotificationMgr.cancel(NOTIFICATION_ID_INBOUND); mInNoti = null; if (V) Log.v(TAG, "inbound notification was removed."); } } Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppTransferHistory.java +23 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.bluetooth.R; import android.app.Activity; import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; Loading Loading @@ -75,6 +76,9 @@ public class BluetoothOppTransferHistory extends Activity implements private int mContextMenuPosition; /** Class to handle Notification Manager updates */ private BluetoothOppNotification mNotifier; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Loading Loading @@ -117,6 +121,8 @@ public class BluetoothOppTransferHistory extends Activity implements mListView.setOnCreateContextMenuListener(this); mListView.setOnItemClickListener(this); } mNotifier = new BluetoothOppNotification(this); } @Override Loading Loading @@ -151,12 +157,14 @@ public class BluetoothOppTransferHistory extends Activity implements switch (item.getItemId()) { case R.id.transfer_menu_open: openCompleteTransfer(); updateNotificationWhenBtDisabled(); return true; case R.id.transfer_menu_clear: int sessionId = mTransferCursor.getInt(mIdColumnId); Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + sessionId); BluetoothOppUtility.updateVisibilityToHidden(this, contentUri); updateNotificationWhenBtDisabled(); return true; } return false; Loading Loading @@ -224,6 +232,7 @@ public class BluetoothOppTransferHistory extends Activity implements mTransferCursor.moveToNext(); } updateNotificationWhenBtDisabled(); } } Loading @@ -237,6 +246,7 @@ public class BluetoothOppTransferHistory extends Activity implements // Open the selected item mTransferCursor.moveToPosition(position); openCompleteTransfer(); updateNotificationWhenBtDisabled(); } /** Loading Loading @@ -265,4 +275,17 @@ public class BluetoothOppTransferHistory extends Activity implements this.startActivity(in); } } /** * When Bluetooth is disabled, notification can not be updated by * ContentObserver in OppService, so need update manually. */ private void updateNotificationWhenBtDisabled() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (!adapter.isEnabled()) { if (V) Log.v(TAG, "Bluetooth is not enabled, update notification manually."); mNotifier.updateNotification(); mNotifier.finishNotification(); } } }