sdblib

e(location);
      instance.start();
      
      fireBridgetChanged(instance);
      return instance;
    }
  }
  
  public static SmartDevelopmentBridge getBridge()
  {
    return instance;
  }
  
  public String getSdbOsLocation()
  {
    return mSdbOsLocation;
  }
  
  protected static void fireBridgetChanged(SmartDevelopmentBridge instance)
  {
    IDebugBridgeChangeListener[] arrayOfIDebugBridgeChangeListener;
    int j = (arrayOfIDebugBridgeChangeListener = (IDebugBridgeChangeListener[])sBridgeListeners.toArray(new IDebugBridgeChangeListener[0])).length;
    for (int i = 0; i < j; i++)
    {
      IDebugBridgeChangeListener listener = arrayOfIDebugBridgeChangeListener[i];
      try
      {
        listener.bridgeChanged(instance);
      }
      catch (Exception e)
      {
        Log.e("sdblib", e);
      }
    }
  }
  
  public static void disconnectBridge()
  {
    synchronized (sLock)
    {
      if (instance != null)
      {
        instance.stop();
        instance = null;
        
        fireBridgetChanged(null);
      }
    }
  }
  
  public static void addDebugBridgeChangeListener(IDebugBridgeChangeListener listener)
  {
    synchronized (sLock)
    {
      if (!sBridgeListeners.contains(listener))
      {
        sBridgeListeners.add(listener);
        if (instance != null) {
          try
          {
            listener.bridgeChanged(instance);
          }
          catch (Exception e)
          {
            Log.e("sdblib", e);
          }
        }
      }
    }
  }
  
  public static void removeDebugBridgeChangeListener(IDebugBridgeChangeListener listener)
  {
    synchronized (sLock)
    {
      sBridgeListeners.remove(listener);
    }
  }
  
  public static void addDeviceChangeListener(IDeviceChangeListener listener)
  {
    addDeviceChangeListener(listener, false);
  }
  
  public static void addDeviceChangeListener(IDeviceChangeListener listener, boolean bNotification)
  {
    IDevice[] devices = getBridge().getDevices();
    synchronized (sLock)
    {
      if (!sDeviceListeners.contains(listener))
      {
        sDeviceListeners.add(listener);
        if (bNotification)
        {
          IDevice[] arrayOfIDevice1;
          int j = (arrayOfIDevice1 = devices).length;
          for (int i = 0; i < j; i++)
          {
            IDevice device = arrayOfIDevice1[i];
            if (DeviceUtil.isOnline(device)) {
              listener.onConnected(device);
            }
          }
        }
      }
    }
  }
  
  public static void removeDeviceChangeListener(IDeviceChangeListener listener)
  {
    synchronized (sLock)
    {
      sDeviceListeners.remove(listener);
    }
  }
  
  public IDevice[] getDevices()
  {
    if (deviceMonitor != null) {
      return deviceMonitor.getDevices();
    }
    return new IDevice[0];
  }
  
  public boolean isConnected()
  {
    if (deviceMonitor != null) {
      return deviceMonitor.isMonitoring();
    }
    return false;
  }
  
  public int getRestartAttemptCount()
  {
    if (deviceMonitor != null) {
      return deviceMonitor.getRestartAttemptCount();
    }
    return -1;
  }
  
  public boolean isDeviceListInitialized()
  {
    return deviceMonitor != null ? deviceMonitor.isDeviceListInitialized() : false;
  }
  
  private SmartDevelopmentBridge(String osLocation)
    throws InvalidParameterException
  {
    if ((osLocation == null) || (osLocation.length() == 0)) {
      throw new InvalidParameterException();
    }
    mSdbOsLocation = osLocation;
  }
  
  private SmartDevelopmentBridge() {}
  
  boolean start()
  {
    try
    {
      deviceMonitor = new DeviceMonitor(this);
      deviceMonitor.boot();
      
      return true;
    }
    catch (ServerException e)
    {
      e.printStackTrace();
    }
    return false;
  }
  
  boolean stop()
  {
    if (!mStarted) {
      return false;
    }
    int numberDevice = deviceMonitor.getDevices().length;
    
    deviceMonitor.down();
    deviceMonitor = null;
    if ((numberDevice == 0) && 
      (!stopSdb())) {
      return false;
    }
    setStarted(false);
    return true;
  }
  
  public void stopBridge()
  {
    deviceMonitor.down();
    deviceMonitor = null;
    
    stopSdb();
  }
  
  public boolean restart()
  {
    if (mSdbOsLocation == null)
    {
      Log.e("sdb", 
        "Cannot restart sdb when SmartDevelopmentBridge is created without the location of sdb.");
      return false;
    }
    synchronized (this)
    {
      stopSdb();
      
      boolean restart = startSdb();
      if ((restart) && (deviceMonitor == null)) {
        start();
      }
      return restart;
    }
  }
  
  /* Error */
  public IDeviceChangeListener[] getDeviceChangeListeners()
  {
    // Byte code:
    //   0: getstatic 42	org/tizen/sdblib/SmartDevelopmentBridge:sDeviceListeners	Ljava/util/ArrayList;
    //   3: invokevirtual 307	java/util/ArrayList:size	()I
    //   6: anewarray 236	org/tizen/sdblib/IDeviceChangeListener
    //   9: astore_1
    //   10: getstatic 44	org/tizen/sdblib/SmartDevelopmentBridge:sLock	Ljava/lang/Object;
    //   13: dup
    //   14: astore_2
    //   15: monitorenter
    //   16: getstatic 42	org/tizen/sdblib/SmartDevelopmentBridge:sDeviceListeners	Ljava/util/ArrayList;
    //   19: aload_1
    //   20: invokevirtual 187	java/util/ArrayList:toArray	([Ljava/lang/Object;)[Ljava/lang/Object;
    //   23: checkcast 310	[Lorg/tizen/sdblib/IDeviceChangeListener;
    //   26: aload_2
    //   27: monitorexit
    //   28: areturn
    //   29: aload_2
    //   30: monitorexit
    //   31: athrow
    // Line number table:
    //   Java source line #465	-> byte code offset #0
    //   Java source line #466	-> byte code offset #10
    //   Java source line #467	-> byte code offset #16
    //   Java source line #466	-> byte code offset #29
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	32	0	this	SmartDevelopmentBridge
    //   9	11	1	ret	IDeviceChangeListener[]
    //   14	16	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   16	28	29	finally
    //   29	31	29	finally
  }
  
  void deviceConnected(IDevice device)
  {
    IDeviceChangeListener[] arrayOfIDeviceChangeListener;
    int j = (arrayOfIDeviceChangeListener = getDeviceChangeListeners()).length;
    for (int i = 0; i < j; i++)
    {
      IDeviceChangeListener listener = arrayOfIDeviceChangeListener[i];
      try
      {
        listener.onConnected(device);
      }
      catch (Exception e)
      {
        Log.e("sdblib", e);
      }
    }
  }
  
  void deviceDisconnected(IDevice device)
  {
    IDeviceChangeListener[] arrayOfIDeviceChangeListener;
    int j = (arrayOfIDeviceChangeListener = getDeviceChangeListeners()).length;
    for (int i = 0; i < j; i++)
    {
      IDeviceChangeListener listener = arrayOfIDeviceChangeListener[i];
      try
      {
        listener.onDisconnected(device);
      }
      catch (Exception e)
      {
        Log.e("sdblib", e);
      }
    }
  }
  
  void deviceChanged(IDevice device, int changeMask)
  {
    IDeviceChangeListener[] arrayOfIDeviceChangeListener;
    int j = (arrayOfIDeviceChangeListener = getDeviceChangeListeners()).length;
    for (int i = 0; i < j; i++)
    {
      IDeviceChangeListener listener = arrayOfIDeviceChangeListener[i];
      try
      {
        listener.onChanged(device, changeMask);
      }
      catch (Exception e)
      {
        Log.e("sdblib", e);
      }
    }
  }
  
  DeviceMonitor getDeviceMonitor()
  {
    return deviceMonitor;
  }
  
  synchronized boolean startSdb()
  {
    if (mSdbOsLocation == null)
    {
      Log.e("sdb", 
        "Cannot start sdb when SmartDevelopmentBridge is created without the location of sdb.");
      return false;
    }
    try
    {
      String[] command = new String[2];
      command[0] = mSdbOsLocation;
      command[1] = "start-server";
      Log.d("sdblib", 
        String.format("launching '%1$s %2$s' to ensure SDB is running.", new Object[] {
        mSdbOsLocation, command[1] }));
      Process proc = Runtime.getRuntime().exec(command);
      
      String error = grabProcessError(proc);
      if (error != null)
      {
        Log.e("sdblib", "'sdb start-server' failed -- run manually if necessary");
        Log.e("sdblib", "Cause: " + error);
        
        return false;
      }
      Log.d("sdblib", "'sdb start-server' succeeded");
      setStarted(true);
      return true;
    }
    catch (IOException ioe)
    {
      Log.d("sdblib", "unable to run 'sdb': " + ioe.getMessage());
    }
    catch (InterruptedException ie)
    {
      Log.d("sdblib", "unable to run 'sdb': " + ie.getMessage());
    }
    return false;
  }
  
  private synchronized boolean stopSdb()
  {
    if (mSdbOsLocation == null)
    {
      Log.e("sdb", 
        "Cannot stop sdb when SmartDevelopmentBridge is created without the location of sdb.");
      return false;
    }
    int status = -1;
    try
    {
      String[] command = new String[2];
      command[0] = mSdbOsLocation;
      command[1] = "kill-server";
      Process proc = Runtime.getRuntime().exec(command);
      status = proc.waitFor();
      if (status == 0)
      {
        Log.d("sdblib", "'sdb kill-server' succeeded");
        setStarted(false);
        return true;
      }
    }
    catch (IOException ioe)
    {
      Log.e("sdb", "stop sdb failed:" + ioe);
    }
    catch (InterruptedException localInterruptedException) {}
    Log.w("sdblib", 
      "'sdb kill-server' failed -- run manually if necessary");
    return false;
  }
  
  private String grabProcessError(Process process)
    throws InterruptedException
  {
    StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream());
    StreamGobbler inGobbler = new StreamGobbler(process.getInputStream());
    try
    {
      errorGobbler.boot();
      inGobbler.boot();
    }
    catch (ServerException localServerException)
    {
      return "Fail to read from stream";
    }
    int status = process.waitFor();
    String error = errorGobbler.getResult();
    if (StringUtil.isEmpty(error))
    {
      if (status == 0) {
        return null;
      }
      return "The sdb fail to execute start-server";
    }
    return error;
  }
  
  static Object getLock()
  {
    return sLock;
  }
  
  public void waitforStart()
  {
    waitforStart(-1L);
  }
  
  public void waitforStart(long timeout)
  {
    long startTime = System.currentTimeMillis();
    while (!getStarted())
    {
      if ((0L < timeout) && (timeout < System.currentTimeMillis() - startTime)) {
        return;
      }
      synchronized (this)
      {
        try
        {
          wait();
        }
        catch (InterruptedException e)
        {
          e.printStackTrace();
        }
      }
    }
  }
  
  public boolean getStarted()
  {
    lock.lock();
    try
    {
      return mStarted;
    }
    finally
    {
      lock.unlock();
    }
  }
  
  void setStarted(boolean isStarted)
  {
    lock.lock();
    try
    {
      mStarted = isStarted;
      synchronized (this)
      {
        notifyAll();
      }
    }
    finally
    {
      lock.unlock();
    }
    lock.unlock();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.SmartDevelopmentBridge
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib;

public class SmartDevelopmentBridgetConstants
{
  public static final String SERVER_PORT_ENV_VAR = "SDB_SERVER_PORT";
  public static final String SDB_DEFAULT_HOST = "127.0.0.1";
  public static final int SDB_DEFAULT_PORT = 26099;
  public static final byte[] ID_OKAY = "OKAY".getBytes();
  public static final byte[] ID_FAIL = "FAIL".getBytes();
  public static final byte[] ID_RECV = "RECV".getBytes();
  public static final byte[] ID_DATA = "DATA".getBytes();
  public static final byte[] ID_DONE = "DONE".getBytes();
  public static final byte[] ID_SEND = "SEND".getBytes();
  public static final byte[] ID_QUIT = "QUIT".getBytes();
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.SmartDevelopmentBridgetConstants
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

public enum Argument
{
  MaxTimeToRespond;
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.Argument
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

import java.io.IOException;
import java.nio.channels.SocketChannel;
import java.util.HashMap;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.SdbHelper;
import org.tizen.sdblib.SdbResponse;
import org.tizen.sdblib.SmartDevelopmentBridge;
import org.tizen.sdblib.exception.SdbCommandRejectedException;
import org.tizen.sdblib.util.Assert;
import org.tizen.sdblib.util.Log;

public class Command
  implements ICommand, ICommandWithArgument, ICommandWithArgument2
{
  protected final SmartDevelopmentBridge sdb;
  protected final String cmd;
  protected final HashMap<Argument, Object> arguments = new HashMap();
  
  public Command(SmartDevelopmentBridge sdb, String cmd)
  {
    Assert.notNull(sdb);
    Assert.notNull(cmd);
    
    this.sdb = sdb;
    this.cmd = cmd;
  }
  
  /* Error */
  public void in(IDevice device, org.tizen.sdblib.IShellOutputReceiver receiver)
    throws IOException
  {
    // Byte code:
    //   0: aload_2
    //   1: invokestatic 30	org/tizen/sdblib/util/Assert:notNull	(Ljava/lang/Object;)V
    //   4: aload_0
    //   5: getfield 36	org/tizen/sdblib/command/Command:sdb	Lorg/tizen/sdblib/SmartDevelopmentBridge;
    //   8: invokevirtual 49	org/tizen/sdblib/SmartDevelopmentBridge:openChannel	()Ljava/nio/channels/SocketChannel;
    //   11: astore_3
    //   12: aload_3
    //   13: aload_0
    //   14: invokevirtual 55	org/tizen/sdblib/command/Command:getMaxTimeToRespond	()I
    //   17: ifgt +7 -> 24
    //   20: iconst_1
    //   21: goto +4 -> 25
    //   24: iconst_0
    //   25: invokevirtual 59	java/nio/channels/SocketChannel:configureBlocking	(Z)Ljava/nio/channels/SelectableChannel;
    //   28: pop
    //   29: aload_0
    //   30: aload_1
    //   31: aload_3
    //   32: invokevirtual 65	org/tizen/sdblib/command/Command:sendRequest	(Lorg/tizen/sdblib/IDevice;Ljava/nio/channels/SocketChannel;)V
    //   35: sipush 16384
    //   38: newarray <illegal type>
    //   40: astore 4
    //   42: aload 4
    //   44: invokestatic 69	java/nio/ByteBuffer:wrap	([B)Ljava/nio/ByteBuffer;
    //   47: astore 5
    //   49: iconst_0
    //   50: istore 6
    //   52: new 75	java/io/ByteArrayOutputStream
    //   55: dup
    //   56: invokespecial 77	java/io/ByteArrayOutputStream:<init>	()V
    //   59: astore 7
    //   61: aload_2
    //   62: ifnull +22 -> 84
    //   65: aload_2
    //   66: invokeinterface 78 1 0
    //   71: ifeq +13 -> 84
    //   74: ldc 84
    //   76: ldc 85
    //   78: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   81: goto +223 -> 304
    //   84: aload_3
    //   85: aload 5
    //   87: invokevirtual 93	java/nio/channels/SocketChannel:read	(Ljava/nio/ByteBuffer;)I
    //   90: istore 8
    //   92: iload 8
    //   94: ifge +55 -> 149
    //   97: aload_2
    //   98: invokeinterface 97 1 0
    //   103: ldc 84
    //   105: new 100	java/lang/StringBuilder
    //   108: dup
    //   109: ldc 102
    //   111: invokespecial 104	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   114: aload_0
    //   115: getfield 38	org/tizen/sdblib/command/Command:cmd	Ljava/lang/String;
    //   118: invokevirtual 107	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   121: ldc 111
    //   123: invokevirtual 107	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   126: aload_1
    //   127: invokevirtual 113	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   130: ldc 116
    //   132: invokevirtual 107	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   135: iload 8
    //   137: invokevirtual 118	java/lang/StringBuilder:append	(I)Ljava/lang/StringBuilder;
    //   140: invokevirtual 121	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   143: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   146: goto +158 -> 304
    //   149: iload 8
    //   151: ifne +54 -> 205
    //   154: sipush 250
    //   157: istore 9
    //   159: iload 6
    //   161: iload 9
    //   163: iadd
    //   164: istore 6
    //   166: aload_0
    //   167: invokevirtual 55	org/tizen/sdblib/command/Command:getMaxTimeToRespond	()I
    //   170: istore 10
    //   172: iload 10
    //   174: ifle +18 -> 192
    //   177: iload 6
    //   179: iload 10
    //   181: if_icmple +11 -> 192
    //   184: new 125	org/tizen/sdblib/exception/ShellCommandUnresponsiveException
    //   187: dup
    //   188: invokespecial 127	org/tizen/sdblib/exception/ShellCommandUnresponsiveException:<init>	()V
    //   191: athrow
    //   192: iload 9
    //   194: i2l
    //   195: invokestatic 128	java/lang/Thread:sleep	(J)V
    //   198: goto -137 -> 61
    //   201: pop
    //   202: goto -141 -> 61
    //   205: iconst_0
    //   206: istore 6
    //   208: aload_2
    //   209: ifnull +66 -> 275
    //   212: aload 7
    //   214: aload 5
    //   216: invokevirtual 134	java/nio/ByteBuffer:array	()[B
    //   219: aload 5
    //   221: invokevirtual 138	java/nio/ByteBuffer:arrayOffset	()I
    //   224: aload 5
    //   226: invokevirtual 141	java/nio/ByteBuffer:position	()I
    //   229: invokevirtual 144	java/io/ByteArrayOutputStream:write	([BII)V
    //   232: aload_2
    //   233: aload 7
    //   235: invokevirtual 148	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   238: invokestatic 151	org/tizen/sdblib/SdbHelper:bytes2string	([B)Ljava/lang/String;
    //   241: invokeinterface 157 2 0
    //   246: pop
    //   247: goto +23 -> 270
    //   250: pop
    //   251: aload_2
    //   252: new 160	java/lang/String
    //   255: dup
    //   256: aload 7
    //   258: invokevirtual 148	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   261: invokespecial 162	java/lang/String:<init>	([B)V
    //   264: invokeinterface 157 2 0
    //   269: pop
    //   270: aload 7
    //   272: invokevirtual 165	java/io/ByteArrayOutputStream:reset	()V
    //   275: aload 5
    //   277: invokevirtual 168	java/nio/ByteBuffer:rewind	()Ljava/nio/Buffer;
    //   280: pop
    //   281: goto -220 -> 61
    //   284: astore 11
    //   286: aload_3
    //   287: invokestatic 172	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   290: aload_2
    //   291: invokestatic 172	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   294: ldc 84
    //   296: ldc -78
    //   298: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   301: aload 11
    //   303: athrow
    //   304: aload_3
    //   305: invokestatic 172	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   308: aload_2
    //   309: invokestatic 172	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   312: ldc 84
    //   314: ldc -78
    //   316: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   319: return
    // Line number table:
    //   Java source line #104	-> byte code offset #0
    //   Java source line #106	-> byte code offset #4
    //   Java source line #107	-> byte code offset #12
    //   Java source line #110	-> byte code offset #29
    //   Java source line #112	-> byte code offset #35
    //   Java source line #113	-> byte code offset #42
    //   Java source line #114	-> byte code offset #49
    //   Java source line #115	-> byte code offset #52
    //   Java source line #118	-> byte code offset #61
    //   Java source line #119	-> byte code offset #74
    //   Java source line #120	-> byte code offset #81
    //   Java source line #123	-> byte code offset #84
    //   Java source line #124	-> byte code offset #92
    //   Java source line #126	-> byte code offset #97
    //   Java source line #127	-> byte code offset #103
    //   Java source line #128	-> byte code offset #135
    //   Java source line #127	-> byte code offset #143
    //   Java source line #129	-> byte code offset #146
    //   Java source line #130	-> byte code offset #149
    //   Java source line #132	-> byte code offset #154
    //   Java source line #133	-> byte code offset #159
    //   Java source line #134	-> byte code offset #166
    //   Java source line #135	-> byte code offset #172
    //   Java source line #136	-> byte code offset #177
    //   Java source line #137	-> byte code offset #184
    //   Java source line #139	-> byte code offset #192
    //   Java source line #140	-> byte code offset #201
    //   Java source line #144	-> byte code offset #205
    //   Java source line #147	-> byte code offset #208
    //   Java source line #148	-> byte code offset #212
    //   Java source line #151	-> byte code offset #232
    //   Java source line #152	-> byte code offset #250
    //   Java source line #154	-> byte code offset #251
    //   Java source line #156	-> byte code offset #270
    //   Java source line #158	-> byte code offset #275
    //   Java source line #116	-> byte code offset #281
    //   Java source line #163	-> byte code offset #284
    //   Java source line #164	-> byte code offset #286
    //   Java source line #165	-> byte code offset #290
    //   Java source line #166	-> byte code offset #294
    //   Java source line #167	-> byte code offset #301
    //   Java source line #164	-> byte code offset #304
    //   Java source line #165	-> byte code offset #308
    //   Java source line #166	-> byte code offset #312
    //   Java source line #168	-> byte code offset #319
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	320	0	this	Command
    //   0	320	1	device	IDevice
    //   0	320	2	receiver	org.tizen.sdblib.IShellOutputReceiver
    //   11	294	3	channel	SocketChannel
    //   40	3	4	data	byte[]
    //   47	229	5	buf	java.nio.ByteBuffer
    //   50	157	6	timeToResponseCount	int
    //   59	212	7	byteOut	java.io.ByteArrayOutputStream
    //   90	60	8	count	int
    //   157	36	9	wait	int
    //   170	10	10	maxTimeToRespond	int
    //   284	18	11	localObject	Object
    //   201	1	12	localInterruptedException	InterruptedException
    //   250	1	13	localException	Exception
    // Exception table:
    //   from	to	target	type
    //   154	198	201	java/lang/InterruptedException
    //   232	247	250	java/lang/Exception
    //   29	284	284	finally
  }
  
  /* Error */
  public void in(IDevice device)
    throws IOException
  {
    // Byte code:
    //   0: ldc 84
    //   2: new 100	java/lang/StringBuilder
    //   5: dup
    //   6: ldc -48
    //   8: invokespecial 104	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   11: aload_0
    //   12: getfield 38	org/tizen/sdblib/command/Command:cmd	Ljava/lang/String;
    //   15: invokevirtual 107	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   18: invokevirtual 121	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   21: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   24: aload_0
    //   25: getfield 36	org/tizen/sdblib/command/Command:sdb	Lorg/tizen/sdblib/SmartDevelopmentBridge;
    //   28: invokevirtual 49	org/tizen/sdblib/SmartDevelopmentBridge:openChannel	()Ljava/nio/channels/SocketChannel;
    //   31: astore_2
    //   32: aload_0
    //   33: aload_1
    //   34: aload_2
    //   35: invokevirtual 65	org/tizen/sdblib/command/Command:sendRequest	(Lorg/tizen/sdblib/IDevice;Ljava/nio/channels/SocketChannel;)V
    //   38: goto +17 -> 55
    //   41: astore_3
    //   42: aload_2
    //   43: invokestatic 172	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   46: ldc 84
    //   48: ldc -78
    //   50: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   53: aload_3
    //   54: athrow
    //   55: aload_2
    //   56: invokestatic 172	org/tizen/sdblib/util/IOUtil:tryClose	(Ljava/io/Closeable;)V
    //   59: ldc 84
    //   61: ldc -78
    //   63: invokestatic 87	org/tizen/sdblib/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)V
    //   66: return
    // Line number table:
    //   Java source line #181	-> byte code offset #0
    //   Java source line #183	-> byte code offset #24
    //   Java source line #186	-> byte code offset #32
    //   Java source line #189	-> byte code offset #41
    //   Java source line #190	-> byte code offset #42
    //   Java source line #191	-> byte code offset #46
    //   Java source line #192	-> byte code offset #53
    //   Java source line #190	-> byte code offset #55
    //   Java source line #191	-> byte code offset #59
    //   Java source line #193	-> byte code offset #66
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	67	0	this	Command
    //   0	67	1	device	IDevice
    //   31	25	2	channel	SocketChannel
    //   41	13	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   32	41	41	finally
  }
  
  protected void sendRequest(IDevice device, SocketChannel channel)
    throws IOException
  {
    SdbHelper.initializeDevice(channel, device.getSerialNumber());
    
    byte[] request = SdbHelper.formSdbRequest("shell:" + cmd);
    SdbHelper.write(channel, request);
    
    SdbResponse resp = SdbHelper.readSdbResponse(channel);
    if (!okay)
    {
      Log.e("sdb", "sdb rejected shell command (" + cmd + "): " + message);
      throw new SdbCommandRejectedException(message);
    }
  }
  
  public ICommandWithArgument2 and(Argument key, Object value)
  {
    return with(key, value);
  }
  
  public ICommandWithArgument2 with(Argument key, Object value)
  {
    Assert.notNull(key);
    Assert.isFalse(arguments.containsKey(key));
    
    arguments.put(key, value);
    return this;
  }
  
  protected int getMaxTimeToRespond()
  {
    Object obj = arguments.get(Argument.MaxTimeToRespond);
    if (!(obj instanceof Integer)) {
      return -1;
    }
    return ((Integer)obj).intValue();
  }
  
  public <T> T in(IDevice device, Matcher<T> matcher)
  {
    try
    {
      in(device, matcher);
    }
    catch (IOException e)
    {
      Log.e("command", "execute " + cmd + " failed:" + e);
    }
    return (T)matcher.getResult();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.Command
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

import org.tizen.sdblib.SmartDevelopmentBridge;

public class CommandFactory
{
  public static ICommandWithArgument execute(String cmd)
  {
    return new Command(SmartDevelopmentBridge.getBridge(), cmd);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.CommandFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

import java.io.IOException;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.IShellOutputReceiver;

public abstract interface ICommand
{
  public abstract void in(IDevice paramIDevice)
    throws IOException;
  
  public abstract void in(IDevice paramIDevice, IShellOutputReceiver paramIShellOutputReceiver)
    throws IOException;
  
  public abstract <T> T in(IDevice paramIDevice, Matcher<T> paramMatcher);
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.ICommand
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

public abstract interface ICommandWithArgument
  extends ICommand
{
  public abstract ICommandWithArgument2 with(Argument paramArgument, Object paramObject);
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.ICommandWithArgument
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

public abstract interface ICommandWithArgument2
  extends ICommand
{
  public abstract ICommandWithArgument2 and(Argument paramArgument, Object paramObject);
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.ICommandWithArgument2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

import org.tizen.sdblib.IShellOutputReceiver;

public abstract interface Matcher<T>
  extends IShellOutputReceiver
{
  public abstract T getResult();
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.Matcher
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

import java.util.Arrays;
import java.util.Collection;
import org.tizen.sdblib.command.matcher.Contains;
import org.tizen.sdblib.command.matcher.Equals;
import org.tizen.sdblib.command.matcher.InverseMatcher;
import org.tizen.sdblib.command.matcher.MultiMatcher;

public class MatcherFactory
{
  public static Matcher<Boolean> equals(String word)
  {
    return new Equals(word);
  }
  
  public static Matcher<Boolean> equalsIgnoreCase(String word)
  {
    return new Equals(word, true);
  }
  
  public static Matcher<Boolean> contains(String result)
  {
    return new Contains(result);
  }
  
  public static Matcher<Boolean> containsIgnoreCase(String result)
  {
    return new Contains(result, true);
  }
  
  public static Matcher<Boolean> not(Matcher<Boolean> receiver)
  {
    return new InverseMatcher(receiver);
  }
  
  public static Matcher<Matcher<?>> matchers(Matcher<?>... matchers)
  {
    return matchers(Arrays.asList(matchers));
  }
  
  public static Matcher<Matcher<?>> matchers(Collection<Matcher<?>> matchers)
  {
    return new MultiMatcher(matchers);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.MatcherFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command;

import java.util.regex.Pattern;
import org.tizen.sdblib.receiver.MultiLineReceiver;

public class PatternExtractor
  extends MultiLineReceiver
  implements Matcher<String>
{
  protected final Pattern pattern;
  protected final String replacement;
  protected String result;
  
  public PatternExtractor(String regexp)
  {
    this(regexp, "$1");
  }
  
  public PatternExtractor(String regexp, String replacement)
  {
    this(Pattern.compile(regexp), replacement);
  }
  
  public PatternExtractor(Pattern pattern, String replacement)
  {
    this.pattern = pattern;
    this.replacement = replacement;
  }
  
  public void processNewLines(String[] lines)
  {
    String[] arrayOfString;
    int j = (arrayOfString = lines).length;
    for (int i = 0; i < j; i++)
    {
      String line = arrayOfString[i];
      
      java.util.regex.Matcher matcher = pattern.matcher(line);
      if (matcher.find())
      {
        result = matcher.replaceAll(replacement);
        return;
      }
    }
  }
  
  public String getResult()
  {
    return result;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.PatternExtractor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command.matcher;

public class Contains
  extends KeywordBasedMatcher
{
  public Contains(String keyword)
  {
    this(keyword, false);
  }
  
  public Contains(String keyword, boolean bIgnoreCase)
  {
    super(keyword, bIgnoreCase);
  }
  
  public boolean processNewLine(String line)
  {
    if (line == null) {
      return false;
    }
    return bIgnoreCase ? line.toLowerCase().contains(keyword.toLowerCase()) : line.contains(keyword);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.matcher.Contains
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command.matcher;

public class Equals
  extends KeywordBasedMatcher
{
  public Equals(String keyword)
  {
    this(keyword, false);
  }
  
  public Equals(String keyword, boolean bIgnoreCase)
  {
    super(keyword, bIgnoreCase);
  }
  
  public boolean processNewLine(String line)
  {
    if (line == null) {
      return false;
    }
    return bIgnoreCase ? line.equalsIgnoreCase(keyword) : line.equals(keyword);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.matcher.Equals
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command.matcher;

import java.io.IOException;
import org.tizen.sdblib.command.Matcher;
import org.tizen.sdblib.receiver.AbstractShellOutputReceiver;

public class InverseMatcher
  extends AbstractShellOutputReceiver
  implements Matcher<Boolean>
{
  protected final Matcher<Boolean> matcher;
  
  public InverseMatcher(Matcher<Boolean> matcher)
  {
    this.matcher = matcher;
  }
  
  public Boolean getResult()
  {
    return Boolean.valueOf(!((Boolean)matcher.getResult()).booleanValue());
  }
  
  public Appendable append(char c)
    throws IOException
  {
    return matcher.append(c);
  }
  
  public boolean isCancelled()
  {
    return matcher.isCancelled();
  }
  
  public void flush()
    throws IOException
  {
    matcher.flush();
  }
  
  public void close()
    throws IOException
  {
    matcher.close();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.matcher.InverseMatcher
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command.matcher;

import org.tizen.sdblib.command.Matcher;
import org.tizen.sdblib.receiver.MultiLineReceiver;

public abstract class KeywordBasedMatcher
  extends MultiLineReceiver
  implements Matcher<Boolean>
{
  protected final String keyword;
  protected final boolean bIgnoreCase;
  protected boolean bMatch = false;
  
  public KeywordBasedMatcher(String keyword, boolean bIgnoreCase)
  {
    this.keyword = keyword;
    this.bIgnoreCase = bIgnoreCase;
  }
  
  public Boolean getResult()
  {
    return Boolean.valueOf(bMatch);
  }
  
  public void processNewLines(String[] lines)
  {
    String[] arrayOfString;
    int j = (arrayOfString = lines).length;
    for (int i = 0; i < j; i++)
    {
      String line = arrayOfString[i];
      if (processNewLine(line))
      {
        bMatch = true;
        break;
      }
    }
  }
  
  protected abstract boolean processNewLine(String paramString);
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.matcher.KeywordBasedMatcher
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.command.matcher;

import java.io.IOException;
import java.util.Collection;
import org.tizen.sdblib.command.Matcher;
import org.tizen.sdblib.receiver.AbstractShellOutputReceiver;

public class MultiMatcher
  extends AbstractShellOutputReceiver
  implements Matcher<Matcher<?>>
{
  protected final Collection<Matcher<?>> matchers;
  
  public MultiMatcher(Collection<?> matchers)
  {
    this.matchers = matchers;
  }
  
  public Matcher<?> getResult()
  {
    for (Matcher<?> matcher : matchers)
    {
      Object obj = matcher.getResult();
      if (obj != null) {
        if (!Boolean.FALSE.equals(obj)) {
          return matcher;
        }
      }
    }
    return null;
  }
  
  public Appendable append(char c)
    throws IOException
  {
    for (Matcher<?> matcher : matchers) {
      matcher.append(c);
    }
    return this;
  }
  
  public void flush()
    throws IOException
  {
    for (Matcher<?> matcher : matchers) {
      matcher.flush();
    }
  }
  
  public void close()
    throws IOException
  {
    for (Matcher<?> matcher : matchers) {
      matcher.close();
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.command.matcher.MultiMatcher
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.daemon;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.tizen.sdblib.exception.ServerException;

public abstract class AbstractServer
  implements Server, Runnable
{
  protected Thread thread = null;
  protected Lock lock = new ReentrantLock();
  protected ServerState state = ServerState.Terminated;
  protected final String name;
  
  public AbstractServer()
  {
    this(null);
  }
  
  public AbstractServer(String name)
  {
    this.name = name;
  }
  
  public String getName()
  {
    return name;
  }
  
  public ServerState getStatus()
  {
    lock.lock();
    try
    {
      return state;
    }
    finally
    {
      lock.unlock();
    }
  }
  
  /* Error */
  protected void setStatus(ServerState state)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 34	org/tizen/sdblib/daemon/AbstractServer:lock	Ljava/util/concurrent/locks/Lock;
    //   4: invokeinterface 49 1 0
    //   9: aload_0
    //   10: aload_1
    //   11: putfield 41	org/tizen/sdblib/daemon/AbstractServer:state	Lorg/tizen/sdblib/daemon/ServerState;
    //   14: goto +31 -> 45
    //   17: astore_2
    //   18: aload_0
    //   19: getfield 34	org/tizen/sdblib/daemon/AbstractServer:lock	Ljava/util/concurrent/locks/Lock;
    //   22: invokeinterface 53 1 0
    //   27: aload_0
    //   28: dup
    //   29: astore_3
    //   30: monitorenter
    //   31: aload_0
    //   32: invokevirtual 61	java/lang/Object:notifyAll	()V
    //   35: aload_3
    //   36: monitorexit
    //   37: goto +6 -> 43
    //   40: aload_3
    //   41: monitorexit
    //   42: athrow
    //   43: aload_2
    //   44: athrow
    //   45: aload_0
    //   46: getfield 34	org/tizen/sdblib/daemon/AbstractServer:lock	Ljava/util/concurrent/locks/Lock;
    //   49: invokeinterface 53 1 0
    //   54: aload_0
    //   55: dup
    //   56: astore_3
    //   57: monitorenter
    //   58: aload_0
    //   59: invokevirtual 61	java/lang/Object:notifyAll	()V
    //   62: aload_3
    //   63: monitorexit
    //   64: goto +6 -> 70
    //   67: aload_3
    //   68: monitorexit
    //   69: athrow
    //   70: return
    // Line number table:
    //   Java source line #138	-> byte code offset #0
    //   Java source line #141	-> byte code offset #9
    //   Java source line #144	-> byte code offset #17
    //   Java source line #145	-> byte code offset #18
    //   Java source line #146	-> byte code offset #27
    //   Java source line #148	-> byte code offset #31
    //   Java source line #146	-> byte code offset #35
    //   Java source line #150	-> byte code offset #43
    //   Java source line #145	-> byte code offset #45
    //   Java source line #146	-> byte code offset #54
    //   Java source line #148	-> byte code offset #58
    //   Java source line #146	-> byte code offset #62
    //   Java source line #151	-> byte code offset #70
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	71	0	this	AbstractServer
    //   0	71	1	state	ServerState
    //   17	27	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   9	17	17	finally
    //   31	37	40	finally
    //   40	42	40	finally
    //   58	64	67	finally
    //   67	69	67	finally
  }
  
  public boolean isState(ServerState... states)
  {
    lock.lock();
    try
    {
      ServerState[] arrayOfServerState;
      int j = (arrayOfServerState = states).length;
      for (int i = 0; i < j; i++)
      {
        ServerState state = arrayOfServerState[i];
        if (this.state.equals(state)) {
          return true;
        }
      }
      return false;
    }
    finally
    {
      lock.unlock();
    }
  }
  
  public void waitState(ServerState... states)
  {
    while (!isState(states)) {
      try
      {
        synchronized (this)
        {
          wait();
        }
      }
      catch (InterruptedException localInterruptedException) {}
    }
  }
  
  /* Error */
  public void run()
  {
    // Byte code:
    //   0: aload_0
    //   1: iconst_1
    //   2: anewarray 37	org/tizen/sdblib/daemon/ServerState
    //   5: dup
    //   6: iconst_0
    //   7: getstatic 83	org/tizen/sdblib/daemon/ServerState:Halting	Lorg/tizen/sdblib/daemon/ServerState;
    //   10: aastore
    //   1
1 2 3 4 5 6 7

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd