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
{
19 const char kBuildTypeUser
[] = "user";
23 bool CastSysInfoAndroid::RegisterJni(JNIEnv
* env
) {
24 return RegisterNativesImpl(env
);
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())
44 if (!base::StringToInt(CAST_BUILD_INCREMENTAL
, &build_number
))
47 // Note: no way to determine which channel was used on play store.
48 if (strcmp(build_info_
->build_type(), kBuildTypeUser
) == 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.
58 // Default to ENG build.
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() {
88 std::string
CastSysInfoAndroid::GetBoardName() {
92 std::string
CastSysInfoAndroid::GetBoardRevision() {
96 std::string
CastSysInfoAndroid::GetFactoryCountry() {
100 std::string
CastSysInfoAndroid::GetFactoryLocale(std::string
* second_locale
) {
104 std::string
CastSysInfoAndroid::GetWifiInterface() {
108 std::string
CastSysInfoAndroid::GetApInterface() {
112 std::string
CastSysInfoAndroid::GetGlVendor() {
113 NOTREACHED() << "GL information shouldn't be requested on Android.";
117 std::string
CastSysInfoAndroid::GetGlRenderer() {
118 NOTREACHED() << "GL information shouldn't be requested on Android.";
122 std::string
CastSysInfoAndroid::GetGlVersion() {
123 NOTREACHED() << "GL information shouldn't be requested on Android.";
127 } // namespace chromecast