use of com.android.ddmlib.IDevice in project android by JetBrains.
the class NonGradleApkProviderTest method testGetApks.
public void testGetApks() throws Exception {
IDevice device = Mockito.mock(IDevice.class);
myFacet.getProperties().APK_PATH = "artifact.apk";
NonGradleApkProvider provider = new NonGradleApkProvider(myFacet, new NonGradleApplicationIdProvider(myFacet), null);
Collection<ApkInfo> apks = provider.getApks(device);
assertNotNull(apks);
assertEquals(1, apks.size());
ApkInfo apk = apks.iterator().next();
assertEquals("p1.p2", apk.getApplicationId());
assertTrue(apk.getFile().getPath().endsWith("artifact.apk"));
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class RestartActivityAction method findDevices.
/**
* Finds the devices associated with all run configurations for the given project
*/
@NotNull
private static List<IDevice> findDevices(@Nullable Project project) {
if (project == null) {
return Collections.emptyList();
}
List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
if (runningProcesses.isEmpty()) {
return Collections.emptyList();
}
List<IDevice> devices = Lists.newArrayList();
for (RunContentDescriptor descriptor : runningProcesses) {
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler == null || processHandler.isProcessTerminated() || processHandler.isProcessTerminating()) {
continue;
}
devices.addAll(getConnectedDevices(processHandler));
}
return devices;
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class InstantRunBuilderTest method setUp.
@Before
public void setUp() throws Exception {
myDevice = mock(IDevice.class);
when(myDevice.getSerialNumber()).thenReturn("device1-serial");
myInstalledPatchCache = new InstalledPatchCache();
myInstantRunContext = mock(InstantRunContext.class);
when(myInstantRunContext.getInstantRunBuildInfo()).thenReturn(InstantRunBuildInfo.get(BUILD_INFO)).thenReturn(InstantRunBuildInfo.get(BUILD_INFO_RELOAD_DEX));
when(myInstantRunContext.getApplicationId()).thenReturn(APPLICATION_ID);
when(myInstantRunContext.getInstalledPatchCache()).thenReturn(myInstalledPatchCache);
myRunConfigContext = new AndroidRunConfigContext();
myRunConfigContext.setTargetDevices(DeviceFutures.forDevices(Collections.singletonList(myDevice)));
myTasksProvider = mock(InstantRunTasksProvider.class);
when(myTasksProvider.getFullBuildTasks()).thenReturn(ASSEMBLE_TASKS);
when(myTasksProvider.getCleanAndGenerateSourcesTasks()).thenReturn(CLEAN_TASKS);
myInstalledApkCache = new InstalledApkCache() {
@Override
protected String executeShellCommand(@NotNull IDevice device, @NotNull String cmd, long timeout, @NotNull TimeUnit timeUnit) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException, InterruptedException {
return myDumpsysPackageOutput;
}
};
myApk = FileUtil.createTempFile("foo", "apk");
myTaskRunner = new RecordingTaskRunner();
myInstantRunClientDelegate = createInstantRunClientDelegate();
myBuilder = new InstantRunBuilder(myDevice, myInstantRunContext, myRunConfigContext, myTasksProvider, false, myInstalledApkCache, myInstantRunClientDelegate);
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class AndroidProcessHandler method addClient.
private void addClient(@NotNull final Client client) {
if (!myClients.add(client)) {
return;
}
IDevice device = client.getDevice();
notifyTextAvailable("Connected to process " + client.getClientData().getPid() + " on device " + device.getName() + "\n", ProcessOutputTypes.STDOUT);
}
use of com.android.ddmlib.IDevice in project android by JetBrains.
the class AndroidRunConfigurationBase method getFastDeployDevices.
@Nullable
private static DeviceFutures getFastDeployDevices(@NotNull Executor executor, @NotNull AndroidFacet facet, @NotNull AndroidSessionInfo info) {
if (!InstantRunSettings.isInstantRunEnabled()) {
InstantRunManager.LOG.info("Instant run not enabled in settings");
return null;
}
if (!info.getExecutorId().equals(executor.getId())) {
String msg = String.format("Cannot Instant Run since old executor (%1$s) doesn't match current executor (%2$s)", info.getExecutorId(), executor.getId());
InstantRunManager.LOG.info(msg);
return null;
}
List<IDevice> devices = info.getDevices();
if (devices == null || devices.isEmpty()) {
InstantRunManager.LOG.info("Cannot Instant Run since we could not locate the devices from the existing launch session");
return null;
}
if (devices.size() > 1) {
InstantRunManager.LOG.info("Last run was on > 1 device, not reusing devices and prompting again");
return null;
}
AndroidModuleModel model = AndroidModuleModel.get(facet);
AndroidVersion version = devices.get(0).getVersion();
InstantRunGradleSupport status = InstantRunGradleUtils.getIrSupportStatus(model, version);
if (status != SUPPORTED) {
InstantRunManager.LOG.info("Cannot Instant Run: " + status);
return null;
}
return DeviceFutures.forDevices(devices);
}
Aggregations