OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_BUILD_INFO_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_BUILD_INFO_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_BUILD_INFO_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_BUILD_INFO_H_ |
13 | 13 |
14 #include <jni.h> | 14 #include <jni.h> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "webrtc/modules/utility/include/jvm_android.h" | 18 #include "webrtc/modules/utility/include/jvm_android.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
| 22 // This enumeration maps to the values returned by BuildInfo::GetSdkVersion(), |
| 23 // indicating the Android release associated with a given SDK version. |
| 24 // See https://developer.android.com/guide/topics/manifest/uses-sdk-element.html |
| 25 // for details. |
| 26 enum SdkCode { |
| 27 SDK_CODE_JELLY_BEAN = 16, // Android 4.1 |
| 28 SDK_CODE_JELLY_BEAN_MR1 = 17, // Android 4.2 |
| 29 SDK_CODE_JELLY_BEAN_MR2 = 18, // Android 4.3 |
| 30 SDK_CODE_KITKAT = 19, // Android 4.4 |
| 31 SDK_CODE_WATCH = 20, // Android 4.4W |
| 32 SDK_CODE_LOLLIPOP = 21, // Android 5.0 |
| 33 SDK_CODE_LOLLIPOP_MR1 = 22, // Android 5.1 |
| 34 SDK_CODE_MARSHMALLOW = 23, // Android 6.0 |
| 35 SDK_CODE_N = 24, |
| 36 }; |
| 37 |
22 // Utility class used to query the Java class (org/webrtc/voiceengine/BuildInfo) | 38 // Utility class used to query the Java class (org/webrtc/voiceengine/BuildInfo) |
23 // for device and Android build information. | 39 // for device and Android build information. |
24 // The calling thread is attached to the JVM at construction if needed and a | 40 // The calling thread is attached to the JVM at construction if needed and a |
25 // valid Java environment object is also created. | 41 // valid Java environment object is also created. |
26 // All Get methods must be called on the creating thread. If not, the code will | 42 // All Get methods must be called on the creating thread. If not, the code will |
27 // hit RTC_DCHECKs when calling JNIEnvironment::JavaToStdString(). | 43 // hit RTC_DCHECKs when calling JNIEnvironment::JavaToStdString(). |
28 class BuildInfo { | 44 class BuildInfo { |
29 public: | 45 public: |
30 BuildInfo(); | 46 BuildInfo(); |
31 ~BuildInfo() {} | 47 ~BuildInfo() {} |
32 | 48 |
33 // End-user-visible name for the end product (e.g. "Nexus 6"). | 49 // End-user-visible name for the end product (e.g. "Nexus 6"). |
34 std::string GetDeviceModel(); | 50 std::string GetDeviceModel(); |
35 // Consumer-visible brand (e.g. "google"). | 51 // Consumer-visible brand (e.g. "google"). |
36 std::string GetBrand(); | 52 std::string GetBrand(); |
37 // Manufacturer of the product/hardware (e.g. "motorola"). | 53 // Manufacturer of the product/hardware (e.g. "motorola"). |
38 std::string GetDeviceManufacturer(); | 54 std::string GetDeviceManufacturer(); |
39 // Android build ID (e.g. LMY47D). | 55 // Android build ID (e.g. LMY47D). |
40 std::string GetAndroidBuildId(); | 56 std::string GetAndroidBuildId(); |
41 // The type of build (e.g. "user" or "eng"). | 57 // The type of build (e.g. "user" or "eng"). |
42 std::string GetBuildType(); | 58 std::string GetBuildType(); |
43 // The user-visible version string (e.g. "5.1"). | 59 // The user-visible version string (e.g. "5.1"). |
44 std::string GetBuildRelease(); | 60 std::string GetBuildRelease(); |
45 // The user-visible SDK version of the framework (e.g. 21). | 61 // The user-visible SDK version of the framework (e.g. 21). See SdkCode enum |
46 std::string GetSdkVersion(); | 62 // for translation. |
| 63 SdkCode GetSdkVersion(); |
47 | 64 |
48 private: | 65 private: |
49 // Helper method which calls a static getter method with |name| and returns | 66 // Helper method which calls a static getter method with |name| and returns |
50 // a string from Java. | 67 // a string from Java. |
51 std::string GetStringFromJava(const char* name); | 68 std::string GetStringFromJava(const char* name); |
52 | 69 |
53 // Ensures that this class can access a valid JNI interface pointer even | 70 // Ensures that this class can access a valid JNI interface pointer even |
54 // if the creating thread was not attached to the JVM. | 71 // if the creating thread was not attached to the JVM. |
55 AttachCurrentThreadIfNeeded attach_thread_if_needed_; | 72 AttachCurrentThreadIfNeeded attach_thread_if_needed_; |
56 | 73 |
57 // Provides access to the JNIEnv interface pointer and the JavaToStdString() | 74 // Provides access to the JNIEnv interface pointer and the JavaToStdString() |
58 // method which is used to translate Java strings to std strings. | 75 // method which is used to translate Java strings to std strings. |
59 std::unique_ptr<JNIEnvironment> j_environment_; | 76 std::unique_ptr<JNIEnvironment> j_environment_; |
60 | 77 |
61 // Holds the jclass object and provides access to CallStaticObjectMethod(). | 78 // Holds the jclass object and provides access to CallStaticObjectMethod(). |
62 // Used by GetStringFromJava() during construction only. | 79 // Used by GetStringFromJava() during construction only. |
63 JavaClass j_build_info_; | 80 JavaClass j_build_info_; |
64 }; | 81 }; |
65 | 82 |
66 } // namespace webrtc | 83 } // namespace webrtc |
67 | 84 |
68 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_BUILD_INFO_H_ | 85 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_BUILD_INFO_H_ |
OLD | NEW |