Skip to content

Commit c54dff7

Browse files
gurmeetkcopybara-github
authored andcommitted
Reland "Reland "Reland "[XR] Use desktop user agent client hints by default for XR devices"""
This is a reland of commit 762df81b695eb7c8a54fe11079435ece2fdd8913 Original change's description: > Reland "Reland "[XR] Use desktop user agent client hints by default for XR devices"" > > This is a reland of commit f007ff92a06f2fc270aafb011d22ccbfcc5a5197 > > This reland resolves issues from the original version, specifically addressing > performance test failures and post-submit linker errors. The tests now fetch > device properties using device_info, ensuring successful execution. > Key modifications include: > > 1. XR Device Determination: Switched from using the `device::features::IsXrDevice()` feature flag to `base::android::device_info::is_xr()` for identifying XR devices. > 2. New Form Factor: Introduced `ui::DEVICE_FORM_FACTOR_XR` as a new enum type for form factors. It is similar to the approach used by devices of desktop form factor. > 3. Testing: Added `for-testing` methods to the `DeviceInfo` class to enable XR device simulation in unit tests. These methods can be utilized for browser tests once XR devices are integrated into automated testing. > 4. Code Cleanup: Removed `device::features::kForceIsXrDeviceForTesting`, a public cpp feature previously used for testing, and cleaned up associated code. > > Original change's description: > > Reland "[XR] Use desktop user agent client hints by default for XR devices" > > > > This is a reland of commit ba8733b34194c66425f780c3a09ea2051da5c7f1 > > > > Original change's description: > > > [XR] Use desktop user agent client hints by default for XR devices > > > > > > This change modifies the user agent client hints for XR devices to align > > > with a desktop form factor. > > > > > > Previously, search requests from XR devices sent the default mobile user > > > agent, causing some web services to incorrectly identify the XR device > > > as a mobile phone. This resulted in a degraded user experience, such as > > > 3D models links not appearing in initial search results. > > > > > > The user agent for XR devices now correctly reflects the user agent > > > string, similar to for a desktop (crrev.com/c/6639016). This is achieved > > > by setting the platform info mobile flag and specifying device-specific > > > details like architecture, CPU, and bit count. > > > > > > This change also resolves the issue of Chrome not playing videos hosted > > > on a drive on XR devices. > > > > > > Test: Verified on a Moohan device by searching for "Golden Eagle". The > > > "View in 3D" option now appears in the initial search results. A screen > > > recording of the successful test is available at > > > https://drive.google.com/file/d/14BcygWXpdrA7E8Ewu3ADNIbYPOo2XZ66/view?usp=drive_link&resourcekey=0-Gi2OiD2fMlYe-2UAd-4Qtw > > > > > > Bug: 381541583 > > > Change-Id: I45c1e2205cc0058bbc0c0f787a16cfe3841a468c > > > Fixed: 380746545 > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6769955 > > > Reviewed-by: Victor Tan <[email protected]> > > > Commit-Queue: Gurmeet Kalra <[email protected]> > > > Cr-Commit-Position: refs/heads/main@{#1491731} > > > > Bug: 381541583 > > Change-Id: Ie222b844db21262f26aade3d7d785bb8203cc131 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6787410 > > Reviewed-by: Victor Tan <[email protected]> > > Commit-Queue: Gurmeet Kalra <[email protected]> > > Cr-Commit-Position: refs/heads/main@{#1492297} > > Bug: 381541583 > Change-Id: Ia6028d2d204f607cc0d6acc2908db1ab89c5a379 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6807752 > Owners-Override: Andrew Grieve <[email protected]> > Commit-Queue: Gurmeet Kalra <[email protected]> > Reviewed-by: Andrew Grieve <[email protected]> > Reviewed-by: Victor Tan <[email protected]> > Reviewed-by: Alexander Cooper <[email protected]> > Reviewed-by: Daniel Cheng <[email protected]> > Cr-Commit-Position: refs/heads/main@{#1499390} Bug: 381541583 Change-Id: I774aaa64892b294bc34e308bb36f8f32e3307962 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6833455 Owners-Override: Andrew Grieve <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Takashi Nakayama <[email protected]> Commit-Queue: Gurmeet Kalra <[email protected]> Reviewed-by: Andrew Grieve <[email protected]> Cr-Commit-Position: refs/heads/main@{#1500161} NOKEYCHECK=True GitOrigin-RevId: d4094e647d83c494f216c9d5eb3ea93334a7b012
1 parent 727d763 commit c54dff7

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

android/device_info.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct IDeviceInfo {
3535
bool isTv;
3636
// Available only on Android T+.
3737
int32_t vulkanDeqpLevel;
38+
bool isXr;
3839
};
3940
#endif
4041

