Commit e860606d authored by gunsch's avatar gunsch Committed by Commit bot

Chromecast: adds Android implementation of CastSysInfo.

R=lcwu@chromium.org,halliwell@chromium.org

Review URL: https://codereview.chromium.org/1132663004

Cr-Commit-Position: refs/heads/master@{#330595}
parent b8022f1a
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_registrar.h" #include "base/android/jni_registrar.h"
#include "chromecast/android/cast_metrics_helper_android.h" #include "chromecast/android/cast_metrics_helper_android.h"
#include "chromecast/base/cast_sys_info_android.h"
#include "chromecast/browser/android/cast_window_android.h" #include "chromecast/browser/android/cast_window_android.h"
#include "chromecast/browser/android/cast_window_manager.h" #include "chromecast/browser/android/cast_window_manager.h"
#include "chromecast/crash/android/crash_handler.h" #include "chromecast/crash/android/crash_handler.h"
...@@ -19,6 +20,7 @@ namespace { ...@@ -19,6 +20,7 @@ namespace {
static base::android::RegistrationMethod kMethods[] = { static base::android::RegistrationMethod kMethods[] = {
{ "CastMetricsHelperAndroid", CastMetricsHelperAndroid::RegisterJni }, { "CastMetricsHelperAndroid", CastMetricsHelperAndroid::RegisterJni },
{ "CastSysInfoAndroid", CastSysInfoAndroid::RegisterJni },
{ "CastWindowAndroid", shell::CastWindowAndroid::RegisterJni }, { "CastWindowAndroid", shell::CastWindowAndroid::RegisterJni },
{ "CastWindowManager", shell::RegisterCastWindowManager }, { "CastWindowManager", shell::RegisterCastWindowManager },
{ "CrashHandler", CrashHandler::RegisterCastCrashJni }, { "CrashHandler", CrashHandler::RegisterCastCrashJni },
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/base/cast_sys_info_android.h"
#include "base/android/build_info.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/strings/string_number_conversions.h"
#include "base/sys_info.h"
#include "chromecast/base/cast_sys_info_util.h"
#include "chromecast/base/version.h"
#include "jni/CastSysInfoAndroid_jni.h"
namespace chromecast {
namespace {
const char kBuildTypeUser[] = "user";
} // namespace
// static
bool CastSysInfoAndroid::RegisterJni(JNIEnv* env) {
return RegisterNativesImpl(env);
}
// static
scoped_ptr<CastSysInfo> CreateSysInfo() {
return make_scoped_ptr(new CastSysInfoAndroid());
}
CastSysInfoAndroid::CastSysInfoAndroid()
: build_info_(base::android::BuildInfo::GetInstance()) {
}
CastSysInfoAndroid::~CastSysInfoAndroid() {
}
CastSysInfo::BuildType CastSysInfoAndroid::GetBuildType() {
if (CAST_IS_DEBUG_BUILD())
return BUILD_ENG;
int build_number;
if (!base::StringToInt(CAST_BUILD_INCREMENTAL, &build_number))
build_number = 0;
// Note: no way to determine which channel was used on play store.
if (strcmp(build_info_->build_type(), kBuildTypeUser) == 0 &&
build_number > 0) {
return BUILD_PRODUCTION;
}
// Dogfooders without a user system build should all still have non-Debug
// builds of the cast receiver APK, but with valid build numbers.
if (build_number > 0)
return BUILD_BETA;
// Default to ENG build.
return BUILD_ENG;
}
std::string CastSysInfoAndroid::GetSerialNumber() {
JNIEnv* env = base::android::AttachCurrentThread();
return base::android::ConvertJavaStringToUTF8(
Java_CastSysInfoAndroid_getSerialNumber(env));
}
std::string CastSysInfoAndroid::GetProductName() {
return build_info_->device();
}
std::string CastSysInfoAndroid::GetDeviceModel() {
return build_info_->model();
}
std::string CastSysInfoAndroid::GetManufacturer() {
return build_info_->manufacturer();
}
std::string CastSysInfoAndroid::GetSystemBuildNumber() {
return base::SysInfo::GetAndroidBuildID();
}
std::string CastSysInfoAndroid::GetSystemReleaseChannel() {
return "";
}
std::string CastSysInfoAndroid::GetBoardName() {
return "";
}
std::string CastSysInfoAndroid::GetBoardRevision() {
return "";
}
std::string CastSysInfoAndroid::GetFactoryCountry() {
return "";
}
std::string CastSysInfoAndroid::GetFactoryLocale(std::string* second_locale) {
return "";
}
std::string CastSysInfoAndroid::GetWifiInterface() {
return "";
}
std::string CastSysInfoAndroid::GetApInterface() {
return "";
}
std::string CastSysInfoAndroid::GetGlVendor() {
NOTREACHED() << "GL information shouldn't be requested on Android.";
return "";
}
std::string CastSysInfoAndroid::GetGlRenderer() {
NOTREACHED() << "GL information shouldn't be requested on Android.";
return "";
}
std::string CastSysInfoAndroid::GetGlVersion() {
NOTREACHED() << "GL information shouldn't be requested on Android.";
return "";
}
} // namespace chromecast
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BASE_CAST_SYS_INFO_ANDROID_H_
#define CHROMECAST_BASE_CAST_SYS_INFO_ANDROID_H_
#include <jni.h>
#include "base/macros.h"
#include "chromecast/public/cast_sys_info.h"
namespace base {
namespace android {
class BuildInfo;
}
}
namespace chromecast {
class CastSysInfoAndroid : public CastSysInfo {
public:
static bool RegisterJni(JNIEnv* env);
CastSysInfoAndroid();
~CastSysInfoAndroid() override;
// CastSysInfo implementation:
BuildType GetBuildType() override;
std::string GetSerialNumber() override;
std::string GetProductName() override;
std::string GetDeviceModel() override;
std::string GetManufacturer() override;
std::string GetSystemBuildNumber() override;
std::string GetSystemReleaseChannel() override;
std::string GetBoardName() override;
std::string GetBoardRevision() override;
std::string GetFactoryCountry() override;
std::string GetFactoryLocale(std::string* second_locale) override;
std::string GetWifiInterface() override;
std::string GetApInterface() override;
std::string GetGlVendor() override;
std::string GetGlRenderer() override;
std::string GetGlVersion() override;
// Native implementation of Java methods.
void DeviceNameChanged(JNIEnv* env, jobject obj, jstring device_name);
private:
const base::android::BuildInfo* const build_info_;
DISALLOW_COPY_AND_ASSIGN(CastSysInfoAndroid);
};
} // namespace chromecast
#endif // CHROMECAST_BASE_CAST_SYS_INFO_ANDROID_H_
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
// version.h is generated from version.h.in. Edit the source! // version.h is generated from version.h.in. Edit the source!
#ifndef CHROMECAST_COMMON_VERSION_INFO_H_ #ifndef CHROMECAST_BASE_VERSION_INFO_H_
#define CHROMECAST_COMMON_VERSION_INFO_H_ #define CHROMECAST_BASE_VERSION_INFO_H_
#define PRODUCT_VERSION "@VERSION_FULL@" #define PRODUCT_VERSION "@VERSION_FULL@"
#define CAST_BUILD_INCREMENTAL "@CAST_BUILD_INCREMENTAL@" #define CAST_BUILD_INCREMENTAL "@CAST_BUILD_INCREMENTAL@"
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
#define CAST_IS_DEBUG_BUILD() @CAST_IS_DEBUG_BUILD@ #define CAST_IS_DEBUG_BUILD() @CAST_IS_DEBUG_BUILD@
#define CAST_PRODUCT_TYPE @CAST_PRODUCT_TYPE@ #define CAST_PRODUCT_TYPE @CAST_PRODUCT_TYPE@
#endif // CHROMECAST_COMMON_VERSION_INFO_H_ #endif // CHROMECAST_BASE_VERSION_INFO_H_
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chromecast.shell;
import android.os.Build;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
/**
* Java implementation of CastSysInfoAndroid methods.
*/
@JNINamespace("chromecast")
public final class CastSysInfoAndroid {
private static final String TAG = "CastSysInfoAndroid";
@CalledByNative
private static String getSerialNumber() {
return Build.SERIAL;
}
}
...@@ -274,6 +274,7 @@ int CastBrowserMainParts::PreCreateThreads() { ...@@ -274,6 +274,7 @@ int CastBrowserMainParts::PreCreateThreads() {
} }
void CastBrowserMainParts::PreMainMessageLoopRun() { void CastBrowserMainParts::PreMainMessageLoopRun() {
#if !defined(OS_ANDROID)
// Set GL strings so GPU config code can make correct feature blacklisting/ // Set GL strings so GPU config code can make correct feature blacklisting/
// whitelisting decisions. // whitelisting decisions.
// Note: SetGLStrings MUST be called after GpuDataManager::Initialize. // Note: SetGLStrings MUST be called after GpuDataManager::Initialize.
...@@ -281,6 +282,7 @@ void CastBrowserMainParts::PreMainMessageLoopRun() { ...@@ -281,6 +282,7 @@ void CastBrowserMainParts::PreMainMessageLoopRun() {
content::GpuDataManager::GetInstance()->SetGLStrings( content::GpuDataManager::GetInstance()->SetGLStrings(
sys_info->GetGlVendor(), sys_info->GetGlRenderer(), sys_info->GetGlVendor(), sys_info->GetGlRenderer(),
sys_info->GetGlVersion()); sys_info->GetGlVersion());
#endif // !defined(OS_ANDROID)
scoped_refptr<PrefRegistrySimple> pref_registry(new PrefRegistrySimple()); scoped_refptr<PrefRegistrySimple> pref_registry(new PrefRegistrySimple());
metrics::RegisterPrefs(pref_registry.get()); metrics::RegisterPrefs(pref_registry.get());
......
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
'base/cast_sys_info_dummy.h', 'base/cast_sys_info_dummy.h',
], ],
'conditions': [ 'conditions': [
['chromecast_branding!="Chrome"', { ['chromecast_branding!="Chrome" and OS!="android"', {
'sources': [ 'sources': [
'base/cast_sys_info_util_simple.cc', 'base/cast_sys_info_util_simple.cc',
], ],
...@@ -375,10 +375,10 @@ ...@@ -375,10 +375,10 @@
'message': 'Generating version header file: <@(_outputs)', 'message': 'Generating version header file: <@(_outputs)',
'inputs': [ 'inputs': [
'<(version_path)', '<(version_path)',
'common/version.h.in', 'base/version.h.in',
], ],
'outputs': [ 'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/chromecast/common/version.h', '<(SHARED_INTERMEDIATE_DIR)/chromecast/base/version.h',
], ],
'action': [ 'action': [
'python', 'python',
...@@ -392,7 +392,7 @@ ...@@ -392,7 +392,7 @@
'-e', 'CAST_BUILD_RELEASE="<!(if test -f <(cast_build_release); then cat <(cast_build_release); else echo eng.${USER}; fi)"', '-e', 'CAST_BUILD_RELEASE="<!(if test -f <(cast_build_release); then cat <(cast_build_release); else echo eng.${USER}; fi)"',
'-e', 'CAST_IS_DEBUG_BUILD=1 if "<(CONFIGURATION_NAME)" == "Debug" or <(cast_is_debug_build) == 1 else 0', '-e', 'CAST_IS_DEBUG_BUILD=1 if "<(CONFIGURATION_NAME)" == "Debug" or <(cast_is_debug_build) == 1 else 0',
'-e', 'CAST_PRODUCT_TYPE=<(cast_product_type)', '-e', 'CAST_PRODUCT_TYPE=<(cast_product_type)',
'common/version.h.in', 'base/version.h.in',
'<@(_outputs)', '<@(_outputs)',
], ],
'includes': [ 'includes': [
...@@ -446,6 +446,8 @@ ...@@ -446,6 +446,8 @@
'../breakpad/src', '../breakpad/src',
], ],
'sources': [ 'sources': [
'base/cast_sys_info_android.cc',
'base/cast_sys_info_android.h',
'android/cast_jni_registrar.cc', 'android/cast_jni_registrar.cc',
'android/cast_jni_registrar.h', 'android/cast_jni_registrar.h',
'android/cast_metrics_helper_android.cc', 'android/cast_metrics_helper_android.cc',
...@@ -535,6 +537,7 @@ ...@@ -535,6 +537,7 @@
'sources': [ 'sources': [
'browser/android/apk/src/org/chromium/chromecast/shell/CastCrashHandler.java', 'browser/android/apk/src/org/chromium/chromecast/shell/CastCrashHandler.java',
'browser/android/apk/src/org/chromium/chromecast/shell/CastMetricsHelper.java', 'browser/android/apk/src/org/chromium/chromecast/shell/CastMetricsHelper.java',
'browser/android/apk/src/org/chromium/chromecast/shell/CastSysInfoAndroid.java',
'browser/android/apk/src/org/chromium/chromecast/shell/CastWindowAndroid.java', 'browser/android/apk/src/org/chromium/chromecast/shell/CastWindowAndroid.java',
'browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java', 'browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java',
], ],
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "chromecast/common/version.h" #include "chromecast/base/version.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "chromecast/android/chromecast_config_android.h" #include "chromecast/android/chromecast_config_android.h"
#include "chromecast/base/version.h"
#include "chromecast/common/global_descriptors.h" #include "chromecast/common/global_descriptors.h"
#include "chromecast/common/version.h"
#include "chromecast/crash/cast_crash_keys.h" #include "chromecast/crash/cast_crash_keys.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "breakpad/src/client/linux/handler/exception_handler.h" #include "breakpad/src/client/linux/handler/exception_handler.h"
#include "breakpad/src/client/linux/handler/minidump_descriptor.h" #include "breakpad/src/client/linux/handler/minidump_descriptor.h"
#include "chromecast/common/version.h" #include "chromecast/base/version.h"
#include "chromecast/crash/android/cast_crash_reporter_client_android.h" #include "chromecast/crash/android/cast_crash_reporter_client_android.h"
#include "components/crash/app/breakpad_linux.h" #include "components/crash/app/breakpad_linux.h"
#include "components/crash/app/crash_reporter_client.h" #include "components/crash/app/crash_reporter_client.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment