Update {virtual,override} to follow C++11 style in ipc.
[chromium-blink-merge.git] / base / android / build_info.h
blob9d73bdbc9c6601904007d4d08786d28d99756b34
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_
8 #include <jni.h>
10 #include <string>
12 #include "base/base_export.h"
13 #include "base/memory/singleton.h"
15 namespace base {
16 namespace android {
18 // This enumeration maps to the values returned by BuildInfo::sdk_int(),
19 // indicating the Android release associated with a given SDK version.
20 enum SdkVersion {
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 {
36 public:
38 ~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
49 // it is called.
50 const char* device() const {
51 return device_;
54 const char* manufacturer() const {
55 return manufacturer_;
58 const char* model() const {
59 return model_;
62 const char* brand() const {
63 return brand_;
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 {
87 return package_name_;
90 const char* build_type() const {
91 return build_type_;
94 int sdk_int() const {
95 return sdk_int_;
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);
106 private:
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
114 // it is called.
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_;
126 const int sdk_int_;
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
134 } // namespace base
136 #endif // BASE_ANDROID_BUILD_INFO_H_