Minor c/c++ codegen update

1, Moved "#include <string>" from exported header to test flag provider
header file.

2, For production target and read only flags, the generated c
api should just return default value instead of calling into c++ api

3, Remove using namespace server_configurable_flags from header, instead
of just having the namespace to be spelled out in each api call. Having
using namespace xxx in header is not a c++ best practice.

4, Replace #ifdef #def #endif with #pragma once

Bug: b/279483801
Test: atest aconfig.test
Change-Id: I3e55a7b14301f3de419795467f33e2dc889d371e
diff --git a/tools/aconfig/templates/c_exported_header.template b/tools/aconfig/templates/c_exported_header.template
index c22b048..ca812a7 100644
--- a/tools/aconfig/templates/c_exported_header.template
+++ b/tools/aconfig/templates/c_exported_header.template
@@ -1,5 +1,4 @@
-#ifndef {header}_c_HEADER_H
-#define {header}_c_HEADER_H
+#pragma once
 
 #ifdef __cplusplus
 extern "C" \{
@@ -20,4 +19,3 @@
 #ifdef __cplusplus
 }
 #endif
-#endif
diff --git a/tools/aconfig/templates/c_source_file.template b/tools/aconfig/templates/c_source_file.template
index 3d2482d..384221d 100644
--- a/tools/aconfig/templates/c_source_file.template
+++ b/tools/aconfig/templates/c_source_file.template
@@ -3,7 +3,15 @@
 
 {{ for item in class_elements}}
 bool {header}_{item.flag_name}() \{
+    {{ if for_test }}
     return {cpp_namespace}::{item.flag_name}();
+    {{ -else- }}
+    {{ if not item.readwrite- }}
+    return {item.default_value};
+    {{ -else- }}
+    return {cpp_namespace}::{item.flag_name}();
+    {{ -endif }}
+    {{ -endif }}
 }
 
 {{ if for_test }}
diff --git a/tools/aconfig/templates/cpp_exported_header.template b/tools/aconfig/templates/cpp_exported_header.template
index e45548e..cd01853 100644
--- a/tools/aconfig/templates/cpp_exported_header.template
+++ b/tools/aconfig/templates/cpp_exported_header.template
@@ -1,7 +1,5 @@
-#ifndef {header}_HEADER_H
-#define {header}_HEADER_H
+#pragma once
 
-#include <string>
 #include <memory>
 
 namespace {cpp_namespace} \{
@@ -50,4 +48,3 @@
 }
 {{ -endif }}
 }
-#endif
diff --git a/tools/aconfig/templates/cpp_prod_flag_provider.template b/tools/aconfig/templates/cpp_prod_flag_provider.template
index 6ba9e41..f908f12 100644
--- a/tools/aconfig/templates/cpp_prod_flag_provider.template
+++ b/tools/aconfig/templates/cpp_prod_flag_provider.template
@@ -1,9 +1,8 @@
-#ifndef {header}_flag_provider_HEADER_H
-#define {header}_flag_provider_HEADER_H
+#pragma once
+
 #include "{header}.h"
 {{ if readwrite }}
 #include <server_configurable_flags/get_flags.h>
-using namespace server_configurable_flags;
 {{ endif }}
 
 namespace {cpp_namespace} \{
@@ -12,7 +11,7 @@
     {{ for item in class_elements}}
     virtual bool {item.flag_name}() override \{
         {{ if item.readwrite- }}
-        return GetServerConfigurableFlag(
+        return server_configurable_flags::GetServerConfigurableFlag(
             "{item.device_config_namespace}",
             "{item.device_config_flag}",
             "{item.default_value}") == "true";
@@ -23,4 +22,3 @@
     {{ endfor }}
 };
 }
-#endif
diff --git a/tools/aconfig/templates/cpp_test_flag_provider.template b/tools/aconfig/templates/cpp_test_flag_provider.template
index afa56cf..03f10a5 100644
--- a/tools/aconfig/templates/cpp_test_flag_provider.template
+++ b/tools/aconfig/templates/cpp_test_flag_provider.template
@@ -1,13 +1,13 @@
-#ifndef {header}_flag_provider_HEADER_H
-#define {header}_flag_provider_HEADER_H
+#pragma once
+
 #include "{header}.h"
 
 {{ if readwrite }}
 #include <server_configurable_flags/get_flags.h>
-using namespace server_configurable_flags;
 {{ endif }}
 
 #include <unordered_map>
+#include <string>
 
 namespace {cpp_namespace} \{
 class flag_provider : public flag_provider_interface \{
@@ -26,7 +26,7 @@
 	          return it->second;
         } else \{
           {{ if item.readwrite- }}
-          return GetServerConfigurableFlag(
+          return server_configurable_flags::GetServerConfigurableFlag(
               "{item.device_config_namespace}",
               "{item.device_config_flag}",
               "{item.default_value}") == "true";
@@ -46,4 +46,3 @@
     }
 };
 }
-#endif