private void updateConnectedDevices ( final List < USBStorageDevice > currentConnectedDevices ) { final List < USBStorageDevice > removedDevices = new ArrayList <> ( ) ; synchronized ( this ) { final Iterator < USBStorageDevice > itConnectedDevices = connectedDevices . iterator ( ) ; while ( itConnectedDevices . hasNext ( ) ) { final USBStorageDevice device = itConnectedDevices . next ( ) ; if ( currentConnectedDevices . contains ( device ) ) { currentConnectedDevices . remove ( device ) ; } else { removedDevices . add ( device ) ; itConnectedDevices . remove ( ) ; } } connectedDevices . addAll ( currentConnectedDevices ) ; } currentConnectedDevices . forEach ( device -> sendEventToListeners ( new USBStorageEvent ( device , DeviceEventType . CONNECTED ) ) ) ; removedDevices . forEach ( device -> sendEventToListeners ( new USBStorageEvent ( device , DeviceEventType . REMOVED ) ) ) ; }
Updates the internal state of this manager and sends