[android] Implemented getting the app version from native code

This commit is contained in:
Alexander Zatsepin 2018-08-07 14:15:27 +03:00 committed by Aleksey Belousov
parent 9a8c58ee09
commit 84ecf864c0

View file

@ -1,10 +1,17 @@
#include "com/mapswithme/core/jni_helper.hpp"
#include "platform/http_user_agent.hpp"
namespace platform
{
std::string HttpUserAgent::ExtractAppVersion() const
{
//TODO(@alexzatsepin): implement app version extraction.
return {};
JNIEnv * env = jni::GetEnv();
static auto const buildConfigClass = jni::GetGlobalClassRef(env,
"com/mapswithme/maps/BuildConfig");
auto const versionNameField = jni::GetStaticFieldID(env, buildConfigClass, "VERSION_NAME",
"Ljava/lang/String;");
jni::TScopedLocalRef versionNameResult(env, env->GetStaticObjectField(buildConfigClass,
versionNameField));
return jni::ToNativeString(env, static_cast<jstring>(versionNameResult.get()));
}
} // platform