arc: Rename use_outfile to out_dir + use as is

Bug: 142684959
Bug: 136273873
Bug: 139379357
Bug: 138805202
Bug: 142685922
Test: adb shell bugreport
Test: atest dumpstate_test
Test: flash android to dut, android-sh, setenforce 1, arc-bugreport
Change-Id: Ia2bb2d4609467d902ce7424d882ed88422867d0b
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index e6bfa14..581d3de 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2296,8 +2296,7 @@
 
     std::string final_path = ds.path_;
     if (ds.options_->OutputToCustomFile()) {
-        std::string bugreport_dir = dirname(ds.options_->use_outfile.c_str());
-        final_path = ds.GetPath(bugreport_dir, ".zip");
+        final_path = ds.GetPath(ds.options_->out_dir, ".zip");
         android::os::CopyFileToFile(ds.path_, final_path);
     }
 
@@ -2418,7 +2417,7 @@
             // clang-format off
             case 'd': do_add_date = true;            break;
             case 'z': do_zip_file = true;            break;
-            case 'o': use_outfile = optarg;          break;
+            case 'o': out_dir = optarg;              break;
             case 's': use_socket = true;             break;
             case 'S': use_control_socket = true;     break;
             case 'v': show_header_only = true;       break;
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index a133f7e..0d25d30 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -386,12 +386,12 @@
         // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide).
         ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode =
             ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT;
-        // File descriptor to output zip file. Takes precedence over use_outfile..
+        // File descriptor to output zip file. Takes precedence over out_dir.
         android::base::unique_fd bugreport_fd;
         // File descriptor to screenshot file.
         android::base::unique_fd screenshot_fd;
-        // Partial path to output file.
-        std::string use_outfile;
+        // Custom output directory.
+        std::string out_dir;
         // Bugreport mode of the bugreport.
         std::string bugreport_mode;
         // Command-line arguments as string
@@ -421,7 +421,7 @@
         /* Returns if options specified require writing to custom file location */
         bool OutputToCustomFile() {
             // Custom location is only honored in limited mode.
-            return limited_only && !use_outfile.empty() && bugreport_fd.get() == -1;
+            return limited_only && !out_dir.empty() && bugreport_fd.get() == -1;
         }
     };
 
diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp
index e167145..c7df1bb 100644
--- a/cmds/dumpstate/tests/dumpstate_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_test.cpp
@@ -172,7 +172,7 @@
 
     EXPECT_FALSE(options_.do_add_date);
     EXPECT_FALSE(options_.do_zip_file);
-    EXPECT_EQ("", options_.use_outfile);
+    EXPECT_EQ("", options_.out_dir);
     EXPECT_FALSE(options_.use_socket);
     EXPECT_FALSE(options_.use_control_socket);
     EXPECT_FALSE(options_.show_header_only);
@@ -366,7 +366,7 @@
     EXPECT_TRUE(options_.use_control_socket);
     EXPECT_FALSE(options_.do_vibrate);
     EXPECT_TRUE(options_.limited_only);
-    EXPECT_EQ(" abc", std::string(options_.use_outfile));
+    EXPECT_EQ(" abc", std::string(options_.out_dir));
 
     // Other options retain default values
     EXPECT_FALSE(options_.show_header_only);