// we don't want our update to interfere with the normal update process so
// hang around until it completes
PluginInterface pi = azureus_core.getPluginManager().getDefaultPluginInterface();
UpdateManager update_manager = pi.getUpdateManager();
final List<UpdateCheckInstance> l_instances = new ArrayList<UpdateCheckInstance>();
update_manager.addListener(
new UpdateManagerListener()
{
public void
checkInstanceCreated(
UpdateCheckInstance instance )
{
synchronized( l_instances ){
l_instances.add( instance );
}
}
});
UpdateCheckInstance[] instances = update_manager.getCheckInstances();
l_instances.addAll( Arrays.asList( instances ));
long start = SystemTime.getMonotonousTime();
while( true ){
if ( SystemTime.getMonotonousTime() - start >= 5*60*1000 ){
break;
}
try{
Thread.sleep(5000);
}catch( Throwable e ){
Debug.out( e );
return( null );
}
if ( l_instances.size() > 0 ){
boolean all_done = true;
for ( UpdateCheckInstance instance: l_instances ){
if ( !instance.isCompleteOrCancelled()){
all_done = false;
break;
}
}
if ( all_done ){
break;
}
}
}
if ( update_manager.getInstallers().length > 0 ){
return( null );
}
UpdateInstaller installer = pi.getUpdateManager().createInstaller();