Skip to content

Commit 1aed23c

Browse files
authored
Populate the missing fields in the UA string (#7085)
Populate the missing fields for the 3P UA string using the starboard system properties. Remove is_robolectric from starboard/build/config/os_definitions.gni as it is in conflict with build/toolchain/android/BUILD.gn. Issue: 437414261
1 parent d489e03 commit 1aed23c

File tree

9 files changed

+41
-42
lines changed

9 files changed

+41
-42
lines changed

base/BUILD.gn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,8 @@ component("base") {
22912291
"system/sys_info_starboard.cc",
22922292
"system/sys_info_starboard.h",
22932293
]
2294+
2295+
deps += [ "//starboard/common:common_headers_only" ]
22942296
}
22952297

22962298
if (use_blink) {
@@ -5054,7 +5056,7 @@ source_set("partition_alloc_test_support") {
50545056
}
50555057

50565058
if (enable_cobalt_hermetic_hacks) {
5057-
# TODO: b/413130400 - Cobalt: Remove this config
5059+
# TODO: b/413130400 - Cobalt: Remove this config
50585060
# after removing base/starboard/linker_stub.h
50595061
config("base_starboard_linker_stub") {
50605062
cflags = ["-Wno-unreachable-code-break"]

base/system/sys_info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool SysInfo::IsLowEndDeviceImpl() {
141141
#endif
142142

143143
#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_WIN) && \
144-
!BUILDFLAG(IS_CHROMEOS)
144+
!BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_STARBOARD)
145145
std::string SysInfo::HardwareModelName() {
146146
return std::string();
147147
}

base/system/sys_info_starboard.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@
1818

1919
#if BUILDFLAG(IS_ANDROID)
2020
#include <sys/system_properties.h>
21-
#else
22-
// TODO(b/374213479): Remove after the functions below are implemented.
23-
#include "base/notreached.h"
21+
#elif BUILDFLAG(IS_STARBOARD)
22+
#include "base/system/sys_info.h"
23+
#include "starboard/common/system_property.h"
24+
using starboard::GetSystemPropertyString;
2425
#endif // BUILDFLAG(IS_ANDROID)
2526

27+
#if BUILDFLAG(IS_STARBOARD)
28+
namespace base {
29+
std::string SysInfo::HardwareModelName() {
30+
return GetSystemPropertyString(kSbSystemPropertyModelName);
31+
}
32+
}
33+
#endif // BUILDFLAG(IS_STARBOARD)
2634
namespace base {
2735
namespace starboard {
2836

@@ -64,29 +72,21 @@ std::string SbSysInfo::Brand() {
6472
__system_property_get("ro.product.brand", brand_str);
6573
return std::string(brand_str);
6674
}
67-
#else
75+
#elif BUILDFLAG(IS_STARBOARD)
6876
std::string SbSysInfo::OriginalDesignManufacturer() {
69-
// TODO(b/374213479): Implement for non-Android.
70-
NOTIMPLEMENTED();
71-
return "";
77+
return GetSystemPropertyString(kSbSystemPropertySystemIntegratorName);
7278
}
7379

7480
std::string SbSysInfo::ChipsetModelNumber() {
75-
// TODO(b/374213479): Implement for non-Android.
76-
NOTIMPLEMENTED();
77-
return "";
81+
return GetSystemPropertyString(kSbSystemPropertyChipsetModelNumber);
7882
}
7983

8084
std::string SbSysInfo::ModelYear() {
81-
// TODO(b/374213479): Implement for non-Android.
82-
NOTIMPLEMENTED();
83-
return "";
85+
return GetSystemPropertyString(kSbSystemPropertyModelYear);
8486
}
8587

8688
std::string SbSysInfo::Brand() {
87-
// TODO(b/374213479): Implement for non-Android.
88-
NOTIMPLEMENTED();
89-
return "";
89+
return GetSystemPropertyString(kSbSystemPropertyBrandName);
9090
}
9191
#endif // BUILDFLAG(IS_ANDROID)
9292

base/time/time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ class BASE_EXPORT ThreadTicks : public time_internal::TimeBase<ThreadTicks> {
12431243
// Returns true if ThreadTicks::Now() is supported on this system.
12441244
[[nodiscard]] static bool IsSupported() {
12451245
#if BUILDFLAG(IS_STARBOARD)
1246-
return starboard::CurrentMonotonicThreadTime() != 0;
1246+
return ::starboard::CurrentMonotonicThreadTime() != 0;
12471247
#elif (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \
12481248
BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA)
12491249
return true;

cobalt/browser/cobalt_content_browser_client.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "cobalt/shell/browser/shell.h"
3838
#include "cobalt/shell/browser/shell_paths.h"
3939
#include "cobalt/shell/common/shell_switches.h"
40+
#include "cobalt/version.h"
4041
#include "components/metrics/metrics_state_manager.h"
4142
#include "components/metrics_services_manager/metrics_services_manager.h"
4243
#include "components/prefs/pref_registry_simple.h"
@@ -90,15 +91,12 @@ std::string GetCobaltUserAgent() {
9091

9192
blink::UserAgentMetadata GetCobaltUserAgentMetadata() {
9293
blink::UserAgentMetadata metadata;
93-
94-
#define COBALT_BRAND_NAME "Cobalt"
95-
#define COBALT_MAJOR_VERSION "26"
96-
#define COBALT_VERSION "26.lts.0-qa"
97-
metadata.brand_version_list.emplace_back(COBALT_BRAND_NAME,
94+
const UserAgentPlatformInfo platform_info;
95+
metadata.brand_version_list.emplace_back(platform_info.brand().value_or(""),
9896
COBALT_MAJOR_VERSION);
99-
metadata.brand_full_version_list.emplace_back(COBALT_BRAND_NAME,
100-
COBALT_VERSION);
101-
metadata.full_version = COBALT_VERSION;
97+
metadata.brand_full_version_list.emplace_back(
98+
platform_info.brand().value_or(""), platform_info.cobalt_version());
99+
metadata.full_version = platform_info.cobalt_version();
102100
metadata.platform = "Starboard";
103101
metadata.architecture = content::GetCpuArchitecture();
104102
metadata.model = content::BuildModelInfo();

cobalt/browser/user_agent/user_agent_platform_info.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "base/system/sys_info.h"
2727
#include "base/system/sys_info_starboard.h"
2828
#include "build/build_config.h"
29+
#include "starboard/common/system_property.h"
2930
#include "starboard/extension/platform_info.h"
3031

3132
#include "cobalt/cobalt_build_id.h" // Generated
@@ -201,15 +202,14 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) {
201202
}
202203
#endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES
203204

204-
#if BUILDFLAG(IS_ANDROID)
205-
info.set_device_type("ATV");
206-
#else
207-
info.set_device_type("TV");
208-
#endif // BUILDFLAG(IS_ANDROID)
205+
info.set_device_type(
206+
starboard::GetSystemPropertyString(kSbSystemPropertyDeviceType));
209207

210-
// TODO(cobalt, b/374213479): figure out firmware version for other platforms.
211208
#if BUILDFLAG(IS_ANDROID)
212209
info.set_firmware_version(base::SysInfo::GetAndroidBuildID());
210+
#elif BUILDFLAG(IS_STARBOARD)
211+
info.set_firmware_version(
212+
starboard::GetSystemPropertyString(kSbSystemPropertyFirmwareVersion));
213213
#endif // BUILDFLAG(IS_ANDROID)
214214

215215
info.set_model(base::SysInfo::HardwareModelName());
@@ -224,12 +224,8 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) {
224224
// Below UA info fields can NOT be retrieved directly from platform's native
225225
// system properties.
226226

227-
char value[1024];
228-
bool result =
229-
SbSystemGetProperty(kSbSystemPropertyUserAgentAuxField, value, 1024);
230-
if (result) {
231-
info.set_aux_field(value);
232-
}
227+
info.set_aux_field(
228+
starboard::GetSystemPropertyString(kSbSystemPropertyUserAgentAuxField));
233229

234230
// We only support JIT for both Linux and Android.
235231
info.set_javascript_engine_version(

cobalt/version.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// release is cut.
3737
//.
3838

39+
#define COBALT_MAJOR_VERSION "26"
3940
#define COBALT_VERSION "26.master.0"
4041

4142
#endif // COBALT_VERSION_H_

starboard/build/config/os_definitions.gni

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ is_linux = current_os == "linux"
2828
is_mac = current_os == "mac"
2929
is_nacl = current_os == "nacl"
3030
is_win = current_os == "win" || current_os == "winuwp"
31-
is_robolectric = false
3231
is_chromecast = false
3332

3433
is_apple = is_ios || is_mac

starboard/common/BUILD.gn

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
# to all platforms.
1717

1818
source_set("common_headers_only") {
19-
sources = [ "log.h" ]
19+
sources = [
20+
"log.h",
21+
"system_property.h",
22+
]
23+
2024
deps = [ "//starboard:starboard_headers_only" ]
2125
}
2226

@@ -82,7 +86,6 @@ static_library("common") {
8286
"storage.cc",
8387
"storage.h",
8488
"string.h",
85-
"system_property.h",
8689
"thread.cc",
8790
"thread.h",
8891
"time.cc",

0 commit comments

Comments
 (0)