bug(device): Android web model is reported as K with reduced User-Agent; use Client Hints when available
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- backend, mobile-dev
调研方向
Start in device/src/web.ts and trace how Device.getInfo() derives the web model from the User-Agent. Add focused tests for a valid Client Hints model and the listed fallback cases, including other platforms. Done means Android web uses a valid hinted model when available while preserving the parsed model in fallback cases.
由索引模型根据 Issue 内容生成。
描述
Bug Report
Plugin(s)
@capacitor/device (web implementation). Observed with version 8.0.3; the current default-branch implementation in device/src/web.ts also still relies on User-Agent parsing and does not request Client Hints.
Capacitor Version
Relevant package versions: @capacitor/core 8.6.0 and @capacitor/device 8.0.3. A complete cap doctor report is not included; this report concerns the browser implementation only.
Platform(s)
Web, specifically Chrome/Chromium on Android with User-Agent reduction enabled, on HTTPS.
Current Behavior
Device.getInfo() derives model from navigator.userAgent. A reduced Android User-Agent such as:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36
is parsed as model: "K". This is a generic value rather than the hardware model. On supported browsers, User-Agent Client Hints can expose a more accurate model, subject to browser policy.
Expected Behavior
Use the existing User-Agent parser as the baseline, and enhance the Android web model using navigator.userAgentData.getHighEntropyValues(["model"]) when available. Preserve the existing model if the API is unavailable, the request rejects, or the returned model is empty/invalid.
No native changes, public signature changes, or third-party dependencies should be needed: getInfo() already returns a Promise. Other fields could remain unchanged to keep the fix focused.
Code Reproduction
Run this in an HTTPS web application with @capacitor/device, using Chrome on an Android device:
import { Device } from "@capacitor/device";
const info = await Device.getInfo();
const hints = typeof navigator.userAgentData?.getHighEntropyValues === "function"
? await navigator.userAgentData.getHighEntropyValues(["model"])
: null;
console.log({ userAgent: navigator.userAgent, parsedModel: info.model, hintedModel: hints?.model });
When Chrome exposes the hardware model via Client Hints, parsedModel can be K while hintedModel contains the actual model. If the browser withholds the hint, the current result should remain the fallback.
This is an inline reproduction; no standalone reproduction repository is attached.
Other Technical Details
Suggested tests: nonempty hinted model overrides the parsed model; missing API, rejected request, empty/whitespace/non-string model preserve the parsed result; other platforms remain unchanged.
Client Hints do not provide a unique device identifier and should not be documented as such.
Additional Context
This revisits #509, which requested the same progressive enhancement and was closed during backlog cleanup. The maintainer comment invited opening a new issue if it remained relevant. The reduced User-Agent behavior is now a practical issue rather than only an anticipated change.
Chrome documentation: https://developer.chrome.com/docs/privacy-security/user-agent-client-hints
Would a narrowly scoped PR implementing this model enhancement with fallback and tests be welcome?
- 主要语言
- Java
- 星标
- 688
- 派生
- 691
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ionic-team/capacitor-plugins 的其他 Issue
-
platform: android
难度 2/5 1-3 小时 新手友好度 88/100
ionic-team/capacitor-plugins#2635 ·
维护者通常 1 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 80/100
ionic-team/capacitor-plugins#2627 ·
维护者通常 1 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 72/100
ionic-team/capacitor-plugins#2616 ·
维护者通常 1 天内回复
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguage未关闭triage
难度 1/5 1 小时以内 新手友好度 88/100
ionic-team/capacitor-plugins#2604 ·
维护者通常 1 天内回复
-
platform: android
难度 3/5 1-2 天 新手友好度 74/100
ionic-team/capacitor-plugins#2636 ·
维护者通常 1 天内回复
查看 ionic-team/capacitor-plugins 的全部 Issue
相似的 Issue
-
Test: Verify vault unlock max failed attempts and PIN brute-force protection可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
wultra/powerauth-tests#980 ·
-
account bug communication lecture
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
line/centraldogma#1397 ·
维护者通常 2 天内回复
-
[Bug]: Fixed/recurring deposit accounts are treated as savings in ownership and listings可能已有人在做 @Aana123 今天认领。 未关闭bug Triage
难度 2/5 1-3 小时 新手友好度 76/100
apache/fineract-consumer-facing#252 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 76/100
ShaftHQ/SHAFT_ENGINE#7946 ·
维护者通常 1 天内回复