Change the file location for update_engine log

We used to write update_engine logs to /data/misc/update_engine, which
has 'root' permission and is inaccessible to other users. This CL
changes the log file location to a new directory under /data/misc/
created with 'system' permission.

Bug: 65568605
Test: mma
Change-Id: Ife5ef318692a8c74636524753c0fd696f149bab0
diff --git a/main.cc b/main.cc
index 91805ae..0b96307 100644
--- a/main.cc
+++ b/main.cc
@@ -89,7 +89,7 @@
   string log_file;
   if (log_to_file) {
 #ifdef __ANDROID__
-    log_file = "/data/misc/update_engine/update_engine.log";
+    log_file = "/data/misc/update_engine_log/update_engine.log";
     log_settings.delete_old = logging::DELETE_OLD_LOG_FILE;
 #else
     log_file = SetupLogFile("/var/log");
@@ -98,6 +98,12 @@
     log_settings.log_file = log_file.c_str();
   }
   logging::InitLogging(log_settings);
+
+#ifdef __ANDROID__
+  // The log file will have AID_LOG as group ID; this GID is inherited from the
+  // parent directory "/data/misc/update_engine_log" which sets the SGID bit.
+  chmod(log_file.c_str(), 0640);
+#endif
 }
 
 }  // namespace