1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_ANDROID_BUILD_INFO_H_
6 #define BASE_ANDROID_BUILD_INFO_H_
12 #include "base/base_export.h"
13 #include "base/memory/singleton.h"
18 // This enumeration maps to the values returned by BuildInfo::sdk_int(),
19 // indicating the Android release associated with a given SDK version.
21 SDK_VERSION_JELLY_BEAN
= 16,
22 SDK_VERSION_JELLY_BEAN_MR1
= 17,
23 SDK_VERSION_JELLY_BEAN_MR2
= 18,
24 SDK_VERSION_KITKAT
= 19,
25 SDK_VERSION_KITKAT_WEAR
= 20,
26 SDK_VERSION_LOLLIPOP
= 21
29 // BuildInfo is a singleton class that stores android build and device
30 // information. It will be called from Android specific code and gets used
31 // primarily in crash reporting.
33 // It is also used to store the last java exception seen during JNI.
34 // TODO(nileshagrawal): Find a better place to store this info.
35 class BASE_EXPORT BuildInfo
{
40 // Static factory method for getting the singleton BuildInfo instance.
41 // Note that ownership is not conferred on the caller and the BuildInfo in
42 // question isn't actually freed until shutdown. This is ok because there
43 // should only be one instance of BuildInfo ever created.
44 static BuildInfo
* GetInstance();
46 // Const char* is used instead of std::strings because these values must be
47 // available even if the process is in a crash state. Sadly
48 // std::string.c_str() doesn't guarantee that memory won't be allocated when
50 const char* device() const {
54 const char* manufacturer() const {
58 const char* model() const {
62 const char* brand() const {
66 const char* android_build_id() const {
67 return android_build_id_
;
70 const char* android_build_fp() const {
71 return android_build_fp_
;
74 const char* package_version_code() const {
75 return package_version_code_
;
78 const char* package_version_name() const {
79 return package_version_name_
;
82 const char* package_label() const {
83 return package_label_
;
86 const char* package_name() const {
90 const char* build_type() const {
98 const char* java_exception_info() const {
99 return java_exception_info_
;
102 void SetJavaExceptionInfo(const std::string
& info
);
104 void ClearJavaExceptionInfo();
106 static bool RegisterBindings(JNIEnv
* env
);
109 friend struct BuildInfoSingletonTraits
;
111 explicit BuildInfo(JNIEnv
* env
);
113 // Const char* is used instead of std::strings because these values must be
114 // available even if the process is in a crash state. Sadly
115 // std::string.c_str() doesn't guarantee that memory won't be allocated when
117 const char* const device_
;
118 const char* const manufacturer_
;
119 const char* const model_
;
120 const char* const brand_
;
121 const char* const android_build_id_
;
122 const char* const android_build_fp_
;
123 const char* const package_version_code_
;
124 const char* const package_version_name_
;
125 const char* const package_label_
;
126 const char* const package_name_
;
127 const char* const build_type_
;
129 // This is set via set_java_exception_info, not at constructor time.
130 const char* java_exception_info_
;
132 DISALLOW_COPY_AND_ASSIGN(BuildInfo
);
135 } // namespace android
138 #endif // BASE_ANDROID_BUILD_INFO_H_