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