ProfilePolicyConnectorFactory: Refactoring from Profile to BrowserContext.
[chromium-blink-merge.git] / base / android / build_info.h
blobe4e84e85baa865eb0c8603234864eb234f9f9e72
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_ICE_CREAM_SANDWICH = 14,
22 SDK_VERSION_ICE_CREAM_SANDWICH_MR1 = 15,
23 SDK_VERSION_JELLY_BEAN = 16,
24 SDK_VERSION_JELLY_BEAN_MR1 = 17,
25 SDK_VERSION_JELLY_BEAN_MR2 = 18,
26 SDK_VERSION_KITKAT = 19,
27 SDK_VERSION_KITKAT_WEAR = 20,
28 SDK_VERSION_LOLLIPOP = 21
31 // BuildInfo is a singleton class that stores android build and device
32 // information. It will be called from Android specific code and gets used
33 // primarily in crash reporting.
35 // It is also used to store the last java exception seen during JNI.
36 // TODO(nileshagrawal): Find a better place to store this info.
37 class BASE_EXPORT BuildInfo {
38 public:
40 ~BuildInfo() {}
42 // Static factory method for getting the singleton BuildInfo instance.
43 // Note that ownership is not conferred on the caller and the BuildInfo in
44 // question isn't actually freed until shutdown. This is ok because there
45 // should only be one instance of BuildInfo ever created.
46 static BuildInfo* GetInstance();
48 // Const char* is used instead of std::strings because these values must be
49 // available even if the process is in a crash state. Sadly
50 // std::string.c_str() doesn't guarantee that memory won't be allocated when
51 // it is called.
52 const char* device() const {
53 return device_;
56 const char* manufacturer() const {
57 return manufacturer_;
60 const char* model() const {
61 return model_;
64 const char* brand() const {
65 return brand_;
68 const char* android_build_id() const {
69 return android_build_id_;
72 const char* android_build_fp() const {
73 return android_build_fp_;
76 const char* package_version_code() const {
77 return package_version_code_;
80 const char* package_version_name() const {
81 return package_version_name_;
84 const char* package_label() const {
85 return package_label_;
88 const char* package_name() const {
89 return package_name_;
92 const char* build_type() const {
93 return build_type_;
96 int sdk_int() const {
97 return sdk_int_;
100 const char* java_exception_info() const {
101 return java_exception_info_;
104 void set_java_exception_info(const std::string& info);
106 static bool RegisterBindings(JNIEnv* env);
108 private:
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
116 // it is called.
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_;
128 const int sdk_int_;
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
136 } // namespace base
138 #endif // BASE_ANDROID_BUILD_INFO_H_