com.android.ide.eclipse.ddms_23.0.2.1259578

16:34:13.062 INFO  jd.cli.Main - Decompiling com.android.ide.eclipse.ddms_23.0.2.1259578.jar
package com.android.ide.eclipse.ddms;

public abstract interface ITraceviewLauncher
{
  public abstract boolean openFile(String paramString);
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.ITraceviewLauncher
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms;

import com.android.ddmlib.IDevice;
import com.android.ddmlib.logcat.LogCatMessage;
import com.android.ddmuilib.logcat.ILogCatBufferChangeListener;
import java.util.List;

class LogCatMonitor$3
  implements ILogCatBufferChangeListener
{
  LogCatMonitor$3(LogCatMonitor paramLogCatMonitor, IDevice paramIDevice) {}
  
  public void bufferChanged(List<LogCatMessage> addedMessages, List<LogCatMessage> deletedMessages)
  {
    LogCatMonitor.access$4(this$0, addedMessages, val$device);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.LogCatMonitor.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms;

import org.eclipse.ui.console.MessageConsoleStream;

class DdmsPlugin$1
  implements Runnable
{
  DdmsPlugin$1(DdmsPlugin paramDdmsPlugin, MessageConsoleStream paramMessageConsoleStream) {}
  
  public void run()
  {
    val$errorConsoleStream.setColor(DdmsPlugin.access$0(this$0));
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.DdmsPlugin.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms;

import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.logcat.LogCatMessage;
import com.android.ddmuilib.logcat.ILogCatBufferChangeListener;
import com.android.ddmuilib.logcat.LogCatReceiver;
import com.android.ddmuilib.logcat.LogCatReceiverFactory;
import com.android.ide.eclipse.ddms.views.LogCatView;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

public class LogCatMonitor
{
  public static final String AUTO_MONITOR_PREFKEY = "ddms.logcat.automonitor";
  public static final String AUTO_MONITOR_LOGLEVEL = "ddms.logcat.auotmonitor.level";
  private static final String AUTO_MONITOR_PROMPT_SHOWN = "ddms.logcat.automonitor.userprompt";
  private IPreferenceStore mPrefStore;
  private Map<String, DeviceData> mMonitoredDevices;
  private IDebuggerConnector[] mConnectors;
  private int mMinMessagePriority;
  final AtomicBoolean mMonitorEnabled = new AtomicBoolean(false);
  
  public LogCatMonitor(IDebuggerConnector[] debuggerConnectors, IPreferenceStore prefStore)
  {
    mConnectors = debuggerConnectors;
    mPrefStore = prefStore;
    mMinMessagePriority = 
      Log.LogLevel.getByString(mPrefStore.getString("ddms.logcat.auotmonitor.level")).getPriority();
    
    mMonitoredDevices = new HashMap();
    
    AndroidDebugBridge.addDeviceChangeListener(new AndroidDebugBridge.IDeviceChangeListener()
    {
      public void deviceDisconnected(IDevice device)
      {
        LogCatMonitor.this.unmonitorDevice(device.getSerialNumber());
        mMonitoredDevices.remove(device.getSerialNumber());
      }
      
      public void deviceConnected(IDevice device) {}
      
      public void deviceChanged(IDevice device, int changeMask) {}
    });
    mPrefStore.addPropertyChangeListener(new IPropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent event)
      {
        if (("ddms.logcat.automonitor".equals(event.getProperty())) && 
          (event.getNewValue().equals(Boolean.valueOf(false)))) {
          LogCatMonitor.this.unmonitorAllDevices();
        } else if ("ddms.logcat.auotmonitor.level".equals(event.getProperty())) {
          mMinMessagePriority = 
            Log.LogLevel.getByString((String)event.getNewValue()).getPriority();
        }
      }
    });
  }
  
  private void unmonitorAllDevices()
  {
    for (String device : mMonitoredDevices.keySet()) {
      unmonitorDevice(device);
    }
    mMonitoredDevices.clear();
  }
  
  private void unmonitorDevice(String deviceSerial)
  {
    DeviceData data = (DeviceData)mMonitoredDevices.get(deviceSerial);
    if (data == null) {
      return;
    }
    receiver.removeMessageReceivedEventListener(bufferChangeListener);
  }
  
  public void monitorDevice(final IDevice device)
  {
    if (!mPrefStore.getBoolean("ddms.logcat.automonitor")) {
      return;
    }
    mMonitorEnabled.set(true);
    if (mMonitoredDevices.keySet().contains(device.getSerialNumber())) {
      return;
    }
    LogCatReceiver r = LogCatReceiverFactory.INSTANCE.newReceiver(device, mPrefStore);
    ILogCatBufferChangeListener l = new ILogCatBufferChangeListener()
    {
      public void bufferChanged(List<LogCatMessage> addedMessages, List<LogCatMessage> deletedMessages)
      {
        LogCatMonitor.this.checkMessages(addedMessages, device);
      }
    };
    r.addMessageReceivedEventListener(l);
    
    mMonitoredDevices.put(device.getSerialNumber(), new DeviceData(r, l));
  }
  
  private void checkMessages(List<LogCatMessage> receivedMessages, IDevice device)
  {
    if (!mMonitorEnabled.get()) {
      return;
    }
    for (LogCatMessage m : receivedMessages) {
      if (isImportantMessage(m))
      {
        focusLogCatView(device, m.getAppName());
        
        mMonitorEnabled.set(false);
        break;
      }
    }
  }
  
  private boolean isImportantMessage(LogCatMessage m)
  {
    if (m.getLogLevel().getPriority() < mMinMessagePriority) {
      return false;
    }
    String app = m.getAppName();
    IDebuggerConnector[] arrayOfIDebuggerConnector;
    int j = (arrayOfIDebuggerConnector = mConnectors).length;
    for (int i = 0; i < j; i++)
    {
      IDebuggerConnector c = arrayOfIDebuggerConnector[i];
      if (c.isWorkspaceApp(app)) {
        return true;
      }
    }
    return false;
  }
  
  private void focusLogCatView(final IDevice device, final String appName)
  {
    Display.getDefault().asyncExec(new Runnable()
    {
      public void run()
      {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
          return;
        }
        IWorkbenchPage page = window.getActivePage();
        if (page == null) {
          return;
        }
        if (!isLogCatViewVisible(page))
        {
          boolean showLogCatView = promptUserOnce(page.getWorkbenchWindow().getShell());
          if (!showLogCatView) {
            return;
          }
        }
        LogCatView v = displayLogCatView(page);
        if (v == null) {
          return;
        }
        v.selectionChanged(device);
        
        v.selectTransientAppFilter(appName);
      }
      
      private boolean isLogCatViewVisible(IWorkbenchPage page)
      {
        IViewPart view = page.findView("com.android.ide.eclipse.ddms.views.LogCatView");
        return (view != null) && (page.isPartVisible(view));
      }
      
      private LogCatView displayLogCatView(IWorkbenchPage page)
      {
        IViewPart view = page.findView("com.android.ide.eclipse.ddms.views.LogCatView");
        if (view != null)
        {
          page.bringToTop(view);
          if ((view instanceof LogCatView)) {
            return (LogCatView)view;
          }
        }
        try
        {
          return (LogCatView)page.showView("com.android.ide.eclipse.ddms.views.LogCatView");
        }
        catch (PartInitException localPartInitException) {}
        return null;
      }
      
      private boolean promptUserOnce(Shell shell)
      {
        boolean promptShown = mPrefStore.getBoolean("ddms.logcat.automonitor.userprompt");
        if (promptShown) {
          return mPrefStore.getBoolean("ddms.logcat.automonitor");
        }
        LogCatMonitorDialog dlg = new LogCatMonitorDialog(shell);
        int r = dlg.open();
        
        mPrefStore.setValue("ddms.logcat.automonitor.userprompt", true);
        mPrefStore.setValue("ddms.logcat.automonitor", dlg.shouldMonitor());
        mPrefStore.setValue("ddms.logcat.auotmonitor.level", dlg.getMinimumPriority());
        
        return (r == 0) && (dlg.shouldMonitor());
      }
    });
  }
  
  private static class DeviceData
  {
    public final LogCatReceiver receiver;
    public final ILogCatBufferChangeListener bufferChangeListener;
    
    public DeviceData(LogCatReceiver r, ILogCatBufferChangeListener l)
    {
      receiver = r;
      bufferChangeListener = l;
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.LogCatMonitor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms;

import com.android.ddmuilib.actions.ICommonAction;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;

public class CommonAction
  extends Action
  implements ICommonAction
{
  private Runnable mRunnable;
  
  public CommonAction() {}
  
  public CommonAction(String text)
  {
    super(text);
  }
  
  public CommonAction(String text, ImageDescriptor image)
  {
    super(text, image);
  }
  
  public CommonAction(String text, int style)
  {
    super(text, style);
  }
  
  public void run()
  {
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
  
  public void setRunnable(Runnable runnable)
  {
    mRunnable = runnable;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.CommonAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;

public class JavaSourceRevealer
{
  private static final String SOURCE_REVEALER_EXTENSION_ID = "com.android.ide.eclipse.ddms.sourceRevealer";
  private static List<ISourceRevealer> sSourceRevealers = ;
  
  private static List<ISourceRevealer> instantiateSourceRevealers()
  {
    IConfigurationElement[] configElements = 
      DdmsPlugin.getDefault().findConfigElements("com.android.ide.eclipse.ddms.sourceRevealer");
    
    List<ISourceRevealer> providers = new ArrayList();
    
    IConfigurationElement[] arrayOfIConfigurationElement1 = configElements;int j = configElements.length;
    for (int i = 0; i < j; i++)
    {
      IConfigurationElement configElement = arrayOfIConfigurationElement1[i];
      
      Object obj = null;
      try
      {
        obj = configElement.createExecutableExtension("class");
      }
      catch (CoreException localCoreException) {}
      if ((obj instanceof ISourceRevealer)) {
        providers.add((ISourceRevealer)obj);
      }
    }
    return providers;
  }
  
  public static boolean reveal(String applicationName, String className, int line)
  {
    for (ISourceRevealer revealer : sSourceRevealers) {
      try
      {
        if (revealer.reveal(applicationName, className, line)) {
          return true;
        }
      }
      catch (Throwable localThrowable) {}
    }
    return false;
  }
  
  public static boolean revealMethod(String fqmn, String fileName, int linenumber, String perspective)
  {
    for (ISourceRevealer revealer : sSourceRevealers) {
      try
      {
        if (revealer.revealMethod(fqmn, fileName, linenumber, perspective)) {
          return true;
        }
      }
      catch (Throwable localThrowable) {}
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.JavaSourceRevealer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms;

import com.android.ddmlib.Client;
import org.eclipse.jface.action.Action;

public abstract interface IClientAction
{
  public abstract Action getAction();
  
  public abstract void selectedClientChanged(Client paramClient);
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.IClientAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

class SystraceOptionsDialogV1$SystraceOptions
  implements ISystraceOptions
{
  private static final int TAG_GFX = 2;
  private static final int TAG_INPUT = 4;
  private static final int TAG_VIEW = 8;
  private static final int TAG_WEBVIEW = 16;
  private static final int TAG_WM = 32;
  private static final int TAG_AM = 64;
  private static final int TAG_SYNC = 128;
  private static final int TAG_AUDIO = 256;
  private static final int TAG_VIDEO = 512;
  private static final int TAG_CAMERA = 1024;
  private int mTraceBufferSize;
  private int mTraceDuration;
  private boolean mTraceCpuFreq;
  private boolean mTraceCpuIdle;
  private boolean mTraceCpuLoad;
  private boolean mTraceDiskIo;
  private boolean mTraceKernelWorkqueues;
  private boolean mTraceCpuScheduler;
  private int mTag;
  
  private SystraceOptionsDialogV1$SystraceOptions(SystraceOptionsDialogV1 paramSystraceOptionsDialogV1) {}
  
  private void enableTag(int tag)
  {
    mTag |= tag;
  }
  
  public String getTags()
  {
    return "0x" + Integer.toHexString(mTag);
  }
  
  public String getOptions()
  {
    StringBuilder sb = new StringBuilder(20);
    if (mTraceCpuFreq) {
      sb.append("-f ");
    }
    if (mTraceCpuIdle) {
      sb.append("-i ");
    }
    if (mTraceCpuLoad) {
      sb.append("-l ");
    }
    if (mTraceDiskIo) {
      sb.append("-d ");
    }
    if (mTraceKernelWorkqueues) {
      sb.append("-w ");
    }
    if (mTraceCpuScheduler) {
      sb.append("-s ");
    }
    if (mTraceDuration > 0)
    {
      sb.append("-t");
      sb.append(mTraceDuration);
      sb.append(' ');
    }
    if (mTraceBufferSize > 0)
    {
      sb.append("-b ");
      sb.append(mTraceBufferSize);
      sb.append(' ');
    }
    return sb.toString().trim();
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.SystraceOptionsDialogV1.SystraceOptions
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

import java.io.File;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class SystraceOptionsDialogV1
  extends TitleAreaDialog
  implements ISystraceOptionsDialog
{
  private static final String TITLE = "Android System Trace";
  private static final String DEFAULT_MESSAGE = "Settings to use while capturing system level trace";
  private static final String DEFAULT_TRACE_FNAME = "trace.html";
  private Text mDestinationText;
  private String mDestinationPath;
  private Text mTraceDurationText;
  private Text mTraceBufferSizeText;
  private static String sSaveToFolder = System.getProperty("user.home");
  private static String sTraceDuration = "";
  private static String sTraceBufferSize = "";
  private Button mTraceCpuFreqBtn;
  private Button mTraceCpuIdleBtn;
  private Button mTraceCpuLoadBtn;
  private Button mTraceDiskIoBtn;
  private Button mTraceKernelWorkqueuesBtn;
  private Button mTraceCpuSchedulerBtn;
  private static boolean sTraceCpuFreq;
  private static boolean sTraceCpuIdle;
  private static boolean sTraceCpuLoad;
  private static boolean sTraceDiskIo;
  private static boolean sTraceKernelWorkqueues;
  private static boolean sTraceCpuScheduler;
  private Button mGfxTagBtn;
  private Button mInputTagBtn;
  private Button mViewTagBtn;
  private Button mWebViewTagBtn;
  private Button mWmTagBtn;
  private Button mAmTagBtn;
  private Button mSyncTagBtn;
  private Button mAudioTagBtn;
  private Button mVideoTagBtn;
  private Button mCameraTagBtn;
  private static boolean sGfxTag;
  private static boolean sInputTag;
  private static boolean sViewTag;
  private static boolean sWebViewTag;
  private static boolean sWmTag;
  private static boolean sAmTag;
  private static boolean sSyncTag;
  private static boolean sAudioTag;
  private static boolean sVideoTag;
  private static boolean sCameraTag;
  private final SystraceOptions mOptions = new SystraceOptions(null);
  
  public SystraceOptionsDialogV1(Shell parentShell)
  {
    super(parentShell);
  }
  
  protected Control createDialogArea(Composite parent)
  {
    setTitle("Android System Trace");
    setMessage("Settings to use while capturing system level trace");
    
    Composite c = new Composite(parent, 2048);
    c.setLayout(new GridLayout(3, false));
    c.setLayoutData(new GridData(1808));
    
    Label l = new Label(c, 0);
    l.setLayoutData(new GridData(131072, 16777216, false, false, 1, 1));
    l.setText("Destination File: ");
    
    mDestinationText = new Text(c, 2048);
    mDestinationText.setLayoutData(new GridData(4, 16777216, true, false, 1, 1));
    mDestinationText.setText(sSaveToFolder + File.separator + "trace.html");
    
    final Button browse = new Button(c, 0);
    browse.setText("Browse...");
    browse.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        String path = SystraceOptionsDialogV1.this.openBrowseDialog(browse.getShell());
        if (path != null) {
          mDestinationText.setText(path);
        }
      }
    });
    Label lblTraceDurationseconds = new Label(c, 0);
    lblTraceDurationseconds.setLayoutData(
      new GridData(131072, 16777216, false, false, 1, 1));
    lblTraceDurationseconds.setText("Trace duration (seconds): ");
    
    mTraceDurationText = new Text(c, 2048);
    mTraceDurationText.setLayoutData(new GridData(4, 16777216, true, false, 2, 1));
    mTraceDurationText.setText(sTraceDuration);
    
    Label lblTraceBufferSize = new Label(c, 0);
    lblTraceBufferSize.setLayoutData(new GridData(131072, 16777216, false, false, 1, 1));
    lblTraceBufferSize.setText("Trace Buffer Size (kb): ");
    
    mTraceBufferSizeText = new Text(c, 2048);
    mTraceBufferSizeText.setLayoutData(new GridData(4, 16777216, true, false, 2, 1));
    mTraceBufferSizeText.setText(sTraceBufferSize);
    
    Label separator = new Label(c, 258);
    GridData gd = new GridData(768);
    horizontalSpan = 3;
    separator.setLayoutData(gd);
    
    Group grpTraceEvents = new Group(c, 2048);
    grpTraceEvents.setLayout(new GridLayout(3, false));
    grpTraceEvents.setLayoutData(new GridData(16384, 16777216, true, false, 2, 1));
    grpTraceEvents.setText("Trace Events");
    
    mTraceCpuFreqBtn = new Button(grpTraceEvents, 32);
    mTraceCpuFreqBtn.setText("CPU Frequency Changes");
    mTraceCpuFreqBtn.setSelection(sTraceCpuFreq);
    
    mTraceCpuIdleBtn = new Button(grpTraceEvents, 32);
    mTraceCpuIdleBtn.setText("CPU Idle Events");
    mTraceCpuIdleBtn.setSelection(sTraceCpuIdle);
    
    mTraceCpuLoadBtn = new Button(grpTraceEvents, 32);
    mTraceCpuLoadBtn.setText("CPU Load");
    mTraceCpuLoadBtn.setSelection(sTraceCpuLoad);
    
    mTraceCpuSchedulerBtn = new Button(grpTraceEvents, 32);
    mTraceCpuSchedulerBtn.setText("CPU Scheduler");
    mTraceCpuSchedulerBtn.setSelection(sTraceCpuScheduler);
    
    Group grpTraceRootEvents = new Group(c, 2048);
    grpTraceRootEvents.setLayout(new GridLayout(2, false));
    grpTraceRootEvents.setLayoutData(new GridData(16384, 16777216, true, false, 2, 1));
    grpTraceRootEvents.setText("Trace Events that require root privileges on device");
    
    mTraceDiskIoBtn = new Button(grpTraceRootEvents, 32);
    mTraceDiskIoBtn.setText("Disk I/O");
    mTraceDiskIoBtn.setSelection(sTraceDiskIo);
    
    mTraceKernelWorkqueuesBtn = new Button(grpTraceRootEvents, 32);
    mTraceKernelWorkqueuesBtn.setText("Kernel Workqueues (requires root)");
    mTraceKernelWorkqueuesBtn.setSelection(sTraceKernelWorkqueues);
    
    Group grpTraceTags = new Group(c, 2048);
    grpTraceTags.setLayout(new GridLayout(5, false));
    grpTraceTags.setLayoutData(new GridData(16384, 16777216, true, false, 3, 1));
    grpTraceTags.setText("Trace Tags");
    
    mGfxTagBtn = new Button(grpTraceTags, 32);
    mGfxTagBtn.setText("gfx");
    mGfxTagBtn.setSelection(sGfxTag);
    
    mInputTagBtn = new Button(grpTraceTags, 32);
    mInputTagBtn.setText("input");
    mInputTagBtn.setSelection(sInputTag);
    
    mViewTagBtn = new Button(grpTraceTags, 32);
    mViewTagBtn.setText("view");
    mViewTagBtn.setSelection(sViewTag);
    
    mWebViewTagBtn = new Button(grpTraceTags, 32);
    mWebViewTagBtn.setText("webview");
    mWebViewTagBtn.setSelection(sWebViewTag);
    
    mWmTagBtn = new Button(grpTraceTags, 32);
    mWmTagBtn.setText("wm");
    mWmTagBtn.setSelection(sWmTag);
    
    mAmTagBtn = new Button(grpTraceTags, 32);
    mAmTagBtn.setText("am");
    mAmTagBtn.setSelection(sAmTag);
    
    mSyncTagBtn = new Button(grpTraceTags, 32);
    mSyncTagBtn.setText("sync");
    mSyncTagBtn.setSelection(sSyncTag);
    
    mAudioTagBtn = new Button(grpTraceTags, 32);
    mAudioTagBtn.setText("audio");
    mAudioTagBtn.setSelection(sAudioTag);
    
    mVideoTagBtn = new Button(grpTraceTags, 32);
    mVideoTagBtn.setText("video");
    mVideoTagBtn.setSelection(sVideoTag);
    
    mCameraTagBtn = new Button(grpTraceTags, 32);
    mCameraTagBtn.setText("camera");
    mCameraTagBtn.setSelection(sCameraTag);
    
    Label lblTraceTagsWarning = new Label(grpTraceTags, 0);
    lblTraceTagsWarning.setText(
      "Changes to trace tags will likely need a restart of the Android framework to take effect:\n    $ adb shell stop\n    $ adb shell start");
    
    lblTraceTagsWarning.setLayoutData(new GridData(16384, 16777216, true, false, 5, 1));
    
    ModifyListener m = new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        SystraceOptionsDialogV1.this.validateFields();
      }
    };
    mDestinationText.addModifyListener(m);
    mTraceBufferSizeText.addModifyListener(m);
    mTraceDurationText.addModifyListener(m);
    
    return c;
  }
  
  private void validateFields()
  {
    String msg = validatePath(mDestinationText.getText());
    if (msg != null)
    {
      setErrorMessage(msg);
      getButton(0).setEnabled(false);
      return;
    }
    if (!validateInteger(mTraceDurationText.getText()))
    {
      setErrorMessage("Trace Duration should be a valid integer (seconds)");
      getButton(0).setEnabled(false);
      return;
    }
    if (!validateInteger(mTraceBufferSizeText.getText()))
    {
      setErrorMessage("Trace Buffer Size should be a valid integer (kilobytes)");
      getButton(0).setEnabled(false);
      return;
    }
    getButton(0).setEnabled(true);
    setErrorMessage(null);
  }
  
  private boolean validateInteger(String text)
  {
    if ((text == null) || (text.isEmpty())) {
      return true;
    }
    try
    {
      Integer.parseInt(text);
      return true;
    }
    catch (NumberFormatException localNumberFormatException) {}
    return false;
  }
  
  private String validatePath(String path)
  {
    if ((path == null) || (path.isEmpty())) {
      return null;
    }
    File f = new File(path);
    if (f.isDirectory()) {
      return String.format("The path '%s' points to a folder", new Object[] { path });
    }
    if ((!f.exists()) && 
      (!f.getParentFile().isDirectory())) {
      return String.format("That path '%s' is not a valid folder.", new Object[] { f.getParent() });
    }
    return null;
  }
  
  private String openBrowseDialog(Shell parentShell)
  {
    FileDialog fd = new FileDialog(parentShell, 8192);
    
    fd.setText("Save To");
    fd.setFileName("trace.html");
    
    fd.setFilterPath(sSaveToFolder);
    fd.setFilterExtensions(new String[] { "*.html" });
    
    String fname = fd.open();
    if ((fname == null) || (fname.trim().length() == 0)) {
      return null;
    }
    sSaveToFolder = fd.getFilterPath();
    return fname;
  }
  
  protected void okPressed()
  {
    mDestinationPath = mDestinationText.getText().trim();
    
    sTraceDuration = mTraceDurationText.getText();
    if (!sTraceDuration.isEmpty()) {
      mOptions.mTraceDuration = Integer.parseInt(sTraceDuration);
    }
    sTraceBufferSize = mTraceBufferSizeText.getText();
    if (!sTraceBufferSize.isEmpty()) {
      mOptions.mTraceBufferSize = Integer.parseInt(sTraceBufferSize);
    }
    mOptions.mTraceCpuFreq = mTraceCpuFreqBtn.getSelection();
    mOptions.mTraceCpuIdle = mTraceCpuIdleBtn.getSelection();
    mOptions.mTraceCpuLoad = mTraceCpuLoadBtn.getSelection();
    mOptions.mTraceDiskIo = mTraceDiskIoBtn.getSelection();
    mOptions.mTraceKernelWorkqueues = mTraceKernelWorkqueuesBtn.getSelection();
    mOptions.mTraceCpuScheduler = mTraceCpuSchedulerBtn.getSelection();
    if (mGfxTagBtn.getSelection()) {
      mOptions.enableTag(2);
    }
    if (mInputTagBtn.getSelection()) {
      mOptions.enableTag(4);
    }
    if (mViewTagBtn.getSelection()) {
      mOptions.enableTag(8);
    }
    if (mWebViewTagBtn.getSelection()) {
      mOptions.enableTag(16);
    }
    if (mWmTagBtn.getSelection()) {
      mOptions.enableTag(32);
    }
    if (mAmTagBtn.getSelection()) {
      mOptions.enableTag(64);
    }
    if (mSyncTagBtn.getSelection()) {
      mOptions.enableTag(128);
    }
    if (mAudioTagBtn.getSelection()) {
      mOptions.enableTag(256);
    }
    if (mVideoTagBtn.getSelection()) {
      mOptions.enableTag(512);
    }
    if (mCameraTagBtn.getSelection()) {
      mOptions.enableTag(1024);
    }
    sTraceCpuFreq = mTraceCpuFreqBtn.getSelection();
    sTraceCpuIdle = mTraceCpuIdleBtn.getSelection();
    sTraceCpuLoad = mTraceCpuLoadBtn.getSelection();
    sTraceDiskIo = mTraceDiskIoBtn.getSelection();
    sTraceKernelWorkqueues = mTraceKernelWorkqueuesBtn.getSelection();
    sTraceCpuScheduler = mTraceCpuSchedulerBtn.getSelection();
    
    sGfxTag = mGfxTagBtn.getSelection();
    sInputTag = mInputTagBtn.getSelection();
    sViewTag = mViewTagBtn.getSelection();
    sWebViewTag = mWebViewTagBtn.getSelection();
    sWmTag = mWmTagBtn.getSelection();
    sAmTag = mAmTagBtn.getSelection();
    sSyncTag = mSyncTagBtn.getSelection();
    sAudioTag = mAudioTagBtn.getSelection();
    sVideoTag = mVideoTagBtn.getSelection();
    sCameraTag = mCameraTagBtn.getSelection();
    
    super.okPressed();
  }
  
  public SystraceOptions getSystraceOptions()
  {
    return mOptions;
  }
  
  public String getTraceFilePath()
  {
    return mDestinationPath;
  }
  
  private class SystraceOptions
    implements ISystraceOptions
  {
    private static final int TAG_GFX = 2;
    private static final int TAG_INPUT = 4;
    private static final int TAG_VIEW = 8;
    private static final int TAG_WEBVIEW = 16;
    private static final int TAG_WM = 32;
    private static final int TAG_AM = 64;
    private static final int TAG_SYNC = 128;
    private static final int TAG_AUDIO = 256;
    private static final int TAG_VIDEO = 512;
    private static final int TAG_CAMERA = 1024;
    private int mTraceBufferSize;
    private int mTraceDuration;
    private boolean mTraceCpuFreq;
    private boolean mTraceCpuIdle;
    private boolean mTraceCpuLoad;
    private boolean mTraceDiskIo;
    private boolean mTraceKernelWorkqueues;
    private boolean mTraceCpuScheduler;
    private int mTag;
    
    private SystraceOptions() {}
    
    private void enableTag(int tag)
    {
      mTag |= tag;
    }
    
    public String getTags()
    {
      return "0x" + Integer.toHexString(mTag);
    }
    
    public String getOptions()
    {
      StringBuilder sb = new StringBuilder(20);
      if (mTraceCpuFreq) {
        sb.append("-f ");
      }
      if (mTraceCpuIdle) {
        sb.append("-i ");
      }
      if (mTraceCpuLoad) {
        sb.append("-l ");
      }
      if (mTraceDiskIo) {
        sb.append("-d ");
      }
      if (mTraceKernelWorkqueues) {
        sb.append("-w ");
      }
      if (mTraceCpuScheduler) {
        sb.append("-s ");
      }
      if (mTraceDuration > 0)
      {
        sb.append("-t");
        sb.append(mTraceDuration);
        sb.append(' ');
      }
      if (mTraceBufferSize > 0)
      {
        sb.append("-b ");
        sb.append(mTraceBufferSize);
        sb.append(' ');
      }
      return sb.toString().trim();
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.SystraceOptionsDialogV1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;

class SystraceOptionsDialogV1$1
  extends SelectionAdapter
{
  SystraceOptionsDialogV1$1(SystraceOptionsDialogV1 paramSystraceOptionsDialogV1, Button paramButton) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    String path = SystraceOptionsDialogV1.access$1(this$0, val$browse.getShell());
    if (path != null) {
      SystraceOptionsDialogV1.access$2(this$0).setText(path);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.SystraceOptionsDialogV1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

public class SystraceTag
{
  public final String tag;
  public final String info;
  
  public SystraceTag(String tagName, String details)
  {
    tag = tagName;
    info = details;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.SystraceTag
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;

class SystraceOptionsDialogV2$1
  extends SelectionAdapter
{
  SystraceOptionsDialogV2$1(SystraceOptionsDialogV2 paramSystraceOptionsDialogV2, Button paramButton) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    String path = SystraceOptionsDialogV2.access$2(this$0, val$browse.getShell());
    if (path != null) {
      SystraceOptionsDialogV2.access$3(this$0).setText(path);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.SystraceOptionsDialogV2.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

import com.android.ddmlib.CollectingOutputReceiver;
import com.android.ddmlib.IDevice;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;

public class SystraceVersionDetector
  implements IRunnableWithProgress
{
  public static final int SYSTRACE_V1 = 1;
  public static final int SYSTRACE_V2 = 2;
  private final IDevice mDevice;
  private List<SystraceTag> mTags;
  
  public SystraceVersionDetector(IDevice device)
  {
    mDevice = device;
  }
  
  public void run(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    monitor.beginTask("Checking systrace version on device..", 
      -1);
    
    CountDownLatch setTagLatch = new CountDownLatch(1);
    CollectingOutputReceiver receiver = new CollectingOutputReceiver(setTagLatch);
    try
    {
      String cmd = "atrace --list_categories";
      mDevice.executeShellCommand(cmd, receiver);
      setTagLatch.await(5L, TimeUnit.SECONDS);
    }
    catch (Exception e)
    {
      throw new InvocationTargetException(e);
    }
    String shellOutput = receiver.getOutput();
    mTags = parseSupportedTags(shellOutput);
    
    monitor.done();
  }
  
  public int getVersion()
  {
    if (mTags == null) {
      return 1;
    }
    return 2;
  }
  
  public List<SystraceTag> getTags()
  {
    return mTags;
  }
  
  private List<SystraceTag> parseSupportedTags(String listCategoriesOutput)
  {
    if (listCategoriesOutput == null) {
      return null;
    }
    if (listCategoriesOutput.contains("unknown option")) {
      return null;
    }
    String[] categories = listCategoriesOutput.split("\n");
    List<SystraceTag> tags = new ArrayList(categories.length);
    
    Pattern p = Pattern.compile("([^-]+) - (.*)");
    String[] arrayOfString1;
    int j = (arrayOfString1 = categories).length;
    for (int i = 0; i < j; i++)
    {
      String category = arrayOfString1[i];
      Matcher m = p.matcher(category);
      if (m.find()) {
        tags.add(new SystraceTag(m.group(1).trim(), m.group(2).trim()));
      }
    }
    return tags;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.SystraceVersionDetector
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

public abstract interface ISystraceOptionsDialog
{
  public abstract ISystraceOptions getSystraceOptions();
  
  public abstract String getTraceFilePath();
  
  public abstract int open();
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.ddms.systrace.ISystraceOptionsDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.ddms.systrace;

import com.android.ddmuilib.TableHelper;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

public class SystraceOptionsDialogV2
  extends TitleAreaDialog
  implements ISystraceOptionsDialog
{
  private static final String TITLE = "Android System Trace";
  private static final String DEFAULT_MESSAGE = "Settings to use while capturing system level trace";
  private static final String DEFAULT_TRACE_FNAME = "trace.html";
  private Text mDestinationText;
  private String mDestinationPath;
  private Text mTraceDurationText;
  private Text mTraceBufferSizeText;
  private Combo mTraceAppCombo;
  private static String sSaveToFolder = System.getProperty("user.home");
  private static String sTraceDuration = "";
  private static String sTraceBufferSize = "";
  private static Set<String> sEnabledTags = new HashSet();
  private static String sLastSelectedApp = null;
  private final List<SystraceTag> mSupportedTags;
  private final List<String> mCurrentApps;
  private final SystraceOptions mOptions = new SystraceOptions(null);
  private Table mTable;
  
  public SystraceOptionsDialogV2(Shell parentShell, List<SystraceTag> tags, List<String> apps)
  {
    super(parentShell);
    mSupportedTags = tags;
    mCurrentApps = apps;
  }
  
  protected Control createDialogArea(Composite parent)
  {
    setTitle("Android System Trace");
    setMessage("Settings to use while capturing system level trace");
    
    Composite c = new Composite(parent, 2048);
    c.setLayout(new GridLayout(3, false));
    c.setLayoutData(new GridData(1808));
    
    Label l = new Label(c, 0);
    l.setLayoutData(new GridData(131072, 16777216, false, false, 1, 1));
    l.setText("Destination File: ");
    
    mDestinationText = new Text(c, 2048);
    mDestinationText.setLayoutData(new GridData(4, 16777216, true, false, 1, 1));
    mDestinationText.setText(sSaveToFolder + File.separator + "trace.html");
    
    final Button browse = new Button(c, 0);
    browse.setText("Browse...");
    browse.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        String path = SystraceOptionsDialogV2.this.openBrowseDialog(browse.getShell());
        if (path != null) {
          mDestinationText.setText(path);
        }
      }
    });
    Label lblTraceDurationseconds = new Label(c, 0);
    lblTraceDurationseconds.setLayoutData(
      new GridData(131072, 16777216, false, false, 1, 1));
    lblTraceDurationseconds.setText("Trace duration (seconds): ");
    
    mTraceDurationText = new Text(c, 2048);
    mTraceDurationText.setLayoutData(new GridData(4, 16777216, true, false, 2, 1));
    mTraceDurationText.setText(sTraceDuration);
    
    Label lblTraceBufferSize = new Label(c, 0);
    lblTraceBufferSize.setLayoutData(new GridData(131072, 16777216, false, false, 1, 1));
    lblTraceBufferSize.setText("Trace Buffer Size (kb): ");
    
    mTraceBufferSizeText = new Text(c, 2048);
    mTraceBufferSizeText.setLayoutData(new GridData(4, 16777216, true, false, 2, 1));
    mTraceBufferSizeText.setText(sTraceBufferSize);
    
    Label lblTraceAppName = new Label(c, 0);
    lblTraceAppName.setLayoutData(new GridData(131072, 16777216, false, false, 1, 1));
    lblTraceAppName.setText("Enable Application Traces from: ");
    
    mTraceAppCombo = new Combo(c, 12);
    mTraceAppCombo.setLayoutData(new GridData(4, 16777216, true, false, 2, 1));
    String[] items = new String[mCurrentApps.size() + 1];
    items[0] = "None";
    for (int i = 0; i < mCurrentApps.size(); i++) {
      items[(i + 1)] = ((String)mCurrentApps.get(i));
    }
    mTraceAppCombo.setItems(items);
    if (sLastSelectedApp != null) {
      mTraceAppCombo.setText(sLastSelectedApp);
    } else {
      mTraceAppCombo.select(0);
    }
    Label separator = new Label(c, 258);
    GridData gd = new GridData(768);
    horizontalSpan = 3;
    separator.setLayoutData(gd);
    
    ModifyListener m = new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        SystraceOptionsDialogV2.this.validateFields();
      }
    };
    mDestinationText.addModifyListener(m);
    mTraceBufferSizeText.addModifyListener(m);
    mTraceDurationText.addModifyListener(m);
    
    l = new Label(c, 0);
    l.setText("Select tags to enable: ");
    l.setLayoutData(new GridData(131072, 16777216, false, false, 1, 1));
    
    mTable = new Table(c, 2080);
    gd = new GridData(1808);
    horizontalSpan = 2;
    mTable.setLayoutData(gd);
    mTable.setHeaderVisible(false);
    mTable.setLinesVisible(false);
    for (SystraceTag tag : mSupportedTags)
    {
      TableItem item = new TableItem(mTable, 0);
      item.setText(info);
      item.setChecked(sEnabledTags.contains(tag));
    }
    TableHelper.createTableColumn(mTable, 
      "TagHeaderNotDisplayed", 
      16384, 
      "SampleTagForColumnLengthCalculation", 
      null, 
      null);
    
    return c;
  }
  
  private v
1 2 3 4 5 6 7 8

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-2017. Infinite Loop Ltd