Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromecast / base / cast_sys_info_android.cc
blob0d85a06ad82386de3859394bab721ed3ebae132c
1 // Copyright 2015 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 #include "chromecast/base/cast_sys_info_android.h"
7 #include "base/android/build_info.h"
8 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/sys_info.h"
12 #include "chromecast/base/cast_sys_info_util.h"
13 #include "chromecast/base/version.h"
14 #include "jni/CastSysInfoAndroid_jni.h"
16 namespace chromecast {
18 namespace {
19 const char kBuildTypeUser[] = "user";
20 } // namespace
22 // static
23 bool CastSysInfoAndroid::RegisterJni(JNIEnv* env) {
24 return RegisterNativesImpl(env);
27 // static
28 scoped_ptr<CastSysInfo> CreateSysInfo() {
29 return make_scoped_ptr(new CastSysInfoAndroid());
32 CastSysInfoAndroid::CastSysInfoAndroid()
33 : build_info_(base::android::BuildInfo::GetInstance()) {
36 CastSysInfoAndroid::~CastSysInfoAndroid() {
39 CastSysInfo::BuildType CastSysInfoAndroid::GetBuildType() {
40 if (CAST_IS_DEBUG_BUILD())
41 return BUILD_ENG;
43 int build_number;
44 if (!base::StringToInt(CAST_BUILD_INCREMENTAL, &build_number))
45 build_number = 0;
47 // Note: no way to determine which channel was used on play store.
48 if (strcmp(build_info_->build_type(), kBuildTypeUser) == 0 &&
49 build_number > 0) {
50 return BUILD_PRODUCTION;
53 // Dogfooders without a user system build should all still have non-Debug
54 // builds of the cast receiver APK, but with valid build numbers.
55 if (build_number > 0)
56 return BUILD_BETA;
58 // Default to ENG build.
59 return BUILD_ENG;
62 std::string CastSysInfoAndroid::GetSerialNumber() {
63 JNIEnv* env = base::android::AttachCurrentThread();
64 return base::android::ConvertJavaStringToUTF8(
65 Java_CastSysInfoAndroid_getSerialNumber(env));
68 std::string CastSysInfoAndroid::GetProductName() {
69 return build_info_->device();
72 std::string CastSysInfoAndroid::GetDeviceModel() {
73 return build_info_->model();
76 std::string CastSysInfoAndroid::GetManufacturer() {
77 return build_info_->manufacturer();
80 std::string CastSysInfoAndroid::GetSystemBuildNumber() {
81 return base::SysInfo::GetAndroidBuildID();
84 std::string CastSysInfoAndroid::GetSystemReleaseChannel() {
85 return "";
88 std::string CastSysInfoAndroid::GetBoardName() {
89 return "";
92 std::string CastSysInfoAndroid::GetBoardRevision() {
93 return "";
96 std::string CastSysInfoAndroid::GetFactoryCountry() {
97 return "";
100 std::string CastSysInfoAndroid::GetFactoryLocale(std::string* second_locale) {
101 return "";
104 std::string CastSysInfoAndroid::GetWifiInterface() {
105 return "";
108 std::string CastSysInfoAndroid::GetApInterface() {
109 return "";
112 std::string CastSysInfoAndroid::GetGlVendor() {
113 NOTREACHED() << "GL information shouldn't be requested on Android.";
114 return "";
117 std::string CastSysInfoAndroid::GetGlRenderer() {
118 NOTREACHED() << "GL information shouldn't be requested on Android.";
119 return "";
122 std::string CastSysInfoAndroid::GetGlVersion() {
123 NOTREACHED() << "GL information shouldn't be requested on Android.";
124 return "";
127 } // namespace chromecast