use of com.android.ddmlib.IDevice in project android by JetBrains.
the class AndroidRunConfigurationBase method canInstantRun.
@NotNull
private InstantRunGradleSupport canInstantRun(@NotNull Module module, @NotNull List<AndroidDevice> targetDevices) {
if (targetDevices.size() != 1) {
return CANNOT_BUILD_FOR_MULTIPLE_DEVICES;
}
AndroidDevice device = targetDevices.get(0);
AndroidVersion version = device.getVersion();
if (!InstantRunManager.isInstantRunCapableDeviceVersion(version)) {
return API_TOO_LOW_FOR_INSTANT_RUN;
}
IDevice targetDevice = MakeBeforeRunTaskProvider.getLaunchedDevice(device);
if (targetDevice != null) {
if (MultiUserUtils.hasMultipleUsers(targetDevice, 200, TimeUnit.MILLISECONDS, false)) {
if (// run config explicitly specifies launching as a different user
getUserIdFromAmParameters() != MultiUserUtils.PRIMARY_USERID || !MultiUserUtils.isCurrentUserThePrimaryUser(targetDevice, 200, TimeUnit.MILLISECONDS, true)) {
// activity manager says current user is not primary
return CANNOT_DEPLOY_FOR_SECONDARY_USER;
}
}
}
InstantRunGradleSupport irSupportStatus = InstantRunGradleUtils.getIrSupportStatus(InstantRunGradleUtils.getAppModel(module), version);
if (irSupportStatus != SUPPORTED) {
return irSupportStatus;
}
// Gradle will instrument against the runtime android.jar (see commit 353f46cbc7363e3fca44c53a6dc0b4d17347a6ac).
// This means that the SDK platform corresponding to the device needs to be installed, otherwise the build will fail.
// We do this as the last check because it is actually possible to recover from this failure. In the future, maybe issues
// that have fixes will have to be handled in a more generic way.
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform == null) {
return SUPPORTED;
}
IAndroidTarget[] targets = platform.getSdkData().getTargets();
for (int i = targets.length - 1; i >= 0; i--) {
if (!targets[i].isPlatform()) {
continue;
}
if (targets[i].getVersion().equals(version)) {
return SUPPORTED;
}
}
return TARGET_PLATFORM_NOT_INSTALLED;
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class DeviceSelectionUtils method getAllCompatibleDevices.
@NotNull
public static List<IDevice> getAllCompatibleDevices(Predicate<IDevice> deviceFilter) {
final List<IDevice> compatibleDevices = new ArrayList<IDevice>();
final AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
if (bridge != null) {
IDevice[] devices = bridge.getDevices();
for (IDevice device : devices) {
if (deviceFilter.apply(device)) {
compatibleDevices.add(device);
}
}
}
return compatibleDevices;
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class DeviceChooser method getFilteredDevices.
@NotNull
private IDevice[] getFilteredDevices() {
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
if (bridge == null || !bridge.isConnected()) {
return EMPTY_DEVICE_ARRAY;
}
final List<IDevice> filteredDevices = new ArrayList<IDevice>();
for (IDevice device : bridge.getDevices()) {
if (myFilter == null || myFilter.apply(device)) {
filteredDevices.add(device);
}
}
return filteredDevices.toArray(new IDevice[filteredDevices.size()]);
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class DeviceChooser method getSelectedDevices.
@NotNull
private IDevice[] getSelectedDevices(boolean onlyCompatible) {
int[] rows = mySelectedRows != null ? mySelectedRows : myDeviceTable.getSelectedRows();
List<IDevice> result = new ArrayList<IDevice>();
for (int row : rows) {
if (row >= 0) {
if (onlyCompatible && !isRowCompatible(row)) {
continue;
}
Object serial = myDeviceTable.getValueAt(row, SERIAL_COLUMN_INDEX);
IDevice[] devices = getFilteredDevices();
for (IDevice device : devices) {
if (device.getSerialNumber().equals(serial.toString())) {
result.add(device);
break;
}
}
}
}
return result.toArray(new IDevice[result.size()]);
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class DeviceChooserDialog method updateOkButton.
private void updateOkButton() {
IDevice[] devices = getSelectedDevices();
boolean enabled = devices.length > 0;
for (IDevice device : devices) {
if (!device.isOnline()) {
enabled = false;
}
}
getOKAction().setEnabled(enabled);
}
Aggregations