void Application::GetRequestedAppControl(const picojson::value& args, picojson::object* out) {
LoggerD("Entered");
- const std::string& encoded_bundle =
- GetCurrentExtension()->GetRuntimeVariable("encoded_bundle", 1024);
+ const std::string& encoded_bundle = RequestedApplicationControl::GetEncodedBundle();
picojson::value result = picojson::value(picojson::object());
PlatformResult result = PlatformResult(ErrorCode::NO_ERROR);
const picojson::array& data = data_arr.get<picojson::array>();
- const std::string& encoded_bundle =
- GetCurrentExtension()->GetRuntimeVariable("encoded_bundle", 1024);
+ const std::string& encoded_bundle = GetEncodedBundle();
result = set_bundle(encoded_bundle);
if (result.IsError()) {
// read input data
PlatformResult result = PlatformResult(ErrorCode::NO_ERROR);
- const std::string& encoded_bundle =
- GetCurrentExtension()->GetRuntimeVariable("encoded_bundle", 1024);
+ const std::string& encoded_bundle = GetEncodedBundle();
result = set_bundle(encoded_bundle);
if (result.IsError()) {
ReportSuccess(*out);
}
+std::string RequestedApplicationControl::GetEncodedBundle() {
+ LoggerD("Entered");
+
+ std::string result;
+ std::size_t size = 512;
+
+ // make sure we read whole variable, if the length of read variable is equal
+ // to the size we were trying to obtain, the variable is likely to be longer
+ do {
+ size <<= 1;
+ result = GetCurrentExtension()->GetRuntimeVariable("encoded_bundle", size);
+ } while (strlen(result.c_str()) == size);
+
+ return result;
+}
+
PlatformResult RequestedApplicationControl::VerifyCallerPresence() {
LoggerD("Entered");
void ReplyResult(const picojson::value& args, picojson::object* out);
void ReplyFailure(picojson::object* out);
+ static std::string GetEncodedBundle();
+
private:
void set_app_control(app_control_h app_control);
common::PlatformResult VerifyCallerPresence();