Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / android / build_info.h
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_ANDROID_BUILD_INFO_H_
6 #define BASE_ANDROID_BUILD_INFO_H_
7
8 #include <jni.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/base_export.h"
14 #include "base/memory/singleton.h"
15
16 namespace base {
17 namespace android {
18
19 // This enumeration maps to the values returned by BuildInfo::sdk_int(),
20 // indicating the Android release associated with a given SDK version.
21 enum SdkVersion {
22   SDK_VERSION_JELLY_BEAN = 16,
23   SDK_VERSION_JELLY_BEAN_MR1 = 17,
24   SDK_VERSION_JELLY_BEAN_MR2 = 18,
25   SDK_VERSION_KITKAT = 19,
26   SDK_VERSION_KITKAT_WEAR = 20,
27   SDK_VERSION_LOLLIPOP = 21,
28   SDK_VERSION_LOLLIPOP_MR1 = 22,
29   SDK_VERSION_MARSHMALLOW = 23,
30   SDK_VERSION_NOUGAT = 24,
31   SDK_VERSION_NOUGAT_MR1 = 25,
32   SDK_VERSION_OREO = 26,
33   SDK_VERSION_O_MR1 = 27,
34   SDK_VERSION_P = 28,
35   SDK_VERSION_Q = 29,
36   SDK_VERSION_R = 30,
37   SDK_VERSION_S = 31,
38   SDK_VERSION_Sv2 = 32,
39   SDK_VERSION_T = 33,
40 };
41
42 // BuildInfo is a singleton class that stores android build and device
43 // information. It will be called from Android specific code and gets used
44 // primarily in crash reporting.
45 class BASE_EXPORT BuildInfo {
46  public:
47   BuildInfo(const BuildInfo&) = delete;
48   BuildInfo& operator=(const BuildInfo&) = delete;
49
50   ~BuildInfo() {}
51
52   // Static factory method for getting the singleton BuildInfo instance.
53   // Note that ownership is not conferred on the caller and the BuildInfo in
54   // question isn't actually freed until shutdown. This is ok because there
55   // should only be one instance of BuildInfo ever created.
56   static BuildInfo* GetInstance();
57
58   // Const char* is used instead of std::strings because these values must be
59   // available even if the process is in a crash state. Sadly
60   // std::string.c_str() doesn't guarantee that memory won't be allocated when
61   // it is called.
62   const char* device() const {
63     return device_;
64   }
65
66   const char* manufacturer() const {
67     return manufacturer_;
68   }
69
70   const char* model() const {
71     return model_;
72   }
73
74   const char* brand() const {
75     return brand_;
76   }
77
78   const char* android_build_id() const {
79     return android_build_id_;
80   }
81
82   const char* android_build_fp() const {
83     return android_build_fp_;
84   }
85
86   const char* gms_version_code() const {
87     return gms_version_code_;
88   }
89
90   // The package name of the host app which has loaded WebView, retrieved from
91   // the application context. In the context of the SDK Runtime, the package
92   // name of the app that owns this particular instance of the SDK Runtime will
93   // also be included. e.g.
94   // com.google.android.sdksandbox:com:com.example.myappwithads
95   const char* host_package_name() const { return host_package_name_; }
96
97   // The application name (e.g. "Chrome"). For WebView, this is name of the
98   // embedding app. In the context of the SDK Runtime, this is the name of the
99   // app that owns this particular instance of the SDK Runtime.
100   const char* host_version_code() const { return host_version_code_; }
101
102   // By default: same as versionCode. For WebView: versionCode of the embedding
103   // app. In the context of the SDK Runtime, this is the versionCode of the app
104   // that owns this particular instance of the SDK Runtime.
105   const char* host_package_label() const { return host_package_label_; }
106
107   const char* package_version_code() const {
108     return package_version_code_;
109   }
110
111   const char* package_version_name() const {
112     return package_version_name_;
113   }
114
115   const char* package_name() const {
116     return package_name_;
117   }
118
119   const char* custom_themes() const { return custom_themes_; }
120
121   const char* resources_version() const { return resources_version_; }
122
123   const char* build_type() const {
124     return build_type_;
125   }
126
127   const char* board() const { return board_; }
128
129   const char* installer_package_name() const { return installer_package_name_; }
130
131   const char* abi_name() const { return abi_name_; }
132
133   int sdk_int() const {
134     return sdk_int_;
135   }
136
137   // Returns the targetSdkVersion of the currently running app. If called from a
138   // library, this returns the embedding app's targetSdkVersion.
139   //
140   // This can only be compared to finalized SDK versions, never against
141   // pre-release Android versions. For pre-release Android versions, see the
142   // targetsAtLeast*() methods in BuildInfo.java.
143   int target_sdk_version() const { return target_sdk_version_; }
144
145   bool is_debug_android() const { return is_debug_android_; }
146
147   bool is_tv() const { return is_tv_; }
148
149   const char* version_incremental() const { return version_incremental_; }
150
151   const char* hardware() const { return hardware_; }
152
153   bool is_at_least_t() const { return is_at_least_t_; }
154
155   bool is_automotive() const { return is_automotive_; }
156
157   bool is_at_least_u() const { return is_at_least_u_; }
158
159   bool targets_at_least_u() const { return targets_at_least_u_; }
160
161   const char* codename() const { return codename_; }
162
163   // Available only on Android T+.
164   int32_t vulkan_deqp_level() const { return vulkan_deqp_level_; }
165
166  private:
167   friend struct BuildInfoSingletonTraits;
168
169   explicit BuildInfo(const std::vector<std::string>& params);
170
171   // Const char* is used instead of std::strings because these values must be
172   // available even if the process is in a crash state. Sadly
173   // std::string.c_str() doesn't guarantee that memory won't be allocated when
174   // it is called.
175   const char* const brand_;
176   const char* const device_;
177   const char* const android_build_id_;
178   const char* const manufacturer_;
179   const char* const model_;
180   const int sdk_int_;
181   const char* const build_type_;
182   const char* const board_;
183   const char* const host_package_name_;
184   const char* const host_version_code_;
185   const char* const host_package_label_;
186   const char* const package_name_;
187   const char* const package_version_code_;
188   const char* const package_version_name_;
189   const char* const android_build_fp_;
190   const char* const gms_version_code_;
191   const char* const installer_package_name_;
192   const char* const abi_name_;
193   const char* const custom_themes_;
194   const char* const resources_version_;
195   // Not needed by breakpad.
196   const int target_sdk_version_;
197   const bool is_debug_android_;
198   const bool is_tv_;
199   const char* const version_incremental_;
200   const char* const hardware_;
201   const bool is_at_least_t_;
202   const bool is_automotive_;
203   const bool is_at_least_u_;
204   const bool targets_at_least_u_;
205   const char* const codename_;
206   const int32_t vulkan_deqp_level_;
207 };
208
209 }  // namespace android
210 }  // namespace base
211
212 #endif  // BASE_ANDROID_BUILD_INFO_H_