aconfig: update cpp codegen

Use access system call to check existence of a file to reduce the cost.

Change-Id: Id64b419db81b2f8ac923b49f7293ee8a54aa78ca
This commit is contained in:
Dennis Shen
2024-09-20 13:15:56 +00:00
parent 8ee4271956
commit 46986a4f02

View File

@@ -2,7 +2,7 @@
{{ if allow_instrumentation }}
{{ if readwrite- }}
#include <sys/stat.h>
#include <unistd.h>
#include "aconfig_storage/aconfig_storage_read_api.hpp"
#include <android/log.h>
#define LOG_TAG "aconfig_cpp_codegen"
@@ -78,8 +78,7 @@ namespace {cpp_namespace} \{
, flag_value_file_(nullptr)
, read_from_new_storage_(false) \{
struct stat buffer;
if (stat("/metadata/aconfig/boot/enable_only_new_storage", &buffer) == 0) \{
if (access("/metadata/aconfig/boot/enable_only_new_storage", F_OK) == 0) \{
read_from_new_storage_ = true;
}