Skip to content

Commit

Permalink
Improve detection for Nvidia devices
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Dec 12, 2024
1 parent de871b3 commit 9cdf560
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
LG = 'LG',
MICROSOFT = 'Microsoft',
MOTOROLA = 'Motorola',
NVIDIA = 'Nvidia',
ONEPLUS = 'OnePlus',
OPPO = 'OPPO',
SAMSUNG = 'Samsung',
Expand Down Expand Up @@ -736,8 +737,8 @@
], [MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]], [
/droid [\d\.]+; (fp\du?)(?: b|\))/i // Fairphone
], [MODEL, [VENDOR, 'Fairphone'], [TYPE, MOBILE]], [
/(shield[\w ]+) b/i // Nvidia Shield Tablets
], [MODEL, [VENDOR, 'Nvidia'], [TYPE, TABLET]], [
/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i // Nvidia Tablets
], [MODEL, [VENDOR, NVIDIA], [TYPE, TABLET]], [
/(sprint) (\w+)/i // Sprint Phones
], [VENDOR, MODEL, [TYPE, MOBILE]], [
/(kin\.[onetw]{3})/i // Microsoft Kin
Expand Down Expand Up @@ -769,6 +770,8 @@
], [[MODEL, CHROMECAST], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/droid.+aft(\w+)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/(shield \w+ tv)/i // Nvidia Shield TV
], [MODEL, [VENDOR, NVIDIA], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
Expand All @@ -791,8 +794,8 @@
/(ouya)/i, // Ouya
/(nintendo) (\w+)/i // Nintendo
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
/droid.+; (shield) bui/i // Nvidia
], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
/droid.+; (shield)( bui|\))/i // Nvidia Portable
], [MODEL, [VENDOR, NVIDIA], [TYPE, CONSOLE]], [
/(playstation \w+)/i // Playstation
], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
/\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
Expand Down
36 changes: 36 additions & 0 deletions test/data/ua/device/nvidia.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"desc": "Tegra Note 7",
"ua": "Mozilla/5.0 (Linux; Android 5.1; TegraNote-P1640 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.133 Safari/537.36",
"expect": {
"vendor": "Nvidia",
"model": "TegraNote-P1640",
"type": "tablet"
}
},
{
"desc": "Nvidia Shield",
"ua": "Mozilla/5.0 (Linux; Android 5.1; SHIELD) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.74 Mobile Safari/537.36",
"expect": {
"vendor": "Nvidia",
"model": "SHIELD",
"type": "console"
}
},
{
"desc": "Nvidia Shield Tablet",
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; SHIELD Tablet Build/LVY48E; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.19 Safari/537.36",
Expand All @@ -7,5 +25,23 @@
"model": "SHIELD Tablet",
"type": "tablet"
}
},
{
"desc": "Nvidia Shield Tablet K1",
"ua": "Mozilla/5.0 (Linux; Android 7.0; SHIELD Tablet K1 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Safari/537.36",
"expect": {
"vendor": "Nvidia",
"model": "SHIELD Tablet K1",
"type": "tablet"
}
},
{
"desc": "Nvidia Shield TV",
"ua": "Mozilla/5.0 (Linux; Android 11; SHIELD Android TV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Mobile Safari/537.36 ",
"expect": {
"vendor": "Nvidia",
"model": "SHIELD Android TV",
"type": "smarttv"
}
}
]

0 comments on commit 9cdf560

Please sign in to comment.