Skip to content

Commit

Permalink
Improves detection for feature phones
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuconcioiu committed Dec 28, 2024
1 parent 09cfb7c commit 31e4caf
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 130 deletions.
9 changes: 8 additions & 1 deletion DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,12 +1017,19 @@ protected function parseDevice(): void
}

/**
* All unknown devices under running Java ME are more likely a features phones
* All unknown devices under running Java ME are more likely features phones
*/
if ('Java ME' === $osName && null === $this->device) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_FEATURE_PHONE;
}

/**
* All smartphones running KaiOS are more likely features phones
*/
if ('KaiOS' === $osName && AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE === $this->device) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_FEATURE_PHONE;
}

/**
* According to http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
* Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the end of the
Expand Down
126 changes: 126 additions & 0 deletions Tests/fixtures/feature_phone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1822,3 +1822,129 @@
model: Core-S4
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; ALCATEL4044T; rv:37.0) Gecko/37.0 Firefox/37.0 KaiOS/1.0
os:
name: KaiOS
version: "1.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "37.0"
engine: Gecko
engine_version: "37.0"
device:
type: feature phone
brand: Alcatel
model: Go Flip
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; LYF/LF-2403N/LYF-LF2403N-000-01-38-151217;Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0
os:
name: KaiOS
version: "2.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: feature phone
brand: LYF
model: LF-2403N
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; LYF/F90M/LYF-F90M-000-02-28-130318; Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0
os:
name: KaiOS
version: "2.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: feature phone
brand: LYF
model: F90M
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; LYF/F30C/LYF_F30C-000-09-10-140318; Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0
os:
name: KaiOS
version: "2.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: feature phone
brand: LYF
model: F30C
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; IPRO_K2_3G; rv:48.0; CAEN) Gecko/48.0 Firefox/48.0 KAIOS/2.5.1.2
os:
name: KaiOS
version: 2.5.1.2
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: feature phone
brand: iPro
model: K2 3G
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; CAT B35; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.5.1
os:
name: KaiOS
version: 2.5.1
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: feature phone
brand: Cat
model: B35
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; LYF/F120B/LYF-F120B-001-02-05-011118_audio_patch-i;Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.5
os:
name: KaiOS
version: "2.5"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: feature phone
brand: LYF
model: F120B
os_family: Firefox OS
browser_family: Firefox
6 changes: 3 additions & 3 deletions Tests/fixtures/podcasting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5988,7 +5988,7 @@
name: PodKast
version: ""
device:
type: smartphone
type: feature phone
brand: Safaricom
model: Kimem Kerefa 4G
os_family: Firefox OS
Expand Down Expand Up @@ -6036,7 +6036,7 @@
name: PodLP
version: 1.3.2.0
device:
type: smartphone
type: feature phone
brand: LYF
model: F271i
os_family: Firefox OS
Expand All @@ -6052,7 +6052,7 @@
name: PodLP
version: 2.2.1
device:
type: smartphone
type: feature phone
brand: Nokia
model: 2720 Flip
os_family: Firefox OS
Expand Down
18 changes: 0 additions & 18 deletions Tests/fixtures/smartphone-29.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6311,24 +6311,6 @@
model: A46
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Mobile; LYF/F120B/LYF-F120B-001-02-05-011118_audio_patch-i;Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.5
os:
name: KaiOS
version: "2.5"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: smartphone
brand: LYF
model: F120B
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Linux; Android 10; beryllium) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36
os:
Expand Down
18 changes: 0 additions & 18 deletions Tests/fixtures/smartphone-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5211,24 +5211,6 @@
model: B15Q
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Mobile; CAT B35; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.5.1
os:
name: KaiOS
version: 2.5.1
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: smartphone
brand: Cat
model: B35
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Linux; Android 8.1.0; CUBOT A5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36
os:
Expand Down
18 changes: 0 additions & 18 deletions Tests/fixtures/smartphone-40.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3273,24 +3273,6 @@
model: A3 Pro 5G
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Mobile; IPRO_K2_3G; rv:48.0; CAEN) Gecko/48.0 Firefox/48.0 KAIOS/2.5.1.2
os:
name: KaiOS
version: 2.5.1.2
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: smartphone
brand: iPro
model: K2 3G
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Linux; Android 6.0.0; DOOV L525) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36
os:
Expand Down
54 changes: 0 additions & 54 deletions Tests/fixtures/smartphone-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8821,42 +8821,6 @@
model: Earth 2
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Mobile; LYF/F30C/LYF_F30C-000-09-10-140318; Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0
os:
name: KaiOS
version: "2.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: smartphone
brand: LYF
model: F30C
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Mobile; LYF/F90M/LYF-F90M-000-02-28-130318; Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0
os:
name: KaiOS
version: "2.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: smartphone
brand: LYF
model: F90M
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Linux; Android 5.1; LS-4004 Build/LMY47D; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36
os:
Expand Down Expand Up @@ -9019,24 +8983,6 @@
model: Next
os_family: Android
browser_family: Opera
-
user_agent: Mozilla/5.0 (Mobile; ALCATEL4044T; rv:37.0) Gecko/37.0 Firefox/37.0 KaiOS/1.0
os:
name: KaiOS
version: "1.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "37.0"
engine: Gecko
engine_version: "37.0"
device:
type: smartphone
brand: Alcatel
model: Go Flip
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Dalvik/2.1.0 (Linux; U; Android 6.0; Dash G Build/MRA58K)
os:
Expand Down
18 changes: 0 additions & 18 deletions Tests/fixtures/smartphone-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,6 @@
model: Flame LS-4503
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Mobile; LYF/LF-2403N/LYF-LF2403N-000-01-38-151217;Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0
os:
name: KaiOS
version: "2.0"
platform: ""
client:
type: browser
name: Firefox Mobile
version: "48.0"
engine: Gecko
engine_version: "48.0"
device:
type: smartphone
brand: LYF
model: LF-2403N
os_family: Firefox OS
browser_family: Firefox
-
user_agent: Mozilla/5.0 (Linux; Android 5.1.1; LS-5002 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36
os:
Expand Down

0 comments on commit 31e4caf

Please sign in to comment.