Java Code Examples for org.jetbrains.android.sdk.AndroidSdkUtils#getAdb()

The following examples show how to use org.jetbrains.android.sdk.AndroidSdkUtils#getAdb() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From WIFIADB with Apache License 2.0 5 votes vote down vote up
public static String getAdbPath() {
    String adbPath = Properties.instance().pjLevel().getValue(Config.ADB_PATH);

    if (Utils.isBlank(adbPath)) {
        final File adbFile = AndroidSdkUtils.getAdb(Global.instance().project());

        if (adbFile != null) {
            adbPath = adbFile.getAbsolutePath();
            Properties.instance().pjLevel().setValue(Config.ADB_PATH, adbPath);
        }
    }

    return adbPath;
}
 
Example 2
Source File: MobileInstallAdbLocationProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
/** Returns location of the adb binary suitable for the given project. */
static Optional<String> getAdbLocationForMobileInstall(Project project) {
  for (MobileInstallAdbLocationProvider provider : EP_NAME.getExtensions()) {
    return provider.getAdbLocation(project);
  }
  File adb = AndroidSdkUtils.getAdb(project);
  return adb == null ? Optional.empty() : Optional.of(adb.getAbsolutePath());
}
 
Example 3
Source File: ADB.java    From AndroidWiFiADB with Apache License 2.0 5 votes vote down vote up
private String getAdbPath() {
  String adbPath = "";
  File adbFile = AndroidSdkUtils.getAdb(project);
  if (adbFile != null) {
    adbPath = adbFile.getAbsolutePath();
  }
  return adbPath;
}
 
Example 4
Source File: LogviewFactory.java    From logviewer with Apache License 2.0 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {

    final File adb = AndroidSdkUtils.getAdb(project);
    ExecutionManager.getInstance(project).getContentManager();

    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("LogViewer", TOOL_WINDOW_ID, "Logview Tools", project);

    toolWindow.setIcon(LogviewerPluginIcons.TOOL_ICON);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);


    DeviceContext deviceContext = new DeviceContext();

    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final LogView logcatView = logcatContent.getUserData(LOG_VIEW_KEY);
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);

    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);

    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    c.putUserData(LOG_VIEW_KEY, logcatView);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            logcatView.activate();
        }
    }, project.getDisposed());


    if (adb != null) {
        loadingPanel.setLoadingText("Initializing ADB");
        loadingPanel.startLoading();

        //ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
        ListenableFuture<AndroidDebugBridge> future = AdbBridgeFactory.getAdb(adb);
        Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {
            @Override
            public void onSuccess(@Nullable AndroidDebugBridge bridge) {
                Logger.getInstance(LogviewFactory.class).info("Successfully obtained debug bridge");
                loadingPanel.stopLoading();
            }

            @Override
            public void onFailure(@NotNull Throwable t) {
                loadingPanel.stopLoading();
                Logger.getInstance(LogviewFactory.class).info("Unable to obtain debug bridge", t);
                String msg;
                if (t.getMessage() != null) {
                    msg = t.getMessage();
                } else {
                    msg = String.format("Unable to establish a connection to adb",
                            ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
                }
                Messages.showErrorDialog(msg, "ADB Connection Error");
            }
        }, EdtExecutor.INSTANCE);
    } else {
        logcatView.showHint("No adb connection!.\n\nDrag and drop log files to view them.");
    }
}