Commit a81074e9 authored by Bryan Henry's avatar Bryan Henry Committed by Commit Bot

[Chromecast] Implement CastSysInfoAndroid::GetFactoryLocale

GetFactoryLocale returned set value.
verified GetFactoryLocale returned set value.

Bug: internal b/72610561
Test: Set ro.product.locale through factory partition, verified
Test: Set ro.product.locale.language/region through factory partition,
Test: Left properties unset, verified GetFactoryLocale returned "en-US".
Change-Id: Ia0e48dd77a2825e6eed09d1e04331b713afb32a3
Reviewed-on: https://chromium-review.googlesource.com/889935
Commit-Queue: Bryan Henry <bryanhenry@google.com>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532655}
parent e179c6a2
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "chromecast/base/cast_sys_info_android.h" #include "chromecast/base/cast_sys_info_android.h"
#include <memory>
#include <sys/system_properties.h> #include <sys/system_properties.h>
#include <memory>
#include <string> #include <string>
#include "base/android/build_info.h" #include "base/android/build_info.h"
...@@ -22,12 +22,13 @@ namespace chromecast { ...@@ -22,12 +22,13 @@ namespace chromecast {
namespace { namespace {
const char kBuildTypeUser[] = "user"; const char kBuildTypeUser[] = "user";
std::string GetAndroidProperty(const std::string& key) { std::string GetAndroidProperty(const std::string& key,
const std::string& default_value) {
char value[PROP_VALUE_MAX]; char value[PROP_VALUE_MAX];
int ret = __system_property_get(key.c_str(), value); int ret = __system_property_get(key.c_str(), value);
if (ret < 0) { if (ret <= 0) {
LOG(ERROR) << "Failed to get property: " << key; VLOG(1) << "No value set for property: " << key;
return ""; return default_value;
} }
return std::string(value); return std::string(value);
...@@ -41,11 +42,9 @@ std::unique_ptr<CastSysInfo> CreateSysInfo() { ...@@ -41,11 +42,9 @@ std::unique_ptr<CastSysInfo> CreateSysInfo() {
} }
CastSysInfoAndroid::CastSysInfoAndroid() CastSysInfoAndroid::CastSysInfoAndroid()
: build_info_(base::android::BuildInfo::GetInstance()) { : build_info_(base::android::BuildInfo::GetInstance()) {}
}
CastSysInfoAndroid::~CastSysInfoAndroid() { CastSysInfoAndroid::~CastSysInfoAndroid() {}
}
CastSysInfo::BuildType CastSysInfoAndroid::GetBuildType() { CastSysInfo::BuildType CastSysInfoAndroid::GetBuildType() {
if (CAST_IS_DEBUG_BUILD()) if (CAST_IS_DEBUG_BUILD())
...@@ -107,11 +106,24 @@ std::string CastSysInfoAndroid::GetBoardRevision() { ...@@ -107,11 +106,24 @@ std::string CastSysInfoAndroid::GetBoardRevision() {
} }
std::string CastSysInfoAndroid::GetFactoryCountry() { std::string CastSysInfoAndroid::GetFactoryCountry() {
return GetAndroidProperty("ro.boot.wificountrycode"); return GetAndroidProperty("ro.boot.wificountrycode", "");
} }
std::string CastSysInfoAndroid::GetFactoryLocale(std::string* second_locale) { std::string CastSysInfoAndroid::GetFactoryLocale(std::string* second_locale) {
return ""; // This duplicates the read-only property portion of
// frameworks/base/core/jni/AndroidRuntime.cpp in the Android tree, which is
// effectively the "factory locale", i.e. the locale chosen by Android
// assuming the other persist.sys.* properties are not set.
const std::string locale = GetAndroidProperty("ro.product.locale", "");
if (!locale.empty()) {
return locale;
}
const std::string language =
GetAndroidProperty("ro.product.locale.language", "en");
const std::string region =
GetAndroidProperty("ro.product.locale.region", "US");
return language + "-" + region;
} }
std::string CastSysInfoAndroid::GetWifiInterface() { std::string CastSysInfoAndroid::GetWifiInterface() {
......
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