use of com.android.tools.idea.run.InstalledPatchCache 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.tools.idea.run.InstalledPatchCache in project android by JetBrains.
the class InstantRunBuilder method manifestResourceChanged.
/**
* Returns true if a resource referenced from the manifest has changed since the last manifest push to the device.
*/
public boolean manifestResourceChanged(@NotNull IDevice device) {
InstalledPatchCache cache = myInstantRunContext.getInstalledPatchCache();
// See if the resources have changed.
// Since this method can be called before we've built, we're looking at the previous
// manifest now. However, manifest edits are treated separately (see manifestChanged()),
// so the goal here is to look for the referenced resources from the manifest
// (when the manifest itself hasn't been edited) and see if any of *them* have changed.
HashCode currentHash = myInstantRunContext.getManifestResourcesHash();
HashCode installedHash = cache.getInstalledManifestResourcesHash(device, myInstantRunContext.getApplicationId());
if (installedHash != null && !installedHash.equals(currentHash)) {
return true;
}
return false;
}
Aggregations