init: move "started at" environment var names to headers

Move "FIRST_STAGE_STARTED_AT" to env_first_stage_started_at variable
in first_stage_init.h.  Move "SELINUX_STARTED_AT" to
env_selinux_started_at variable in selinux.h.

Test: build
Bug: 124491153
Bug: 129780532
Change-Id: I512d1835dcee5a3d034ac453b27b0709eed23cff
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index f069c58..7dd3ad4 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -235,7 +235,7 @@
 
     SetInitAvbVersionInRecovery();
 
-    setenv("FIRST_STAGE_STARTED_AT", std::to_string(start_time.time_since_epoch().count()).c_str(),
+    setenv(kEnvFirstStageStartedAt, std::to_string(start_time.time_since_epoch().count()).c_str(),
            1);
 
     const char* path = "/system/bin/init";
diff --git a/init/first_stage_init.h b/init/first_stage_init.h
index 0476e44..7de816f 100644
--- a/init/first_stage_init.h
+++ b/init/first_stage_init.h
@@ -21,5 +21,7 @@
 
 int FirstStageMain(int argc, char** argv);
 
+static constexpr char kEnvFirstStageStartedAt[] = "FIRST_STAGE_STARTED_AT";
+
 }  // namespace init
 }  // namespace android
diff --git a/init/init.cpp b/init/init.cpp
index a18c2c8..1f3c2fc 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -56,6 +56,7 @@
 #include "action_parser.h"
 #include "boringssl_self_test.h"
 #include "epoll.h"
+#include "first_stage_init.h"
 #include "first_stage_mount.h"
 #include "import_parser.h"
 #include "keychords.h"
@@ -630,20 +631,18 @@
 
 static void RecordStageBoottimes(const boot_clock::time_point& second_stage_start_time) {
     int64_t first_stage_start_time_ns = -1;
-    static constexpr char first_stage_started_at[] = "FIRST_STAGE_STARTED_AT";
-    if (auto first_stage_start_time_str = getenv(first_stage_started_at);
+    if (auto first_stage_start_time_str = getenv(kEnvFirstStageStartedAt);
         first_stage_start_time_str) {
         property_set("ro.boottime.init", first_stage_start_time_str);
         android::base::ParseInt(first_stage_start_time_str, &first_stage_start_time_ns);
     }
-    unsetenv(first_stage_started_at);
+    unsetenv(kEnvFirstStageStartedAt);
 
     int64_t selinux_start_time_ns = -1;
-    static constexpr char selinux_started_at[] = "SELINUX_STARTED_AT";
-    if (auto selinux_start_time_str = getenv(selinux_started_at); selinux_start_time_str) {
+    if (auto selinux_start_time_str = getenv(kEnvSelinuxStartedAt); selinux_start_time_str) {
         android::base::ParseInt(selinux_start_time_str, &selinux_start_time_ns);
     }
-    unsetenv(selinux_started_at);
+    unsetenv(kEnvSelinuxStartedAt);
 
     if (selinux_start_time_ns == -1) return;
     if (first_stage_start_time_ns == -1) return;
diff --git a/init/selinux.cpp b/init/selinux.cpp
index f897170..8a63363 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -544,7 +544,7 @@
         PLOG(FATAL) << "restorecon failed of /system/bin/init failed";
     }
 
-    setenv("SELINUX_STARTED_AT", std::to_string(start_time.time_since_epoch().count()).c_str(), 1);
+    setenv(kEnvSelinuxStartedAt, std::to_string(start_time.time_since_epoch().count()).c_str(), 1);
 
     const char* path = "/system/bin/init";
     const char* args[] = {path, "second_stage", nullptr};
diff --git a/init/selinux.h b/init/selinux.h
index 3aa9406..c7d6647 100644
--- a/init/selinux.h
+++ b/init/selinux.h
@@ -35,6 +35,8 @@
                                        const std::vector<std::string>& aliases, int type,
                                        std::string* result);
 
+static constexpr char kEnvSelinuxStartedAt[] = "SELINUX_STARTED_AT";
+
 }  // namespace init
 }  // namespace android