OLD | NEW |
| (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/memory/singleton.h" | |
13 | |
14 namespace base { | |
15 namespace android { | |
16 | |
17 // BuildInfo is a singleton class that stores android build and device | |
18 // information. | |
19 class BuildInfo { | |
20 public: | |
21 | |
22 ~BuildInfo() {} | |
23 | |
24 // Static factory method for getting the singleton BuildInfo instance. | |
25 // Note that ownership is not conferred on the caller and the BuildInfo in | |
26 // question isn't actually freed until shutdown. This is ok because there | |
27 // should only be one instance of BuildInfo ever created. | |
28 static BuildInfo* GetInstance(); | |
29 | |
30 // Const char* is used instead of std::strings because these values must be | |
31 // available even if the process is in a crash state. Sadly | |
32 // std::string.c_str() doesn't guarantee that memory won't be allocated when | |
33 // it is called. | |
34 const char* device() const { | |
35 return device_; | |
36 } | |
37 | |
38 const char* model() const { | |
39 return model_; | |
40 } | |
41 | |
42 const char* brand() const { | |
43 return brand_; | |
44 } | |
45 | |
46 const char* android_build_id() const { | |
47 return android_build_id_; | |
48 } | |
49 | |
50 const char* android_build_fp() const { | |
51 return android_build_fp_; | |
52 } | |
53 | |
54 const char* package_version_code() const { | |
55 return package_version_code_; | |
56 } | |
57 | |
58 const char* package_version_name() const { | |
59 return package_version_name_; | |
60 } | |
61 | |
62 private: | |
63 BuildInfo(); | |
64 | |
65 friend struct DefaultSingletonTraits<BuildInfo>; | |
66 | |
67 // Const char* is used instead of std::strings because these values must be | |
68 // available even if the process is in a crash state. Sadly | |
69 // std::string.c_str() doesn't guarantee that memory won't be allocated when | |
70 // it is called. | |
71 char* device_; | |
72 char* model_; | |
73 char* brand_; | |
74 char* android_build_id_; | |
75 char* android_build_fp_; | |
76 char* package_version_code_; | |
77 char* package_version_name_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(BuildInfo); | |
80 | |
81 }; | |
82 | |
83 bool RegisterBuildInfo(JNIEnv* env); | |
84 | |
85 } // namespace android | |
86 } // namespace base | |
87 | |
88 #endif // BASE_ANDROID_BUILD_INFO_H_ | |
OLD | NEW |