当前位置: 首页>>代码示例>>Java>>正文


Java AndroidDebugBridge类代码示例

本文整理汇总了Java中com.android.ddmlib.AndroidDebugBridge的典型用法代码示例。如果您正苦于以下问题:Java AndroidDebugBridge类的具体用法?Java AndroidDebugBridge怎么用?Java AndroidDebugBridge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AndroidDebugBridge类属于com.android.ddmlib包,在下文中一共展示了AndroidDebugBridge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
public static void main(String[] args) {		
	Timer timer = new Timer();
       timer.schedule(new TimerTask() {        	
           @Override
           public void run() {
           	LoggerHelper.logEvent(MyLevel.TIMEOUT, "-1 | Complete analysis stopped due to timeout of 40 minutes");
               System.exit(0);
           }
       }, 40 * 60000);
	
	
	try{
		Main.v().run(args);
		AndroidDebugBridge.terminate();
	}catch(Exception ex) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		ex.printStackTrace(pw);			
		LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, sw.toString());
		UtilMain.writeToFile("mainException.txt", FrameworkOptions.apkPath + "\n");
	}
	LoggerHelper.logEvent(MyLevel.EXECUTION_STOP, "Analysis successfully terminated");
	//this is necessary otherwise we will wait for a max of 20 minutes for the TimerTask
	System.exit(0);
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:26,代码来源:Main.java

示例2: connectToAndroidDevice

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
public void connectToAndroidDevice() {
	LoggerHelper.logEvent(MyLevel.RUNTIME, "Connecting to ADB...");				
	if(adb == null) {
	    AndroidDebugBridge.init(false);		    			
//		AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
//				FrameworkOptions.PLATFORM_TOOLS + File.separator + "adb", true);
		adb = AndroidDebugBridge.createBridge();				
	}
	
	waitForDevice();		
	this.device = getDevice(FrameworkOptions.devicePort);
	if(this.device == null) {
		LoggerHelper.logEvent(MyLevel.EXCEPTION_RUNTIME, String.format("Device with port %s not found! -- retry it", FrameworkOptions.devicePort));
		connectToAndroidDevice();
	}
	LoggerHelper.logEvent(MyLevel.RUNTIME, "Successfully connected to ADB...");		
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:18,代码来源:FrameworkEventManager.java

示例3: waitForInitialDeviceList

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
/**
 * Wait for the Android Debug Bridge to return an initial device list.
 */
protected static void waitForInitialDeviceList(final AndroidDebugBridge androidDebugBridge, Logger logger) {
    if (!androidDebugBridge.hasInitialDeviceList()) {
        logger.info("Waiting for initial device list from the Android Debug Bridge");
        long limitTime = System.currentTimeMillis() + ADB_TIMEOUT_MS;
        while (!androidDebugBridge.hasInitialDeviceList() && (System.currentTimeMillis() < limitTime)) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException("Interrupted waiting for initial device list from Android Debug Bridge");
            }
        }
        if (!androidDebugBridge.hasInitialDeviceList()) {
            logger.error("Did not receive initial device list from the Android Debug Bridge.");
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:20,代码来源:AwoInstaller.java

示例4: observeForDeviceChange

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
/**
 * Observe for deviec state changes
 */
private void observeForDeviceChange() {
    deviceSelectionListener =
            new DeviceContext.DeviceSelectionListener() {
                @Override
                public void deviceSelected(@Nullable IDevice device) {
                    notifyDeviceUpdated(device);
                }

                @Override
                public void deviceChanged(@NotNull IDevice device, int changeMask) {
                    if ((changeMask & IDevice.CHANGE_STATE) == IDevice.CHANGE_STATE) {
                        notifyDeviceUpdated(device);
                    }
                }

                @Override
                public void clientSelected(@Nullable final Client c) {
                }
            };
    deviceContext.addListener(deviceSelectionListener, this);
    AndroidDebugBridge.addClientChangeListener(this);
    AndroidDebugBridge.addDeviceChangeListener(this);
    AndroidDebugBridge.addDebugBridgeChangeListener(this);
}
 
开发者ID:josesamuel,项目名称:logviewer,代码行数:28,代码来源:LogSourceManager.java

示例5: dispose

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
@Override
public void dispose() {
    AndroidDebugBridge.removeClientChangeListener(this);
    for (DeviceLogSource deviceLogSource : deviceLogSourcesMap.values()) {
        deviceLogSource.getLogProvider().dispose();
    }
    for (LogSource fileLogSource : fileLogSourcesMap.values()) {
        fileLogSource.getLogProvider().dispose();
    }
    if (myBridge != null) {
        AndroidDebugBridge.removeDeviceChangeListener(this);
        AndroidDebugBridge.removeDebugBridgeChangeListener(this);
        myBridge = null;
    }

    deviceLogSourcesMap.clear();
}
 
开发者ID:josesamuel,项目名称:logviewer,代码行数:18,代码来源:LogSourceManager.java

示例6: actionPerformed

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    final AndroidDebugBridge debugBridge = AndroidSdkProvider.getAdb();
    if (debugBridge != null) {
        RequestProcessor.getDefault().post(new Runnable() {

            @Override
            public void run() {
                StatusDisplayer.getDefault().setStatusText(
                        NbBundle.getMessage(MobileDeviceNode.class, "MSG_restarting_ADB"));
                boolean status = debugBridge.restart();
                StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
                        MobileDeviceNode.class,
                        status ? "MSG_ADB_restart_success" : "MSG_ADB_restart_fail"));
            }
        });
    } else {
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(MobileDeviceNode.class, "ERR_cannot_restart_ADB"));
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:21,代码来源:RestartADBAction.java

示例7: getPropertySets

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
@Override
public PropertySet[] getPropertySets() {
    final Sheet.Set set = Sheet.createPropertiesSet();
    set.put(new PropertySupport.ReadOnly<Boolean>(
            "PROP_DebugBridgeConnected",
            Boolean.class,
            NbBundle.getMessage(DevicesNode.class, "PROP_DebugBridgeConnected"),
            NbBundle.getMessage(DevicesNode.class, "DESC_DebugBridgeConnected")) {
        @Override
        public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
            final AndroidDebugBridge jp = AndroidSdkProvider.getAdb();
            return jp == null ? Boolean.FALSE : jp.isConnected();
        }
    });
    return new PropertySet[]{
        set
    };
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:19,代码来源:DevicesNode.java

示例8: updateAdb

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
protected void updateAdb() {
    AndroidSdk sdk = defaultSdk.get();
    if (sdk != null) {
        final FileObject path = sdk.findTool(ADB_TOOL);
        if (path != null) {
            ClientData.class.getClassLoader().clearAssertionStatus();      //qattern
            DebugPortManager.setProvider(DebugPortProvider.getDefault());
            AndroidDebugBridge.initIfNeeded(true);
            String adbLocation = FileUtil.toFile(path).getAbsolutePath();
            String lastLocation = adbPath.getAndSet(adbLocation);
            pcs.firePropertyChange(PROP_DEFAULT_ADB_PATH, lastLocation, adbLocation);
            AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(adbLocation, false);
            AndroidDebugBridge lastAdb = adb.getAndSet(bridge);
            pcs.firePropertyChange(PROP_DEFAULT_ADB, lastAdb, bridge);
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:18,代码来源:AndroidSdkProvider.java

示例9: getADBInstance

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
/**
 * 获取ADB连接实例
 * 
 * @return AndroidDebugBridge
 */
public static AndroidDebugBridge getADBInstance() {
	if (bridge == null) {
		AndroidDebugBridge.init(false);
		String os = System.getProperty("os.name").toLowerCase();
		if (os.startsWith("win")) {
			// 如果是win系统
			bridge = AndroidDebugBridge.createBridge(DirConfig.ADB_DIR + "adb.exe", true);
		} else if(os.startsWith("mac")) {
			// 如果是osx系统
			bridge = AndroidDebugBridge.createBridge(DirConfig.MAC_ADB_DIR + "adb", true);
		} else {
			bridge = AndroidDebugBridge.createBridge("adb",true);
		}
	}
	return bridge;
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:22,代码来源:AdbUtil.java

示例10: getSelectedDevices

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
@NotNull
public IDevice[] getSelectedDevices() {
  int[] rows = mySelectedRows != null ? mySelectedRows : myDeviceTable.getSelectedRows();
  List<IDevice> result = new ArrayList<IDevice>();
  for (int row : rows) {
    if (row >= 0) {
      Object serial = myDeviceTable.getValueAt(row, SERIAL_COLUMN_INDEX);
      final AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
      if (bridge == null) {
        return EMPTY_DEVICE_ARRAY;
      }
      IDevice[] devices = getFilteredDevices(bridge);
      for (IDevice device : devices) {
        if (device.getSerialNumber().equals(serial.toString())) {
          result.add(device);
          break;
        }
      }
    }
  }
  return result.toArray(new IDevice[result.size()]);
}
 
开发者ID:zzz40500,项目名称:ADB-Duang,代码行数:23,代码来源:MyDeviceChooser.java

示例11: close

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
/**
 * Closes all open resources. <b>MUST BE CALLED WHEN THIS CLASS IS NO LONGER NEEDED.</b>
 */
public void close() {
    LOGGER.info("Closing the AgentManager.");
    try {
        // We close the bridge and adb service, so bridge creation wont fail next time we try. This is a workaround,
        // ddmlib is bugged.
        AndroidDebugBridge.disconnectBridge();

        // Terminate the bridge connection
        AndroidDebugBridge.terminate();

        dispatcher.close();

        // Stops the chrome driver started as a service
        deviceManager.stopChromeDriverService();

        if(AgentPropertiesLoader.hasFtpServer()) {
            // Disconnect and logout the FTP client
            deviceManager.stopFtpFileTransferService();
        }
    } catch (Exception e) {
        // If something cannot be closed it was never opened, so it's okay.
        // Nothing to do here.
        LOGGER.info(e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:29,代码来源:AgentManager.java

示例12: chooseDevice

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
private IDevice chooseDevice() {
    AndroidDebugBridge adb = AndroidSdkUtils.getDebugBridge(project);
    if (adb == null) {
        showErrorNotification("ADB connection error");
        return null;
    }
    List<IDevice> devices = Arrays.asList(adb.getDevices());
    if (devices.isEmpty()) {
        showErrorNotification("Can't find any devices");
        return null;
    }
    if (devices.size() == 1) {
        return devices.get(0);
    }
    return new ChooseDialog<IDevice>(project, "Choose Device", devices) {
        @Override
        protected String getItemName(IDevice d) {
            return d.getProperty(IDevice.PROP_DEVICE_MANUFACTURER) + " " + d.getProperty(IDevice.PROP_DEVICE_MODEL)
                    + " [" + d.getSerialNumber() + "]";
        }
    }
            .showAndGetResult();
}
 
开发者ID:shchurov,项目名称:SharedPreferences-Editor-Plugin,代码行数:24,代码来源:OpenEditorAction.java

示例13: actionPerformed

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  Notifications.Bus.notify(new Notification("Android", "ADB", "ADB requested.", NotificationType.INFORMATION));
  Project project = getEventProject(e);
  File adb = project == null ? null : AndroidSdkUtils.getAdb(project);
  if (adb == null) {
    return;
  }

  ListenableFuture<AndroidDebugBridge> bridge = AdbService.getInstance().getDebugBridge(adb);
  Futures.addCallback(bridge, new FutureCallback<AndroidDebugBridge>() {
    @Override
    public void onSuccess(AndroidDebugBridge result) {
      Notifications.Bus.notify(new Notification("Android", "ADB", "ADB obtained", NotificationType.INFORMATION));
    }

    @Override
    public void onFailure(Throwable t) {
      Notifications.Bus.notify(new Notification("Android", "ADB", "ADB error: " + t.toString(), NotificationType.INFORMATION));
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GetAdbAction.java

示例14: run

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
@Override
public void run() {
  AndroidDebugBridge.addClientChangeListener(this);

  myClient.dumpHprof();
  synchronized (myEvents) {
     myEvent = myEvents.start(System.currentTimeMillis(), MemoryMonitorView.EVENT_HPROF);
  }
  try {
    myResponse.await(1, TimeUnit.MINUTES);
    // TODO Handle cases where it fails or times out.
  }
  catch (InterruptedException e) {
    // Interrupted
  }
  // If the event had not finished, finish it now
  synchronized (myEvents) {
    if (myEvent != null) {
      myEvent.stop(System.currentTimeMillis());
    }
  }
  AndroidDebugBridge.removeClientChangeListener(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DumpHprofAction.java

示例15: initDebugBridge

import com.android.ddmlib.AndroidDebugBridge; //导入依赖的package包/类
private void initDebugBridge() {
	if (bridge == null) {
		AndroidDebugBridge.init(false);
	}
	
	if ((bridge == null) || (!bridge.isConnected())) {
		String adbLocation = System.getProperty("user.dir");
		System.out.println(adbLocation);
		if ((adbLocation != null) && (adbLocation.length() != 0)) {
			adbLocation = adbLocation + File.separator + "adb";
			File file= new File(adbLocation);
			if(!file.exists())
				adbLocation = "adb";
		}else{
			adbLocation = "adb";
		}
		bridge = AndroidDebugBridge.createBridge(adbLocation, false);
	}
}
 
开发者ID:hoozheng,项目名称:AndroidRobot,代码行数:20,代码来源:AdbDevice.java


注:本文中的com.android.ddmlib.AndroidDebugBridge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。