MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getDeviceModel

Function getDeviceModel

libs/utils/src/utils/platform/JvmUtils.cpp:149–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149std::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
166class UncaughtJavaException : public djinni::jni_exception {

Callers

nothing calls this directly

Calls 1

getEnvFunction · 0.70

Tested by

no test coverage detected