private void report ( final int error ) { sendErrorBroadcast ( error ) ; if ( mDisableNotification ) return ; // create or update notification: final String deviceAddress = mDeviceAddress ; final String deviceName = mDeviceName != null ? mDeviceName : getString ( R . string . dfu_unknown_name ) ; final NotificationCompat . Builder builder = new NotificationCompat . Builder ( this , NOTIFICATION_CHANNEL_DFU ) . setSmallIcon ( android . R . drawable . stat_sys_upload ) . setOnlyAlertOnce ( true ) . setColor ( Color . RED ) . setOngoing ( false ) . setContentTitle ( getString ( R . string . dfu_status_error ) ) . setSmallIcon ( android . R . drawable . stat_sys_upload_done ) . setContentText ( getString ( R . string . dfu_status_error_msg ) ) . setAutoCancel ( true ) ; // update the notification final Intent intent = new Intent ( this , getNotificationTarget ( ) ) ; intent . addFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; intent . putExtra ( EXTRA_DEVICE_ADDRESS , deviceAddress ) ; intent . putExtra ( EXTRA_DEVICE_NAME , deviceName ) ; intent . putExtra ( EXTRA_PROGRESS , error ) ; // this may contains ERROR_CONNECTION_MASK bit! final PendingIntent pendingIntent = PendingIntent . getActivity ( this , 0 , intent , PendingIntent . FLAG_UPDATE_CURRENT ) ; builder . setContentIntent ( pendingIntent ) ; // Any additional configuration? updateErrorNotification ( builder ) ; final NotificationManager manager = ( NotificationManager ) getSystemService ( Context . NOTIFICATION_SERVICE ) ; manager . notify ( NOTIFICATION_ID , builder . build ( ) ) ; }
Creates or updates the notification in the Notification Manager . Sends broadcast with given error number to the activity .