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 set_java_exception_info(const std::string
& info
);
104 static bool RegisterBindings(JNIEnv
* env
);
107 friend struct BuildInfoSingletonTraits
;
109 explicit BuildInfo(JNIEnv
* env
);
111 // Const char* is used instead of std::strings because these values must be
112 // available even if the process is in a crash state. Sadly
113 // std::string.c_str() doesn't guarantee that memory won't be allocated when
115 const char* const device_
;
116 const char* const manufacturer_
;
117 const char* const model_
;
118 const char* const brand_
;
119 const char* const android_build_id_
;
120 const char* const android_build_fp_
;
121 const char* const package_version_code_
;
122 const char* const package_version_name_
;
123 const char* const package_label_
;
124 const char* const package_name_
;
125 const char* const build_type_
;
127 // This is set via set_java_exception_info, not at constructor time.
128 const char* java_exception_info_
;
130 DISALLOW_COPY_AND_ASSIGN(BuildInfo
);
133 } // namespace android
136 #endif // BASE_ANDROID_BUILD_INFO_H_