Fix bug in removal of *.flock files.

Bug: 20816098
Change-Id: I72ee32884f32af43a54518c9b9772f63957ab5de
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 2f67263..208d2b9 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -96,9 +96,8 @@
 
 OatFileAssistant::~OatFileAssistant() {
   // Clean up the lock file.
-  if (lock_file_.get() != nullptr) {
-    lock_file_->Erase();
-    TEMP_FAILURE_RETRY(unlink(lock_file_->GetPath().c_str()));
+  if (flock_.HasFile()) {
+    TEMP_FAILURE_RETRY(unlink(flock_.GetFile()->GetPath().c_str()));
   }
 }
 
@@ -121,7 +120,7 @@
 
 bool OatFileAssistant::Lock(std::string* error_msg) {
   CHECK(error_msg != nullptr);
-  CHECK(lock_file_.get() == nullptr) << "OatFileAssistant::Lock already acquired";
+  CHECK(!flock_.HasFile()) << "OatFileAssistant::Lock already acquired";
 
   if (OatFileName() == nullptr) {
     *error_msg = "Failed to determine lock file";
@@ -129,13 +128,7 @@
   }
   std::string lock_file_name = *OatFileName() + ".flock";
 
-  lock_file_.reset(OS::CreateEmptyFile(lock_file_name.c_str()));
-  if (lock_file_.get() == nullptr) {
-    *error_msg = "Failed to create lock file " + lock_file_name;
-    return false;
-  }
-
-  if (!flock_.Init(lock_file_.get(), error_msg)) {
+  if (!flock_.Init(lock_file_name.c_str(), error_msg)) {
     TEMP_FAILURE_RETRY(unlink(lock_file_name.c_str()));
     return false;
   }
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index a25ee31..bb8dd27 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -353,7 +353,6 @@
   // To implement Lock(), we lock a dummy file where the oat file would go
   // (adding ".flock" to the target file name) and retain the lock for the
   // remaining lifetime of the OatFileAssistant object.
-  std::unique_ptr<File> lock_file_;
   ScopedFlock flock_;
 
   // In a properly constructed OatFileAssistant object, dex_location_ should