Fix fastdeploy failure in Windows
adb --fastdeploy creates a TemporaryFile to which the stdout for a shell command is redirected. This happens while the file is still open (the TemporaryFile object holds the file handle). In Linux this works, but Windows blocks the operation with an error of "The process cannot access the file because it is being used by another process". This change closes the file before the shell tries to write to it. Test: mm -j 72 Test: adb install --fastdeploy --force-agent --local-agent /mnt/raid/boat-attack-apk/boat-attack-swappy.apk Bug: 122592986 Change-Id: Iaaaf62cda43e4714d7f979e6a690549b383a7b82
This commit is contained in:
parent
0ae6d74436
commit
f788f67c23
|
@ -33,7 +33,6 @@
|
|||
#include "client/file_sync_client.h"
|
||||
#include "commandline.h"
|
||||
#include "fastdeploy.h"
|
||||
#include "sysdeps.h"
|
||||
|
||||
static constexpr int kFastDeployMinApi = 24;
|
||||
|
||||
|
@ -159,17 +158,23 @@ static int install_app_streamed(int argc, const char** argv, bool use_fastdeploy
|
|||
|
||||
if (use_fastdeploy == true) {
|
||||
TemporaryFile metadataTmpFile;
|
||||
TemporaryFile patchTmpFile;
|
||||
std::string patchTmpFilePath;
|
||||
{
|
||||
TemporaryFile patchTmpFile;
|
||||
patchTmpFile.DoNotRemove();
|
||||
patchTmpFilePath = patchTmpFile.path;
|
||||
}
|
||||
|
||||
FILE* metadataFile = fopen(metadataTmpFile.path, "wb");
|
||||
extract_metadata(file, metadataFile);
|
||||
fclose(metadataFile);
|
||||
|
||||
create_patch(file, metadataTmpFile.path, patchTmpFile.path);
|
||||
create_patch(file, metadataTmpFile.path, patchTmpFilePath.c_str());
|
||||
// pass all but 1st (command) and last (apk path) parameters through to pm for
|
||||
// session creation
|
||||
std::vector<const char*> pm_args{argv + 1, argv + argc - 1};
|
||||
install_patch(file, patchTmpFile.path, pm_args.size(), pm_args.data());
|
||||
install_patch(file, patchTmpFilePath.c_str(), pm_args.size(), pm_args.data());
|
||||
adb_unlink(patchTmpFilePath.c_str());
|
||||
delete_device_patch_file(file);
|
||||
return 0;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue