Loading adb/client/fastdeploy.cpp +6 −11 Original line number Diff line number Diff line Loading @@ -101,17 +101,12 @@ void fastdeploy_set_agent_update_strategy(FastDeploy_AgentUpdateStrategy agent_u static void push_to_device(const void* data, size_t byte_count, const char* dst, bool sync) { std::vector<const char*> srcs; { TemporaryFile temp; android::base::WriteFully(temp.fd, data, byte_count); srcs.push_back(temp.path); // On Windows, the file needs to be flushed before pushing to device. // closing the file flushes its content, but we still need to remove it after push. // FileDeleter does exactly that. temp.DoNotRemove(); } FileDeleter temp_deleter(srcs.back()); TemporaryFile tf; android::base::WriteFully(tf.fd, data, byte_count); srcs.push_back(tf.path); // On Windows, the file needs to be flushed before pushing to device, // but can't be removed until after the push. unix_close(tf.release()); if (!do_sync_push(srcs, dst, sync)) { error_exit("Failed to push fastdeploy agent to device."); Loading adb/fastdeploy/deployagent/test/com/android/fastdeploy/FastDeployTest.java +8 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; import com.android.ddmlib.Log.LogLevel; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.log.LogUtil.CLog; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; Loading Loading @@ -68,17 +70,19 @@ public class FastDeployTest extends BaseHostJUnit4Test { } private boolean isAppInstalled(String packageName) throws DeviceNotAvailableException { final String commandResult = getDevice().executeShellCommand("pm list packages"); final String result = getDevice().executeShellCommand("pm list packages"); CLog.logAndDisplay(LogLevel.INFO, result); final int prefixLength = "package:".length(); return Arrays.stream(commandResult.split("\\r?\\n")) return Arrays.stream(result.split("\\r?\\n")) .anyMatch(line -> line.substring(prefixLength).equals(packageName)); } // Mostly copied from PkgInstallSignatureVerificationTest.java. private String fastInstallPackage(String apkPath) private void fastInstallPackage(String apkPath) throws IOException, DeviceNotAvailableException { return getDevice().executeAdbCommand("install", "-t", "--fastdeploy", "--force-agent", String result = getDevice().executeAdbCommand("install", "-t", "--fastdeploy", "--force-agent", apkPath); CLog.logAndDisplay(LogLevel.INFO, result); } } Loading Loading
adb/client/fastdeploy.cpp +6 −11 Original line number Diff line number Diff line Loading @@ -101,17 +101,12 @@ void fastdeploy_set_agent_update_strategy(FastDeploy_AgentUpdateStrategy agent_u static void push_to_device(const void* data, size_t byte_count, const char* dst, bool sync) { std::vector<const char*> srcs; { TemporaryFile temp; android::base::WriteFully(temp.fd, data, byte_count); srcs.push_back(temp.path); // On Windows, the file needs to be flushed before pushing to device. // closing the file flushes its content, but we still need to remove it after push. // FileDeleter does exactly that. temp.DoNotRemove(); } FileDeleter temp_deleter(srcs.back()); TemporaryFile tf; android::base::WriteFully(tf.fd, data, byte_count); srcs.push_back(tf.path); // On Windows, the file needs to be flushed before pushing to device, // but can't be removed until after the push. unix_close(tf.release()); if (!do_sync_push(srcs, dst, sync)) { error_exit("Failed to push fastdeploy agent to device."); Loading
adb/fastdeploy/deployagent/test/com/android/fastdeploy/FastDeployTest.java +8 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; import com.android.ddmlib.Log.LogLevel; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.log.LogUtil.CLog; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; Loading Loading @@ -68,17 +70,19 @@ public class FastDeployTest extends BaseHostJUnit4Test { } private boolean isAppInstalled(String packageName) throws DeviceNotAvailableException { final String commandResult = getDevice().executeShellCommand("pm list packages"); final String result = getDevice().executeShellCommand("pm list packages"); CLog.logAndDisplay(LogLevel.INFO, result); final int prefixLength = "package:".length(); return Arrays.stream(commandResult.split("\\r?\\n")) return Arrays.stream(result.split("\\r?\\n")) .anyMatch(line -> line.substring(prefixLength).equals(packageName)); } // Mostly copied from PkgInstallSignatureVerificationTest.java. private String fastInstallPackage(String apkPath) private void fastInstallPackage(String apkPath) throws IOException, DeviceNotAvailableException { return getDevice().executeAdbCommand("install", "-t", "--fastdeploy", "--force-agent", String result = getDevice().executeAdbCommand("install", "-t", "--fastdeploy", "--force-agent", apkPath); CLog.logAndDisplay(LogLevel.INFO, result); } } Loading