Update codegen to return defautl value if package is not in storage file

Bug: 301491148
Test: m and presubmits
Change-Id: Ic4ed15f31fce928e89a2b12259a69faa48e5f60e
diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs
index 7bc34d6..d318b96 100644
--- a/tools/aconfig/aconfig/src/codegen/rust.rs
+++ b/tools/aconfig/aconfig/src/codegen/rust.rs
@@ -295,7 +295,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 1)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(false)
+                            }
                         }
                     })
                 });
@@ -339,7 +342,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 2)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(false)
+                            }
                         }
                     })
                 });
@@ -383,7 +389,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 3)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(false)
+                            }
                         }
                     })
                 });
@@ -428,7 +437,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 8)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(true)
+                            }
                         }
                     })
                 });
diff --git a/tools/aconfig/aconfig/templates/cpp_source_file.template b/tools/aconfig/aconfig/templates/cpp_source_file.template
index 852b905..eaaf86f 100644
--- a/tools/aconfig/aconfig/templates/cpp_source_file.template
+++ b/tools/aconfig/aconfig/templates/cpp_source_file.template
@@ -76,7 +76,8 @@
             : boolean_start_index_()
             {{ -endif }}
             , flag_value_file_(nullptr)
-            , read_from_new_storage_(false) \{
+            , read_from_new_storage_(false)
+            , package_exists_in_storage_(true) \{
 
             if (access("/metadata/aconfig/boot/enable_only_new_storage", F_OK) == 0) \{
                read_from_new_storage_ = true;
@@ -99,6 +100,11 @@
                 ALOGE("error: failed to get package read context: %s", context.error().c_str());
             }
 
+            if (!(context->package_exists)) \{
+               package_exists_in_storage_ = false;
+               return;
+            }
+
             // cache package boolean flag start index
             boolean_start_index_ = context->boolean_start_index;
 
@@ -126,6 +132,10 @@
             if (cache_[{item.readwrite_idx}] == -1) \{
             {{ if allow_instrumentation- }}
                 if (read_from_new_storage_) \{
+                    if (!package_exists_in_storage_) \{
+                       return {item.default_value};
+                    }
+
                     auto value = aconfig_storage::get_boolean_flag_value(
                         *flag_value_file_,
                         boolean_start_index_ + {item.flag_offset});
@@ -168,6 +178,8 @@
         std::unique_ptr<aconfig_storage::MappedStorageFile> flag_value_file_;
 
         bool read_from_new_storage_;
+
+        bool package_exists_in_storage_;
     {{ -endif }}
     {{ -endif }}
 
diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template
index c2f162f..6456360 100644
--- a/tools/aconfig/aconfig/templates/rust.template
+++ b/tools/aconfig/aconfig/templates/rust.template
@@ -51,7 +51,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + {flag.flag_offset})
                                     .map_err(|err| format!("failed to get flag: \{err}"))
                             },
-                            None => Err("no context found for package '{package}'".to_string())
+                            None => \{
+                                 log!(Level::Error, "no context found for package {package}");
+                                 Ok({flag.default_value})
+                            }
                         }
                     })
                 });
diff --git a/tools/aconfig/aflags/Cargo.toml b/tools/aconfig/aflags/Cargo.toml
index 7efce6d..d31e232 100644
--- a/tools/aconfig/aflags/Cargo.toml
+++ b/tools/aconfig/aflags/Cargo.toml
@@ -9,10 +9,10 @@
 protobuf = "3.2.0"
 regex = "1.10.3"
 aconfig_protos = { path = "../aconfig_protos" }
-aconfigd_protos = { version = "0.1.0", path = "../../../../../system/server_configurable_flags/aconfigd"}
+aconfigd_protos = { version = "0.1.0", path = "../../../../../packages/modules/ConfigInfrastructure/aconfigd/proto"}
 nix = { version = "0.28.0", features = ["user"] }
 aconfig_storage_file = { version = "0.1.0", path = "../aconfig_storage_file" }
 aconfig_storage_read_api = { version = "0.1.0", path = "../aconfig_storage_read_api" }
 clap = {version = "4.5.2" }
 aconfig_device_paths = { version = "0.1.0", path = "../aconfig_device_paths" }
-aconfig_flags = { version = "0.1.0", path = "../aconfig_flags" }
\ No newline at end of file
+aconfig_flags = { version = "0.1.0", path = "../aconfig_flags" }