henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "webrtc/modules/audio_device/android/build_info.h" |
| 12 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 13 | #include "webrtc/modules/utility/include/helpers_android.h" |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | BuildInfo::BuildInfo() |
kwiberg | 1c7fdd8 | 2016-04-26 08:18:04 -0700 | [diff] [blame] | 18 | : j_environment_(JVM::GetInstance()->environment()), |
| 19 | j_build_info_( |
| 20 | JVM::GetInstance()->GetClass("org/webrtc/voiceengine/BuildInfo")) {} |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 21 | |
| 22 | std::string BuildInfo::GetStringFromJava(const char* name) { |
| 23 | jmethodID id = j_build_info_.GetStaticMethodId(name, "()Ljava/lang/String;"); |
| 24 | jstring j_string = static_cast<jstring>( |
| 25 | j_build_info_.CallStaticObjectMethod(id)); |
| 26 | return j_environment_->JavaToStdString(j_string); |
| 27 | } |
| 28 | |
| 29 | std::string BuildInfo::GetDeviceModel() { |
| 30 | return GetStringFromJava("getDeviceModel"); |
| 31 | } |
| 32 | |
| 33 | std::string BuildInfo::GetBrand() { |
| 34 | return GetStringFromJava("getBrand"); |
| 35 | } |
| 36 | |
| 37 | std::string BuildInfo::GetDeviceManufacturer() { |
| 38 | return GetStringFromJava("getDeviceManufacturer"); |
| 39 | } |
| 40 | |
| 41 | std::string BuildInfo::GetAndroidBuildId() { |
| 42 | return GetStringFromJava("getAndroidBuildId"); |
| 43 | } |
| 44 | |
| 45 | std::string BuildInfo::GetBuildType() { |
| 46 | return GetStringFromJava("getBuildType"); |
| 47 | } |
| 48 | |
| 49 | std::string BuildInfo::GetBuildRelease() { |
| 50 | return GetStringFromJava("getBuildRelease"); |
| 51 | } |
| 52 | |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 53 | SdkCode BuildInfo::GetSdkVersion() { |
| 54 | jmethodID id = j_build_info_.GetStaticMethodId("getSdkVersion", "()I"); |
| 55 | jint j_version = j_build_info_.CallStaticIntMethod(id); |
| 56 | return static_cast<SdkCode>(j_version); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } // namespace webrtc |