54 lines
3.0 KiB
C++
54 lines
3.0 KiB
C++
#include <jni.h>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
std::vector<std::pair<int, std::pair<std::string, std::unordered_map<std::string, std::string>>>> firebaseDataOrdered = {
|
|
{0, {"dev", {{"apiKey", "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"}, {"appId", "1:650071678820:android:a53292637abb7c0d6c6471"}, {"projectId", "hpos-af3cc"}, {"storageBucket", "hpos-af3cc.appspot.com"}}}},
|
|
{1, {"qc-qa", {{"apiKey", "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs"}, {"appId", "1:1004619739289:android:3dbcefb10ea99654e5c808"}, {"projectId", "hpos-qa"}, {"storageBucket", "hpos-qa.appspot.com"}}}},
|
|
{2, {"prod", {{"apiKey", "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"}, {"appId", "1:1012719870714:android:d8d7c962d96f4097de5f43"}, {"projectId", "hpos-prod"}, {"storageBucket", "hpos-prod.appspot.com"}}}},
|
|
{3, {"pre prod", {{"apiKey", "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38"}, {"appId", "1:121176529204:android:e6841fdac57bdc95bbed61"}, {"projectId", "hpos-preprod"}, {"storageBucket", "hpos-preprod.appspot.com"}}}},
|
|
{4, {"SMI R&D", {{"apiKey", "AIzaSyAVxpilbB804iRCCpMBDjjmdZhQguctGHM"}, {"appId", "1:327771387914:android:a3b4ed2e42ea6e38dc87f3"}, {"projectId", "hposrandd"}, {"storageBucket", "hposrandd.firebasestorage.app"}}}},
|
|
{5, {"molbio", {{"apiKey", "molbio"}, {"appId", "molbio"}, {"projectId", "molbio"}, {"storageBucket", "molbio"}}}}
|
|
};
|
|
|
|
|
|
extern "C"
|
|
JNIEXPORT jobject JNICALL
|
|
Java_com_example_hpostesting_firebase_FirebaseManager_getFirebaseDataMap(JNIEnv *env,jobject thiz) {
|
|
jclass mapClass = env->FindClass("java/util/LinkedHashMap");
|
|
jmethodID init = env->GetMethodID(mapClass, "<init>", "()V");
|
|
jmethodID put = env->GetMethodID(mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
|
jobject outerMap = env->NewObject(mapClass, init);
|
|
|
|
for (const auto &entry : firebaseDataOrdered) {
|
|
int order = entry.first;
|
|
const std::string &outerKeyStr = entry.second.first;
|
|
const auto &innerMapData = entry.second.second;
|
|
|
|
jobject innerMap = env->NewObject(mapClass, init);
|
|
// "int" field for order
|
|
|
|
jstring intKey = env->NewStringUTF("int");
|
|
jstring intValue = env->NewStringUTF(std::to_string(order).c_str());
|
|
env->CallObjectMethod(innerMap, put, intKey, intValue);
|
|
env->DeleteLocalRef(intKey);
|
|
env->DeleteLocalRef(intValue);
|
|
|
|
// actual firebase config keys
|
|
for (const auto &innerPair : innerMapData) {
|
|
jstring key = env->NewStringUTF(innerPair.first.c_str());
|
|
jstring value = env->NewStringUTF(innerPair.second.c_str());
|
|
env->CallObjectMethod(innerMap, put, key, value);
|
|
env->DeleteLocalRef(key);
|
|
env->DeleteLocalRef(value);
|
|
}
|
|
|
|
jstring outerKey = env->NewStringUTF(outerKeyStr.c_str());
|
|
env->CallObjectMethod(outerMap, put, outerKey, innerMap);
|
|
env->DeleteLocalRef(outerKey);
|
|
env->DeleteLocalRef(innerMap);
|
|
}
|
|
|
|
return outerMap;
|
|
}
|