@@ -64,13 +65,15 @@ static void JNI_DeviceInfo_FillFields(JNIEnv* env,
6465
jboolean isAutomotive,
6566
jboolean isFoldable,
6667
jboolean isDesktop,
67-
jint vulkanDeqpLevel) {
68+
jint vulkanDeqpLevel,
69+
jboolean isXr) {
6870
Set(IDeviceInfo{.gmsVersionCode = gmsVersionCode,
6971
.isAutomotive = static_cast<bool>(isAutomotive),
7072
.isDesktop = static_cast<bool>(isDesktop),
7173
.isFoldable = static_cast<bool>(isFoldable),
7274
.isTv = static_cast<bool>(isTV),
73-
.vulkanDeqpLevel = vulkanDeqpLevel});
75+
.vulkanDeqpLevel = vulkanDeqpLevel,
76+
.isXr = static_cast<bool>(isXr)});
7477
}
7578

7679
const std::string& gms_version_code() {
@@ -102,4 +105,17 @@ int32_t vulkan_deqp_level() {
102105
return get_device_info().vulkanDeqpLevel;
103106
}
104107

108+
bool is_xr() {
109+
return get_device_info().isXr;
110+
}
111+
112+
void set_is_xr_for_testing() {
113+
Java_DeviceInfo_setIsXrForTesting(AttachCurrentThread()); // IN-TEST
114+
get_holder().reset();
115+
}
116+
117+
void reset_is_xr_for_testing() {
118+
Java_DeviceInfo_resetIsXrForTesting(AttachCurrentThread()); // IN-TEST
119+
get_holder().reset();
120+
}
105121
} // namespace base::android::device_info

android/device_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ BASE_EXPORT bool is_foldable();
3232
BASE_EXPORT bool is_desktop();
3333
// Available only on Android T+.
3434
BASE_EXPORT int32_t vulkan_deqp_level();
35+
BASE_EXPORT bool is_xr();
3536

37+
// For testing use only.
38+
BASE_EXPORT void set_is_xr_for_testing();
39+
BASE_EXPORT void reset_is_xr_for_testing();
3640
} // namespace base::android::device_info
3741

3842
#endif // BASE_ANDROID_DEVICE_INFO_H_

android/java/src/org/chromium/base/DeviceInfo.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public final class DeviceInfo {
3636
private static @Nullable String sGmsVersionCodeForTesting;
3737
private static @Nullable Boolean sIsAutomotiveForTesting;
3838
private static boolean sInitialized;
39+
private static boolean sIsXrForTesting;
3940
private final IDeviceInfo mIDeviceInfo;
4041

4142
@GuardedBy("CREATION_LOCK")
@@ -61,7 +62,8 @@ public static void sendToNative(IDeviceInfo info) {
6162
/* isAutomotive= */ info.isAutomotive,
6263
/* isFoldable= */ info.isFoldable,
6364
/* isDesktop= */ info.isDesktop,
64-
/* vulkanDeqpLevel= */ info.vulkanDeqpLevel);
65+
/* vulkanDeqpLevel= */ info.vulkanDeqpLevel,
66+
/* isXr= */ sIsXrForTesting ? true : info.isXr);
6567
}
6668

6769
public static IDeviceInfo getAidlInfo() {
@@ -105,10 +107,24 @@ public static int getVulkanDeqpLevel() {
105107
return getInstance().mIDeviceInfo.vulkanDeqpLevel;
106108
}
107109

110+
public static boolean isXr() {
111+
return getInstance().mIDeviceInfo.isXr;
112+
}
113+
108114
public static boolean isInitializedForTesting() {
109115
return sInitialized;
110116
}
111117

118+
@CalledByNativeForTesting
119+
public static void setIsXrForTesting() {
120+
sIsXrForTesting = true;
121+
}
122+
123+
@CalledByNativeForTesting
124+
public static void resetIsXrForTesting() {
125+
sIsXrForTesting = false;
126+
}
127+
112128
private static DeviceInfo getInstance() {
113129
// Some tests mock out things BuildInfo is based on, so disable caching in tests to ensure
114130
// such mocking is not defeated by caching.
@@ -197,6 +213,8 @@ private DeviceInfo() {
197213
}
198214
}
199215
mIDeviceInfo.vulkanDeqpLevel = vulkanLevel;
216+
217+
mIDeviceInfo.isXr = pm.hasSystemFeature("android.software.xr.api.openxr");
200218
}
201219

202220
@NativeMethods
@@ -207,6 +225,7 @@ void fillFields(
207225
boolean isAutomotive,
208226
boolean isFoldable,
209227
boolean isDesktop,
210-
int vulkanDeqpLevel);
228+
int vulkanDeqpLevel,
229+
boolean isXr);
211230
}
212231
}

android/java/src/org/chromium/base/IDeviceInfo.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ parcelable IDeviceInfo {
1111
boolean isFoldable;
1212
boolean isTv;
1313
int vulkanDeqpLevel;
14+
boolean isXr;
1415
}

0 commit comments

Comments
 (0)