45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
#include <jni.h>
|
|
#include <string>
|
|
#include <sys/system_properties.h>
|
|
// 日志打印
|
|
#include <android/log.h>
|
|
|
|
#define LOG_TAG "TAG_LOG"
|
|
#define LOGI(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
|
|
|
extern "C"
|
|
JNIEXPORT jstring JNICALL
|
|
Java_com_aoleyun_sn_utils_JGYUtils_getAuthorization(JNIEnv *env, jclass clazz) {
|
|
// TODO: implement getAuthorization()
|
|
std::string hello;
|
|
|
|
// 1. 获取 SDK 版本号 , 存储于 C 字符串 sdk_verison_str 中
|
|
char sdk[128] = "0";
|
|
|
|
// 获取版本号方法
|
|
__system_property_get("ro.build.version.sdk", sdk);
|
|
//将版本号转为 int 值
|
|
int sdk_verison = atoi(sdk);
|
|
jclass cls = env->FindClass("com/aoleyun/sn/BuildConfig");
|
|
jfieldID jfieldId_text = env->GetStaticFieldID(cls, "FLAVOR", "Ljava/lang/String;");
|
|
jstring text = (jstring) env->GetStaticObjectField(cls, jfieldId_text);
|
|
const char *char_name = env->GetStringUTFChars(text, JNI_FALSE);
|
|
std::string s = char_name;
|
|
if (s.compare("newly") == 0) {
|
|
LOGI("newly");
|
|
hello = "Basic NzljNjRlZjQxYjg3MjhhZDZhYTI5YWY6YWJjNjQ3NzRiYjc2YzMyZDVkZTg0Yzk3==";
|
|
} else if (s.compare("MTKnewly") == 0) {
|
|
LOGI("MTKnewly");
|
|
hello = "Basic NzljNjRlZjQxYjg3MjhhZDZhYTI5YWY6YWJjNjQ3NzRiYjc2YzMyZDVkZTg0Yzk3==";
|
|
} else if (s.compare("beta") == 0) {
|
|
LOGI("beta");
|
|
hello = "Basic NTJkODE2NDM2NjViYjJjYWRhY2YwZTllOmI5N2RkZTYwNjdhY2ZhMjY5MDlhZjQ1Nw==";
|
|
}
|
|
// LOGI("%s", char_name);
|
|
// LOGI("dasdasd");
|
|
// LOGI("%s", hello.c_str());
|
|
return env->NewStringUTF(hello.c_str());
|
|
}
|
|
|
|
|