/**
* Devices to be monitored
*/
- protected final ArrayList<Device> devices = new ArrayList<Device>();
+ protected ArrayList<Device> devices = null;
private byte[] mLengthBuffer = new byte[4];
Device[]
getDevices()
{
+ while ( null == devices )
+ {
+ try {
+ this.wait();
+ } catch (InterruptedException e) {
+ }
+ }
return devices.toArray( new Device[devices.size()] );
}
// it's important to not do it inside the synchronized loop as this could block
// the whole workspace (this lock is acquired during build too).
final ArrayList<Device> devicesToQuery = new ArrayList<Device>();
+ if (null == this.devices )
+ {
+ this.devices = new ArrayList<Device>();
+ }
synchronized ( this )
{
Log.d("DeviceMonitor", "updateDevices: " + newDevice.getSerialNumber() + " newly connected.");
}
}
+ this.notifyAll();
}
+
}
newList.clear();
}
* @see #hasInitialDeviceList()
*/
public IDevice[] getDevices() {
- synchronized (sLock) {
- if (deviceMonitor != null) {
- return deviceMonitor.getDevices();
- }
- }
+ if (deviceMonitor != null) {
+ return deviceMonitor.getDevices();
+ }
- return new IDevice[0];
+ return new IDevice[0];
}
/**