| 147 | } |
| 148 | |
| 149 | std::string getDeviceModel() { |
| 150 | JNIEnv* env = getEnv(); |
| 151 | if (env == nullptr) { |
| 152 | return {}; |
| 153 | } |
| 154 | jclass buildClass = env->FindClass("android/os/Build"); |
| 155 | jfieldID modelId = env->GetStaticFieldID(buildClass, "MODEL", "Ljava/lang/String;"); |
| 156 | auto* modelObj = reinterpret_cast<jstring>(env->GetStaticObjectField(buildClass, modelId)); |
| 157 | const char* deviceModel = env->GetStringUTFChars(modelObj, nullptr); |
| 158 | if (env->ExceptionCheck() != 0u) { |
| 159 | env->ExceptionClear(); |
| 160 | return {}; |
| 161 | } |
| 162 | return std::string(deviceModel); |
| 163 | } |
| 164 | } // namespace snap::utils::platform |
| 165 | |
| 166 | class UncaughtJavaException : public djinni::jni_exception { |