Search in sources :

Example 1 with InstalledPatchCache

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);
}
Also used : AndroidRunConfigContext(com.android.tools.idea.run.AndroidRunConfigContext) IDevice(com.android.ddmlib.IDevice) IOException(java.io.IOException) InstalledPatchCache(com.android.tools.idea.run.InstalledPatchCache) InstalledApkCache(com.android.tools.idea.run.InstalledApkCache) ShellCommandUnresponsiveException(com.android.ddmlib.ShellCommandUnresponsiveException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) TimeUnit(java.util.concurrent.TimeUnit) TimeoutException(com.android.ddmlib.TimeoutException) Before(org.junit.Before)

Example 2 with InstalledPatchCache

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;
}
Also used : HashCode(com.google.common.hash.HashCode) InstalledPatchCache(com.android.tools.idea.run.InstalledPatchCache)

Aggregations

InstalledPatchCache (com.android.tools.idea.run.InstalledPatchCache)2 AdbCommandRejectedException (com.android.ddmlib.AdbCommandRejectedException)1 IDevice (com.android.ddmlib.IDevice)1 ShellCommandUnresponsiveException (com.android.ddmlib.ShellCommandUnresponsiveException)1 TimeoutException (com.android.ddmlib.TimeoutException)1 AndroidRunConfigContext (com.android.tools.idea.run.AndroidRunConfigContext)1 InstalledApkCache (com.android.tools.idea.run.InstalledApkCache)1 HashCode (com.google.common.hash.HashCode)1 IOException (java.io.IOException)1 TimeUnit (java.util.concurrent.TimeUnit)1 Before (org.junit.Before)1