[Title] Fixed - SDB check first time device connection logic
authorgyeongseok.seo <gyeongseok.seo@samsung.com>
Wed, 12 Jun 2013 06:48:52 +0000 (15:48 +0900)
committergyeongseok.seo <gyeongseok.seo@samsung.com>
Wed, 12 Jun 2013 06:48:52 +0000 (15:48 +0900)
[Desc.]
[Issue]

Change-Id: I628113ea92a96361550743cb3873e4e493768469

org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java
org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java

index e44d608..33664d9 100644 (file)
@@ -61,7 +61,7 @@ extends AbstractServer
     /**
      * Devices to be monitored
      */
-    protected final ArrayList<Device> devices = new ArrayList<Device>();
+    protected ArrayList<Device> devices = null;
 
     private byte[] mLengthBuffer = new byte[4];
 
@@ -109,6 +109,13 @@ extends AbstractServer
     Device[]
     getDevices()
     {
+       while ( null == devices )
+       {
+               try {
+                               this.wait();
+                       } catch (InterruptedException e) {
+                       }
+       }
        return devices.toArray( new Device[devices.size()] );
     }
     
@@ -249,6 +256,10 @@ extends AbstractServer
             // 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 )
             {
                    
@@ -316,7 +327,9 @@ extends AbstractServer
                         Log.d("DeviceMonitor", "updateDevices: " + newDevice.getSerialNumber() + " newly connected.");
                     }
                 }
+                this.notifyAll();
             }
+               
         }
         newList.clear();
     }
index 4ef06b4..02771ce 100644 (file)
@@ -345,13 +345,11 @@ SmartDevelopmentBridge
      * @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];
     }
 
     /**