add copy apks to temp folder
diff --git a/chrome/browser/chromeos/file_manager/arc_file_tasks.cc b/chrome/browser/chromeos/file_manager/arc_file_tasks.cc
index 6131bb7..d6d095c 100644
--- a/chrome/browser/chromeos/file_manager/arc_file_tasks.cc
+++ b/chrome/browser/chromeos/file_manager/arc_file_tasks.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/file_manager/arc_file_tasks.h"
+#include <fcntl.h>
#include <memory>
#include <string>
#include <utility>
@@ -12,6 +13,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
@@ -343,6 +345,38 @@
const std::vector<storage::FileSystemURL>& file_system_urls,
const std::vector<std::string>& mime_types,
FileTaskFinishedCallback done) {
+
+ constexpr char kArcApksFolder[] = "/var/run/chrome/archero/apks";
+ int mode = 0777;
+ int open_flags = O_WRONLY | O_CREAT;
+
+ for (size_t i = 0; i < file_system_urls.size(); ++i) {
+ if (file_system_urls[i].path().FinalExtension() == std::string(".apk")) {
+ base::FilePath folder(kArcApksFolder);
+ base::File::Error error;
+ if (!base::CreateDirectoryAndGetError(folder, &error)) {
+ LOG(ERROR) << "Failed to create " << folder << ": "
+ << base::File::ErrorToString(error);
+ }
+ if (!base::SetPosixFilePermissions(folder, mode)) {
+ LOG(ERROR) << "Could not set permissions: " << folder;
+ }
+ base::File source(file_system_urls[i].path(),
+ base::File::FLAG_OPEN | base::File::FLAG_READ);
+
+ std::string target_path(kArcApksFolder);
+ target_path.append("/");
+ target_path.append(file_system_urls[i].path().BaseName().value());
+
+ base::File target(open(target_path.c_str(), open_flags, mode));
+ if (!base::CopyFileContents(source, target)) {
+ LOG(ERROR)
+ << "ExecuteArcTask couldn't copy file to /var/run/chrome/archero : "
+ << file_system_urls[i].path();
+ }
+ }
+ }
+
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK_EQ(file_system_urls.size(), mime_types.size());