本文整理汇总了Java中org.jetbrains.android.sdk.AndroidSdkUtils.getDebugBridge方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidSdkUtils.getDebugBridge方法的具体用法?Java AndroidSdkUtils.getDebugBridge怎么用?Java AndroidSdkUtils.getDebugBridge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.android.sdk.AndroidSdkUtils
的用法示例。
在下文中一共展示了AndroidSdkUtils.getDebugBridge方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectedDevices
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的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()]);
}
示例2: chooseDevice
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的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();
}
示例3: initDevices
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private boolean initDevices(Project project) {
boolean update = true;
if (bridge == null) {
bridge = AndroidSdkUtils.getDebugBridge(project);
}
deviceList.clear();
if (bridge != null) {
IDevice[] devices = bridge.getDevices();
if (devices != null) {
for (IDevice device : devices) {
if (selectDevice != null) {
if (device.getName().equals(selectDevice.getName()) && device.getSerialNumber().equals(selectDevice.getSerialNumber())) {
selectDevice = device;
update = false;
}
}
deviceList.add(device);
}
}
if (deviceList.size() > 0 && selectDevice == null) {
selectDevice = deviceList.get(0);
update = true;
}
} else {
update = false;
}
return update;
}
示例4: loadDevices
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private void loadDevices() {
final AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(myProject);
final IDevice[] devices = bridge != null ? getDevicesWithValidDeviceId(bridge) : new IDevice[0];
final String deviceId = myDataSource.getState().deviceId;
final DefaultComboBoxModel model = new DefaultComboBoxModel(devices);
Object selectedItem = null;
if (deviceId != null && deviceId.length() > 0) {
for (IDevice device : devices) {
if (deviceId.equals(AndroidDbUtil.getDeviceId(device))) {
selectedItem = device;
break;
}
}
if (selectedItem == null) {
model.addElement(deviceId);
myMissingDeviceIds = deviceId;
selectedItem = deviceId;
}
}
myDeviceComboBoxModel = model;
myDeviceComboBox.setModel(model);
if (selectedItem != null) {
myDeviceComboBox.setSelectedItem(selectedItem);
}
}
示例5: doSynchronize
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
@NotNull
public static Set<AndroidDataSource> doSynchronize(@NotNull final Project project,
@NotNull final Collection<AndroidDataSource> dataSourcesToSync) {
final AndroidDebugBridge debugBridge = AndroidSdkUtils.getDebugBridge(project);
if (debugBridge == null) {
Messages.showErrorDialog(project, AndroidBundle.message("cannot.connect.to.adb.error"), CommonBundle.getErrorTitle());
return Collections.emptySet();
}
final Set<AndroidDataSource> syncedDataSources = Collections.synchronizedSet(new HashSet<AndroidDataSource>(dataSourcesToSync));
final MySynchronizeDataSourcesTask task = new MySynchronizeDataSourcesTask(project, debugBridge, syncedDataSources);
ProgressManager.getInstance().run(task);
return syncedDataSources;
}
示例6: getOnlineDevices
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private Set<IDevice> getOnlineDevices() {
AndroidDebugBridge debugBridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
if (debugBridge == null) {
return Collections.emptySet();
}
return Sets.newHashSet(debugBridge.getDevices());
}
示例7: getDevice
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private static DeviceResult getDevice(Project project) {
List<AndroidFacet> facets = getApplicationFacets(project);
if (!facets.isEmpty()) {
AndroidFacet facet = facets.get(0);
String packageName = AdbUtil.computePackageName(facet);
AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(project);
if (bridge == null) {
error("No platform configured");
return null;
}
int count = 0;
while (!bridge.isConnected() || !bridge.hasInitialDeviceList()) {
try {
Thread.sleep(100);
count++;
} catch (InterruptedException e) {
// pass
}
// let's not wait > 10 sec.
if (count > 100) {
error("Timeout getting device list!");
return null;
}
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 1) {
return new DeviceResult(devices, facet, packageName);
} else if (devices.length > 1) {
return askUserForDevice(facet, packageName);
} else {
return null;
}
}
error("No devices found");
return null;
}
示例8: getDevice
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private DeviceResult getDevice(AnActionEvent anActionEvent) {
List<AndroidFacet> facets = getApplicationFacets(anActionEvent.getProject());
if (!facets.isEmpty()) {
AndroidFacet facet = null;
String androidFacetName = getAndroidFacetName(anActionEvent);
if (androidFacetName != null) {
for (AndroidFacet androidFacet : facets) {
if (androidFacet.getModule().getName().equals(androidFacetName)) {
facet = androidFacet;
}
}
if (facet == null) {
return null;
}
} else {
if (facets.size() > 1) {
facet = ModuleChooserDialogHelper.showDialogForFacets(anActionEvent.getProject(), facets);
if (facet == null) {
return null;
}
} else {
facet = facets.get(0);
}
}
String packageName =facet.getAndroidModuleInfo().getPackage();
AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(anActionEvent.getProject());
if (bridge == null) {
error("No platform configured");
return null;
}
if (bridge.isConnected() && bridge.hasInitialDeviceList()) {
IDevice[] devices = bridge.getDevices();
if (devices.length == 1) {
return new DeviceResult(anActionEvent, devices[0], facet, packageName);
} else if (devices.length > 1) {
return askUserForDevice(anActionEvent, facet, packageName);
} else {
return new DeviceResult(anActionEvent, null, facet, null);
}
}
}
return new DeviceResult(anActionEvent, null, null, null);
}
示例9: run
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
public static void run(Project currentProject, boolean fromFastdexTerminal) {
FastdexStatus status = FastdexUtil.checkInstall(currentProject);
if (status != null) {
if (!FastdexUtil.isSupportFastdexVersion(status.getFastdexVersion())) {
if (DialogUtil.createDialog("The current version is too old, does not support fastdex${variantName} task, Update now?", "Of course", "Next time")) {
FastdexUtil.installFastdex(currentProject, status, status.getModuleBuildFile().getPsiFile());
}
return;
}
ArrayList<String> shell = status.getFastdexRunShell(currentProject);
if (shell == null) {
NotificationUtils.gradleWrapperNotFound();
}
else {
if (!Utils.hasInitAndroidDebugBridge()) {
AndroidSdkUtils.getDebugBridge(currentProject);
}
AndroidFacet myFacet = AndroidFacet.getInstance(status.getSelectedModule());
String value = PropertiesComponent.getInstance(currentProject).getValue(ANDROID_TARGET_DEVICES_PROPERTY);
String[] selectedSerials = value != null ? fromString(value) : null;
AndroidPlatform platform = myFacet.getConfiguration().getAndroidPlatform();
DeviceChooserDialog chooser = new DeviceChooserDialog(myFacet, platform.getTarget(), true, selectedSerials, null);
IDevice[] devices = null;
try {
Method method = DeviceChooser.class.getDeclaredMethod("getFilteredDevices");
method.setAccessible(true);
devices = (IDevice[]) method.invoke(chooser.getMyDeviceChooser());
} catch (Throwable e) {
e.printStackTrace();
NotificationUtils.errorMsgDialog(e.getMessage());
return;
}
IDevice targetDevice = null;
if (fromFastdexTerminal && lastSelectedDeviceSN != null && devices != null && devices.length > 0) {
for (IDevice iDevice : devices) {
if (lastSelectedDeviceSN.equals(iDevice.getSerialNumber())) {
targetDevice = iDevice;
break;
}
}
}
if (targetDevice == null) {
if (devices != null && devices.length > 1 && !status.isSupportMultipleDevices()) {
if (DialogUtil.createDialog("The current fastdex version is " + status.getFastdexVersion() + " does not support multiple device connections, Update now?",
"Of course", "Next time")) {
FastdexUtil.installFastdex(currentProject, status, status.getModuleBuildFile().getPsiFile(), Constant.MIN_SUPPORT_MULTIPLE_DEVICE_FASTDEX_VERSION);
}
return;
}
if (devices == null || devices.length != 1) {
chooser.show();
}
if (chooser.isClosed()) {
return;
}
devices = chooser.getSelectedDevices();
if (devices == null || devices.length == 0) {
return;
}
targetDevice = devices[0];
}
lastSelectedDeviceSN = targetDevice.getSerialNumber();
shell.add("-PDEVICE_SN=" + targetDevice.getSerialNumber());
if (status.hasOneAppplicationModule()) {
FastdexTerminal.getInstance(currentProject).initAndExecute(currentProject.getBasePath(),shell);
}
else {
FastdexTerminal.getInstance(currentProject).initAndExecute(status.getSelectedModule().getModuleFile().getParent().getPath(),shell);
}
}
}
}
示例10: doUpdateTree
import org.jetbrains.android.sdk.AndroidSdkUtils; //导入方法依赖的package包/类
private void doUpdateTree(boolean showAllProcesses) {
final AndroidDebugBridge debugBridge = AndroidSdkUtils.getDebugBridge(myProject);
final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
final DefaultTreeModel model = new DefaultTreeModel(root);
if (debugBridge == null) {
myProcessTree.setModel(model);
return;
}
final Set<String> processNames = collectAllProcessNames(myProject);
final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
final String prevProcess = properties.getValue(DEBUGGABLE_PROCESS_PROPERTY);
final String prevDevice = properties.getValue(DEBUGGABLE_DEVICE_PROPERTY);
TreeNode selectedDeviceNode = null;
TreeNode selectedClientNode = null;
Object[] firstTreePath = null;
final IDevice[] devices = debugBridge.getDevices();
for (IDevice device : devices) {
final DefaultMutableTreeNode deviceNode = new DefaultMutableTreeNode(device);
root.add(deviceNode);
for (Client client : device.getClients()) {
final String clientDescription = client.getClientData().getClientDescription();
if (clientDescription != null &&
(showAllProcesses || isRelatedProcess(processNames, clientDescription))) {
final DefaultMutableTreeNode clientNode = new DefaultMutableTreeNode(client);
deviceNode.add(clientNode);
final String deviceName = device.getName();
if (clientDescription.equals(prevProcess) &&
(selectedDeviceNode == null || deviceName.equals(prevDevice))) {
selectedClientNode = clientNode;
selectedDeviceNode = deviceNode;
}
if (firstTreePath == null) {
firstTreePath = new Object[]{root, deviceNode, clientNode};
}
}
}
}
final Object[] pathToSelect =
selectedDeviceNode != null ? new Object[]{root, selectedDeviceNode, selectedClientNode} : firstTreePath;
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
myProcessTree.setModel(model);
if (pathToSelect != null) {
myProcessTree.getSelectionModel().setSelectionPath(new TreePath(pathToSelect));
}
else {
getOKAction().setEnabled(false);
}
TreeUtil.expandAll(myProcessTree);
}
});
}