Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: base/android/build_info.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/android/base_jni_registrar.cc ('k') | base/android/build_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
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
12 #include "base/base_export.h"
13 #include "base/memory/singleton.h"
14
15 namespace base {
16 namespace android {
17
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,
27 SDK_VERSION_LOLLIPOP_MR1 = 22
28 };
29
30 // BuildInfo is a singleton class that stores android build and device
31 // information. It will be called from Android specific code and gets used
32 // primarily in crash reporting.
33
34 // It is also used to store the last java exception seen during JNI.
35 // TODO(nileshagrawal): Find a better place to store this info.
36 class BASE_EXPORT BuildInfo {
37 public:
38
39 ~BuildInfo() {}
40
41 // Static factory method for getting the singleton BuildInfo instance.
42 // Note that ownership is not conferred on the caller and the BuildInfo in
43 // question isn't actually freed until shutdown. This is ok because there
44 // should only be one instance of BuildInfo ever created.
45 static BuildInfo* GetInstance();
46
47 // Const char* is used instead of std::strings because these values must be
48 // available even if the process is in a crash state. Sadly
49 // std::string.c_str() doesn't guarantee that memory won't be allocated when
50 // it is called.
51 const char* device() const {
52 return device_;
53 }
54
55 const char* manufacturer() const {
56 return manufacturer_;
57 }
58
59 const char* model() const {
60 return model_;
61 }
62
63 const char* brand() const {
64 return brand_;
65 }
66
67 const char* android_build_id() const {
68 return android_build_id_;
69 }
70
71 const char* android_build_fp() const {
72 return android_build_fp_;
73 }
74
75 const char* package_version_code() const {
76 return package_version_code_;
77 }
78
79 const char* package_version_name() const {
80 return package_version_name_;
81 }
82
83 const char* package_label() const {
84 return package_label_;
85 }
86
87 const char* package_name() const {
88 return package_name_;
89 }
90
91 const char* build_type() const {
92 return build_type_;
93 }
94
95 int sdk_int() const {
96 return sdk_int_;
97 }
98
99 int has_language_apk_splits() const { return has_language_apk_splits_; }
100
101 const char* java_exception_info() const {
102 return java_exception_info_;
103 }
104
105 void SetJavaExceptionInfo(const std::string& info);
106
107 void ClearJavaExceptionInfo();
108
109 static bool RegisterBindings(JNIEnv* env);
110
111 private:
112 friend struct BuildInfoSingletonTraits;
113
114 explicit BuildInfo(JNIEnv* env);
115
116 // Const char* is used instead of std::strings because these values must be
117 // available even if the process is in a crash state. Sadly
118 // std::string.c_str() doesn't guarantee that memory won't be allocated when
119 // it is called.
120 const char* const device_;
121 const char* const manufacturer_;
122 const char* const model_;
123 const char* const brand_;
124 const char* const android_build_id_;
125 const char* const android_build_fp_;
126 const char* const package_version_code_;
127 const char* const package_version_name_;
128 const char* const package_label_;
129 const char* const package_name_;
130 const char* const build_type_;
131 const int sdk_int_;
132 const bool has_language_apk_splits_;
133 // This is set via set_java_exception_info, not at constructor time.
134 const char* java_exception_info_;
135
136 DISALLOW_COPY_AND_ASSIGN(BuildInfo);
137 };
138
139 } // namespace android
140 } // namespace base
141
142 #endif // BASE_ANDROID_BUILD_INFO_H_
OLDNEW
« no previous file with comments | « base/android/base_jni_registrar.cc ('k') | base/android/build_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698