mobileesp_converted 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +1 -1
- data/java_source/UAgentInfo.java +316 -190
- data/lib/mobileesp_converted/user_agent_info.rb +439 -318
- data/lib/mobileesp_converted/version.rb +1 -1
- data/spec/mobileesp_converted/user_agent_info_spec.rb +14 -0
- metadata +14 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1f6ec4f7d1353886d6c451ee189e3ac4f4081553
|
4
|
+
data.tar.gz: cfe50ea1fe146820349401a82af6d8acbb29d90b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6943f9a52c3d3b5817a9cd43ac9f18753c9c28c33bc8d0ff29e5ea3e399b16d0ad725fe916005d6f5000d217aef94e3f0fed178c7f4166ae66d2a1adbf4fb0bf
|
7
|
+
data.tar.gz: 3362f43631324a082ae09f0efd154d840ff5a15f2c8c1789645ab546e784283145158b80d248a9925c9ec5d5c6c3e39556737537e7c307a0e55522c19149c6fa
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ task :default => [:test]
|
|
7
7
|
desc "Download Java MobileESP source code to ./tmp directory."
|
8
8
|
task :download_source do
|
9
9
|
`mkdir -p java_source`
|
10
|
-
`cd java_source; rm UAgentInfo.java; wget
|
10
|
+
`cd java_source; rm UAgentInfo.java; wget https://raw.githubusercontent.com/ahand/mobileesp/master/Java/UAgentInfo.java`
|
11
11
|
end
|
12
12
|
|
13
13
|
Rake::TestTask.new do |t|
|
data/java_source/UAgentInfo.java
CHANGED
@@ -1,25 +1,42 @@
|
|
1
1
|
/* *******************************************
|
2
|
-
// Copyright 2010-
|
2
|
+
// Copyright 2010-2015, Anthony Hand
|
3
3
|
//
|
4
|
-
// File version 2013.08.01 (August 1, 2013)
|
5
|
-
// Updates:
|
6
|
-
// - Updated DetectMobileQuick(). Moved the 'Exclude Tablets' logic to the top of the method to fix a logic bug.
|
7
4
|
//
|
8
|
-
// File version
|
9
|
-
//
|
10
|
-
// -
|
11
|
-
// -
|
12
|
-
//
|
13
|
-
//
|
14
|
-
// - Added support for
|
15
|
-
// -
|
16
|
-
// -
|
17
|
-
//
|
18
|
-
//
|
19
|
-
// -
|
20
|
-
//
|
21
|
-
// -
|
22
|
-
//
|
5
|
+
// File version 2015.05.13 (May 13, 2015)
|
6
|
+
// Updates:
|
7
|
+
// - Moved MobileESP to GitHub. https://github.com/ahand/mobileesp
|
8
|
+
// - Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet.
|
9
|
+
// - Removed DetectOperaAndroidPhone(). This method is no longer reliable.
|
10
|
+
// - Removed DetectOperaAndroidTablet(). This method is no longer reliable.
|
11
|
+
// - Added support for Windows Phone 10: variable and DetectWindowsPhone10()
|
12
|
+
// - Updated DetectWindowsPhone() to include WP10.
|
13
|
+
// - Added support for Firefox OS.
|
14
|
+
// - A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
|
15
|
+
// - NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
|
16
|
+
// - Added support for Sailfish OS. Not enough info to add a tablet detection method at this time.
|
17
|
+
// - A variable plus DetectSailfish(), DetectSailfishPhone()
|
18
|
+
// - Added support for Ubuntu Mobile OS.
|
19
|
+
// - DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
|
20
|
+
// - Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps.
|
21
|
+
// - One variable for Samsung Tizen TVs, plus DetectTizenTV()
|
22
|
+
// - One variable for LG WebOS TVs, plus DetectWebOSTV()
|
23
|
+
// - Updated DetectTizen(). Now tests for "mobile" to disambiguate from Samsung Smart TVs
|
24
|
+
// - Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
|
25
|
+
// - Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet.
|
26
|
+
// - Updated DetectAndroidPhone().
|
27
|
+
// - Updated internal detection code for Android.
|
28
|
+
// - No longer has a special test case for the HTC Flyer tablet.
|
29
|
+
// - Checks against DetectOperaMobile() on Android and reports here if relevant.
|
30
|
+
// - Updated DetectAndroidTablet().
|
31
|
+
// - No longer has a special test case for the HTC Flyer tablet.
|
32
|
+
// - Checks against DetectOperaMobile() on Android to exclude it from here.
|
33
|
+
// - DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones.
|
34
|
+
// - DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.
|
35
|
+
// - DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile.
|
36
|
+
// - DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile.
|
37
|
+
// - DetectSmartphone(): Added support for Meego phones.
|
38
|
+
// - Refactored the detection logic in DetectMobileQuick() and DetectMobileLong().
|
39
|
+
// - Moved a few detection tests for older browsers to Long.
|
23
40
|
//
|
24
41
|
//
|
25
42
|
//
|
@@ -39,7 +56,7 @@
|
|
39
56
|
// Project Owner: Anthony Hand
|
40
57
|
// Email: anthony.hand@gmail.com
|
41
58
|
// Web Site: http://www.mobileesp.com
|
42
|
-
// Source Files:
|
59
|
+
// Source Files: https://github.com/ahand/mobileesp
|
43
60
|
//
|
44
61
|
// Versions of this code are available for:
|
45
62
|
// PHP, JavaScript, Java, ASP.NET (C#), and Ruby
|
@@ -86,10 +103,10 @@ public class UAgentInfo {
|
|
86
103
|
|
87
104
|
public static final String deviceAndroid = "android";
|
88
105
|
public static final String deviceGoogleTV = "googletv";
|
89
|
-
public static final String deviceHtcFlyer = "htc_flyer"; //HTC Flyer
|
90
106
|
|
91
107
|
public static final String deviceWinPhone7 = "windows phone os 7";
|
92
108
|
public static final String deviceWinPhone8 = "windows phone 8";
|
109
|
+
public static final String deviceWinPhone10 = "windows phone 10";
|
93
110
|
public static final String deviceWinMob = "windows ce";
|
94
111
|
public static final String deviceWindows = "windows";
|
95
112
|
public static final String deviceIeMob = "iemobile";
|
@@ -115,19 +132,23 @@ public class UAgentInfo {
|
|
115
132
|
public static final String deviceS90 = "series90";
|
116
133
|
|
117
134
|
public static final String devicePalm = "palm";
|
118
|
-
public static final String deviceWebOS = "webos"; //For Palm
|
135
|
+
public static final String deviceWebOS = "webos"; //For Palm devices
|
136
|
+
public static final String deviceWebOStv = "web0s"; //For LG TVs
|
119
137
|
public static final String deviceWebOShp = "hpwos"; //For HP's line of WebOS devices
|
120
|
-
public static final String engineBlazer = "blazer"; //Old Palm
|
121
|
-
public static final String engineXiino = "xiino"; //Another old Palm
|
122
138
|
|
123
139
|
public static final String deviceNuvifone = "nuvifone"; //Garmin Nuvifone
|
124
140
|
public static final String deviceBada = "bada"; //Samsung's Bada OS
|
125
141
|
public static final String deviceTizen = "tizen"; //Tizen OS
|
126
142
|
public static final String deviceMeego = "meego"; //Meego OS
|
143
|
+
public static final String deviceSailfish = "sailfish"; //Sailfish OS
|
144
|
+
public static final String deviceUbuntu = "ubuntu"; //Ubuntu Mobile OS
|
127
145
|
|
128
146
|
public static final String deviceKindle = "kindle"; //Amazon Kindle, eInk one
|
129
147
|
public static final String engineSilk = "silk-accelerated"; //Amazon's accelerated Silk browser for Kindle Fire
|
130
148
|
|
149
|
+
public static final String engineBlazer = "blazer"; //Old Palm
|
150
|
+
public static final String engineXiino = "xiino"; //Another old Palm
|
151
|
+
|
131
152
|
//Initialize variables for mobile-specific content.
|
132
153
|
public static final String vndwap = "vnd.wap";
|
133
154
|
public static final String wml = "wml";
|
@@ -145,6 +166,7 @@ public class UAgentInfo {
|
|
145
166
|
public static final String deviceXbox = "xbox";
|
146
167
|
public static final String deviceArchos = "archos";
|
147
168
|
|
169
|
+
public static final String engineFirefox = "firefox"; //For Firefox OS
|
148
170
|
public static final String engineOpera = "opera"; //Popular browser
|
149
171
|
public static final String engineNetfront = "netfront"; //Common embedded OS browser
|
150
172
|
public static final String engineUpBrowser = "up.browser"; //common on some phones
|
@@ -152,13 +174,15 @@ public class UAgentInfo {
|
|
152
174
|
public static final String deviceMidp = "midp"; //a mobile Java technology
|
153
175
|
public static final String uplink = "up.link";
|
154
176
|
public static final String engineTelecaQ = "teleca q"; //a modern feature phone browser
|
155
|
-
public static final String engineObigo = "obigo"; //W 10 is a modern feature phone browser
|
156
|
-
|
157
177
|
public static final String devicePda = "pda"; //some devices report themselves as PDAs
|
158
178
|
public static final String mini = "mini"; //Some mobile browsers put "mini" in their names.
|
159
179
|
public static final String mobile = "mobile"; //Some mobile browsers put "mobile" in their user agent strings.
|
160
180
|
public static final String mobi = "mobi"; //Some mobile browsers put "mobi" in their user agent strings.
|
161
181
|
|
182
|
+
//Smart TV strings
|
183
|
+
public static final String smartTV1 = "smart-tv"; //Samsung Tizen smart TVs
|
184
|
+
public static final String smartTV2 = "smarttv"; //LG WebOS smart TVs
|
185
|
+
|
162
186
|
//Use Maemo, Tablet, and Linux to test for Nokia"s Internet Tablets.
|
163
187
|
public static final String maemo = "maemo";
|
164
188
|
public static final String linux = "linux";
|
@@ -170,7 +194,7 @@ public class UAgentInfo {
|
|
170
194
|
public static final String manuericsson = "ericsson";
|
171
195
|
public static final String manuSamsung1 = "sec-sgh";
|
172
196
|
public static final String manuSony = "sony";
|
173
|
-
public static final String manuHtc = "htc";
|
197
|
+
public static final String manuHtc = "htc"; //Popular Android and WinMo manufacturer
|
174
198
|
|
175
199
|
//In some UserAgents, the only clue is the operator.
|
176
200
|
public static final String svcDocomo = "docomo";
|
@@ -282,10 +306,6 @@ public class UAgentInfo {
|
|
282
306
|
* @return detection of an iPhone
|
283
307
|
*/
|
284
308
|
public boolean detectIphone() {
|
285
|
-
if ((this.initCompleted == true) ||
|
286
|
-
(this.isIphone == true))
|
287
|
-
return this.isIphone;
|
288
|
-
|
289
309
|
// The iPad and iPod touch say they're an iPhone! So let's disambiguate.
|
290
310
|
if (userAgent.indexOf(deviceIphone) != -1 &&
|
291
311
|
!detectIpad() &&
|
@@ -349,16 +369,10 @@ public class UAgentInfo {
|
|
349
369
|
* @return detection of an Android device
|
350
370
|
*/
|
351
371
|
public boolean detectAndroid() {
|
352
|
-
if ((this.initCompleted == true) ||
|
353
|
-
(this.isAndroid == true))
|
354
|
-
return this.isAndroid;
|
355
|
-
|
356
372
|
if ((userAgent.indexOf(deviceAndroid) != -1) ||
|
357
373
|
detectGoogleTV())
|
358
374
|
return true;
|
359
|
-
|
360
|
-
if (userAgent.indexOf(deviceHtcFlyer) != -1)
|
361
|
-
return true;
|
375
|
+
|
362
376
|
return false;
|
363
377
|
}
|
364
378
|
|
@@ -370,18 +384,18 @@ public class UAgentInfo {
|
|
370
384
|
* @return detection of an Android phone
|
371
385
|
*/
|
372
386
|
public boolean detectAndroidPhone() {
|
373
|
-
|
374
|
-
|
375
|
-
return
|
387
|
+
//First, let's make sure we're on an Android device.
|
388
|
+
if (!detectAndroid())
|
389
|
+
return false;
|
376
390
|
|
377
|
-
|
378
|
-
|
379
|
-
//Special check for Android phones with Opera Mobile. They should report here.
|
380
|
-
if (detectOperaAndroidPhone())
|
391
|
+
//If it's Android and has 'mobile' in it, Google says it's a phone.
|
392
|
+
if (userAgent.indexOf(mobile) != -1)
|
381
393
|
return true;
|
382
|
-
|
383
|
-
|
394
|
+
|
395
|
+
//Special check for Android devices with Opera Mobile/Mini. They should report here.
|
396
|
+
if (detectOperaMobile())
|
384
397
|
return true;
|
398
|
+
|
385
399
|
return false;
|
386
400
|
}
|
387
401
|
|
@@ -395,12 +409,9 @@ public class UAgentInfo {
|
|
395
409
|
if (!detectAndroid())
|
396
410
|
return false;
|
397
411
|
|
398
|
-
//Special check for Opera
|
412
|
+
//Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
|
399
413
|
if (detectOperaMobile())
|
400
414
|
return false;
|
401
|
-
//Special check for the HTC Flyer 7" tablet. It should NOT report here.
|
402
|
-
if (userAgent.indexOf(deviceHtcFlyer) != -1)
|
403
|
-
return false;
|
404
415
|
|
405
416
|
//Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
|
406
417
|
if ((userAgent.indexOf(mobile) > -1))
|
@@ -437,30 +448,59 @@ public class UAgentInfo {
|
|
437
448
|
* @return detection of a WebKit browser
|
438
449
|
*/
|
439
450
|
public boolean detectWebkit() {
|
440
|
-
if ((this.initCompleted == true) ||
|
441
|
-
(this.isWebkit == true))
|
442
|
-
return this.isWebkit;
|
443
|
-
|
444
451
|
if (userAgent.indexOf(engineWebKit) != -1) {
|
445
452
|
return true;
|
446
453
|
}
|
447
454
|
return false;
|
448
455
|
}
|
449
456
|
|
457
|
+
/**
|
458
|
+
* Detects if the current browser is the Symbian S60 Open Source Browser.
|
459
|
+
* @return detection of Symbian S60 Browser
|
460
|
+
*/
|
461
|
+
public boolean detectS60OssBrowser() {
|
462
|
+
//First, test for WebKit, then make sure it's either Symbian or S60.
|
463
|
+
if (detectWebkit()
|
464
|
+
&& (userAgent.indexOf(deviceSymbian) != -1
|
465
|
+
|| userAgent.indexOf(deviceS60) != -1)) {
|
466
|
+
return true;
|
467
|
+
}
|
468
|
+
return false;
|
469
|
+
}
|
450
470
|
|
451
471
|
/**
|
452
|
-
*
|
472
|
+
*
|
473
|
+
* Detects if the current device is any Symbian OS-based device,
|
474
|
+
* including older S60, Series 70, Series 80, Series 90, and UIQ,
|
475
|
+
* or other browsers running on these devices.
|
476
|
+
* @return detection of SymbianOS
|
477
|
+
*/
|
478
|
+
public boolean detectSymbianOS() {
|
479
|
+
if (userAgent.indexOf(deviceSymbian) != -1
|
480
|
+
|| userAgent.indexOf(deviceS60) != -1
|
481
|
+
|| userAgent.indexOf(deviceS70) != -1
|
482
|
+
|| userAgent.indexOf(deviceS80) != -1
|
483
|
+
|| userAgent.indexOf(deviceS90) != -1) {
|
484
|
+
return true;
|
485
|
+
}
|
486
|
+
return false;
|
487
|
+
}
|
488
|
+
|
489
|
+
/**
|
490
|
+
* Detects if the current browser is a Windows Phone 7.x, 8, or 10 device
|
453
491
|
* @return detection of Windows Phone 7.x OR 8
|
454
492
|
*/
|
455
493
|
public boolean detectWindowsPhone() {
|
456
|
-
if (detectWindowsPhone7()
|
494
|
+
if (detectWindowsPhone7()
|
495
|
+
|| detectWindowsPhone8()
|
496
|
+
|| detectWindowsPhone10()) {
|
457
497
|
return true;
|
458
498
|
}
|
459
499
|
return false;
|
460
500
|
}
|
461
501
|
|
462
502
|
/**
|
463
|
-
* Detects a Windows Phone 7
|
503
|
+
* Detects a Windows Phone 7 device (in mobile browsing mode).
|
464
504
|
* @return detection of Windows Phone 7
|
465
505
|
*/
|
466
506
|
public boolean detectWindowsPhone7() {
|
@@ -481,6 +521,17 @@ public class UAgentInfo {
|
|
481
521
|
return false;
|
482
522
|
}
|
483
523
|
|
524
|
+
/**
|
525
|
+
* Detects a Windows Phone 10 device (in mobile browsing mode).
|
526
|
+
* @return detection of Windows Phone 10
|
527
|
+
*/
|
528
|
+
public boolean detectWindowsPhone10() {
|
529
|
+
if (userAgent.indexOf(deviceWinPhone10) != -1) {
|
530
|
+
return true;
|
531
|
+
}
|
532
|
+
return false;
|
533
|
+
}
|
534
|
+
|
484
535
|
/**
|
485
536
|
* Detects if the current browser is a Windows Mobile device.
|
486
537
|
* Excludes Windows Phone 7.x and 8 devices.
|
@@ -511,7 +562,6 @@ public class UAgentInfo {
|
|
511
562
|
return false;
|
512
563
|
}
|
513
564
|
|
514
|
-
|
515
565
|
/**
|
516
566
|
* Detects if the current browser is any BlackBerry.
|
517
567
|
* Includes BB10 OS, but excludes the PlayBook.
|
@@ -560,8 +610,10 @@ public class UAgentInfo {
|
|
560
610
|
* @return detection of a Blackberry device with WebKit browser
|
561
611
|
*/
|
562
612
|
public boolean detectBlackBerryWebKit() {
|
563
|
-
if (detectBlackBerry() &&
|
613
|
+
if (detectBlackBerry() &&
|
614
|
+
userAgent.indexOf(engineWebKit) != -1) {
|
564
615
|
return true;
|
616
|
+
}
|
565
617
|
return false;
|
566
618
|
}
|
567
619
|
|
@@ -575,8 +627,8 @@ public class UAgentInfo {
|
|
575
627
|
(userAgent.indexOf(deviceBBStorm) != -1 ||
|
576
628
|
userAgent.indexOf(deviceBBTorch) != -1 ||
|
577
629
|
userAgent.indexOf(deviceBBBoldTouch) != -1 ||
|
578
|
-
|
579
|
-
|
630
|
+
userAgent.indexOf(deviceBBCurveTouch) != -1 )) {
|
631
|
+
return true;
|
580
632
|
}
|
581
633
|
return false;
|
582
634
|
}
|
@@ -626,54 +678,21 @@ public class UAgentInfo {
|
|
626
678
|
}
|
627
679
|
}
|
628
680
|
|
629
|
-
|
630
|
-
/**
|
631
|
-
* Detects if the current browser is the Symbian S60 Open Source Browser.
|
632
|
-
* @return detection of Symbian S60 Browser
|
633
|
-
*/
|
634
|
-
public boolean detectS60OssBrowser() {
|
635
|
-
//First, test for WebKit, then make sure it's either Symbian or S60.
|
636
|
-
if (detectWebkit()
|
637
|
-
&& (userAgent.indexOf(deviceSymbian) != -1
|
638
|
-
|| userAgent.indexOf(deviceS60) != -1)) {
|
639
|
-
return true;
|
640
|
-
}
|
641
|
-
return false;
|
642
|
-
}
|
643
|
-
|
644
|
-
/**
|
645
|
-
*
|
646
|
-
* Detects if the current device is any Symbian OS-based device,
|
647
|
-
* including older S60, Series 70, Series 80, Series 90, and UIQ,
|
648
|
-
* or other browsers running on these devices.
|
649
|
-
* @return detection of SymbianOS
|
650
|
-
*/
|
651
|
-
public boolean detectSymbianOS() {
|
652
|
-
if (userAgent.indexOf(deviceSymbian) != -1
|
653
|
-
|| userAgent.indexOf(deviceS60) != -1
|
654
|
-
|| userAgent.indexOf(deviceS70) != -1
|
655
|
-
|| userAgent.indexOf(deviceS80) != -1
|
656
|
-
|| userAgent.indexOf(deviceS90) != -1) {
|
657
|
-
return true;
|
658
|
-
}
|
659
|
-
return false;
|
660
|
-
}
|
661
|
-
|
662
|
-
|
663
681
|
/**
|
664
682
|
* Detects if the current browser is on a PalmOS device.
|
665
683
|
* @return detection of a PalmOS device
|
666
684
|
*/
|
667
685
|
public boolean detectPalmOS() {
|
668
|
-
//Make sure it's not WebOS first
|
669
|
-
if (detectPalmWebOS())
|
670
|
-
return false;
|
671
|
-
|
672
686
|
//Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
|
673
687
|
if (userAgent.indexOf(devicePalm) != -1
|
674
688
|
|| userAgent.indexOf(engineBlazer) != -1
|
675
689
|
|| userAgent.indexOf(engineXiino) != -1) {
|
690
|
+
//Make sure it's not WebOS first
|
691
|
+
if (detectPalmWebOS()) {
|
692
|
+
return false;
|
693
|
+
} else {
|
676
694
|
return true;
|
695
|
+
}
|
677
696
|
}
|
678
697
|
return false;
|
679
698
|
}
|
@@ -703,39 +722,25 @@ public class UAgentInfo {
|
|
703
722
|
}
|
704
723
|
|
705
724
|
/**
|
706
|
-
* Detects
|
707
|
-
* @return detection of
|
725
|
+
* Detects if the current browser is on a WebOS smart TV.
|
726
|
+
* @return detection of a WebOS smart TV
|
708
727
|
*/
|
709
|
-
public boolean
|
710
|
-
if (userAgent.indexOf(
|
711
|
-
|
712
|
-
|| userAgent.indexOf(mobi) != -1)) {
|
713
|
-
return true;
|
714
|
-
}
|
715
|
-
return false;
|
716
|
-
}
|
717
|
-
|
718
|
-
/**
|
719
|
-
* Detects Opera Mobile on an Android phone.
|
720
|
-
* @return detection of an Opera browser on an Android phone
|
721
|
-
*/
|
722
|
-
public boolean detectOperaAndroidPhone() {
|
723
|
-
if (userAgent.indexOf(engineOpera) != -1
|
724
|
-
&& (userAgent.indexOf(deviceAndroid) != -1
|
725
|
-
&& userAgent.indexOf(mobi) != -1)) {
|
728
|
+
public boolean detectWebOSTV() {
|
729
|
+
if (userAgent.indexOf(deviceWebOStv) != -1 &&
|
730
|
+
userAgent.indexOf(smartTV2) != -1) {
|
726
731
|
return true;
|
727
732
|
}
|
728
733
|
return false;
|
729
734
|
}
|
730
735
|
|
731
736
|
/**
|
732
|
-
* Detects Opera Mobile
|
733
|
-
* @return detection of an Opera browser
|
737
|
+
* Detects Opera Mobile or Opera Mini.
|
738
|
+
* @return detection of an Opera browser for a mobile device
|
734
739
|
*/
|
735
|
-
public boolean
|
740
|
+
public boolean detectOperaMobile() {
|
736
741
|
if (userAgent.indexOf(engineOpera) != -1
|
737
|
-
&& (userAgent.indexOf(
|
738
|
-
|
742
|
+
&& (userAgent.indexOf(mini) != -1
|
743
|
+
|| userAgent.indexOf(mobi) != -1)) {
|
739
744
|
return true;
|
740
745
|
}
|
741
746
|
return false;
|
@@ -779,7 +784,7 @@ public class UAgentInfo {
|
|
779
784
|
}
|
780
785
|
|
781
786
|
/**
|
782
|
-
* Detects a device running the Bada
|
787
|
+
* Detects a device running the Bada OS from Samsung.
|
783
788
|
* @return detection of a Bada device
|
784
789
|
*/
|
785
790
|
public boolean detectBada() {
|
@@ -794,7 +799,20 @@ public class UAgentInfo {
|
|
794
799
|
* @return detection of a Tizen device
|
795
800
|
*/
|
796
801
|
public boolean detectTizen() {
|
797
|
-
if (userAgent.indexOf(deviceTizen) != -1
|
802
|
+
if (userAgent.indexOf(deviceTizen) != -1 &&
|
803
|
+
userAgent.indexOf(mobile) != -1) {
|
804
|
+
return true;
|
805
|
+
}
|
806
|
+
return false;
|
807
|
+
}
|
808
|
+
|
809
|
+
/**
|
810
|
+
* Detects if the current browser is on a Tizen smart TV.
|
811
|
+
* @return detection of a Tizen smart TV
|
812
|
+
*/
|
813
|
+
public boolean detectTizenTV() {
|
814
|
+
if (userAgent.indexOf(deviceTizen) != -1 &&
|
815
|
+
userAgent.indexOf(smartTV1) != -1) {
|
798
816
|
return true;
|
799
817
|
}
|
800
818
|
return false;
|
@@ -811,6 +829,123 @@ public class UAgentInfo {
|
|
811
829
|
return false;
|
812
830
|
}
|
813
831
|
|
832
|
+
/**
|
833
|
+
* Detects a phone running the Meego OS.
|
834
|
+
* @return detection of a Meego phone
|
835
|
+
*/
|
836
|
+
public boolean detectMeegoPhone() {
|
837
|
+
if (userAgent.indexOf(deviceMeego) != -1 &&
|
838
|
+
userAgent.indexOf(mobi) != -1) {
|
839
|
+
return true;
|
840
|
+
}
|
841
|
+
return false;
|
842
|
+
}
|
843
|
+
|
844
|
+
/**
|
845
|
+
* Detects a mobile device (probably) running the Firefox OS.
|
846
|
+
* @return detection of a Firefox OS mobile device
|
847
|
+
*/
|
848
|
+
public boolean detectFirefoxOS() {
|
849
|
+
if (detectFirefoxOSPhone() || detectFirefoxOSTablet())
|
850
|
+
return true;
|
851
|
+
|
852
|
+
return false;
|
853
|
+
}
|
854
|
+
|
855
|
+
/**
|
856
|
+
* Detects a phone (probably) running the Firefox OS.
|
857
|
+
* @return detection of a Firefox OS phone
|
858
|
+
*/
|
859
|
+
public boolean detectFirefoxOSPhone() {
|
860
|
+
//First, let's make sure we're NOT on another major mobile OS.
|
861
|
+
if (detectIos()
|
862
|
+
|| detectAndroid()
|
863
|
+
|| detectSailfish())
|
864
|
+
return false;
|
865
|
+
|
866
|
+
if ((userAgent.indexOf(engineFirefox) != -1)
|
867
|
+
&& (userAgent.indexOf(mobile) != -1))
|
868
|
+
return true;
|
869
|
+
|
870
|
+
return false;
|
871
|
+
}
|
872
|
+
|
873
|
+
/**
|
874
|
+
* Detects a tablet (probably) running the Firefox OS.
|
875
|
+
* @return detection of a Firefox OS tablet
|
876
|
+
*/
|
877
|
+
public boolean detectFirefoxOSTablet() {
|
878
|
+
//First, let's make sure we're NOT on another major mobile OS.
|
879
|
+
if (detectIos()
|
880
|
+
|| detectAndroid()
|
881
|
+
|| detectSailfish())
|
882
|
+
return false;
|
883
|
+
|
884
|
+
if ((userAgent.indexOf(engineFirefox) != -1)
|
885
|
+
&& (userAgent.indexOf(deviceTablet) != -1))
|
886
|
+
return true;
|
887
|
+
|
888
|
+
return false;
|
889
|
+
}
|
890
|
+
|
891
|
+
/**
|
892
|
+
* Detects a device running the Sailfish OS.
|
893
|
+
* @return detection of a Sailfish device
|
894
|
+
*/
|
895
|
+
public boolean detectSailfish() {
|
896
|
+
if (userAgent.indexOf(deviceSailfish) != -1) {
|
897
|
+
return true;
|
898
|
+
}
|
899
|
+
return false;
|
900
|
+
}
|
901
|
+
|
902
|
+
/**
|
903
|
+
* Detects a phone running the Sailfish OS.
|
904
|
+
* @return detection of a Sailfish phone
|
905
|
+
*/
|
906
|
+
public boolean detectSailfishPhone() {
|
907
|
+
if (detectSailfish() && (userAgent.indexOf(mobile) != -1))
|
908
|
+
return true;
|
909
|
+
|
910
|
+
return false;
|
911
|
+
}
|
912
|
+
|
913
|
+
/**
|
914
|
+
* Detects a mobile device running the Ubuntu Mobile OS.
|
915
|
+
* @return detection of an Ubuntu Mobile OS mobile device
|
916
|
+
*/
|
917
|
+
public boolean detectUbuntu() {
|
918
|
+
if (detectUbuntuPhone() || detectUbuntuTablet())
|
919
|
+
return true;
|
920
|
+
|
921
|
+
return false;
|
922
|
+
}
|
923
|
+
|
924
|
+
/**
|
925
|
+
* Detects a phone running the Ubuntu Mobile OS.
|
926
|
+
* @return detection of an Ubuntu Mobile OS phone
|
927
|
+
*/
|
928
|
+
public boolean detectUbuntuPhone() {
|
929
|
+
if ((userAgent.indexOf(deviceUbuntu) != -1)
|
930
|
+
&& (userAgent.indexOf(mobile) != -1))
|
931
|
+
return true;
|
932
|
+
|
933
|
+
return false;
|
934
|
+
}
|
935
|
+
|
936
|
+
/**
|
937
|
+
* Detects a tablet running the Ubuntu Mobile OS.
|
938
|
+
* @return detection of an Ubuntu Mobile OS tablet
|
939
|
+
*/
|
940
|
+
public boolean detectUbuntuTablet() {
|
941
|
+
if ((userAgent.indexOf(deviceUbuntu) != -1)
|
942
|
+
&& (userAgent.indexOf(deviceTablet) != -1))
|
943
|
+
return true;
|
944
|
+
|
945
|
+
return false;
|
946
|
+
}
|
947
|
+
|
948
|
+
|
814
949
|
/**
|
815
950
|
* Detects the Danger Hiptop device.
|
816
951
|
* @return detection of a Danger Hiptop
|
@@ -978,6 +1113,7 @@ public class UAgentInfo {
|
|
978
1113
|
|| detectSymbianOS()
|
979
1114
|
|| detectWindowsMobile()
|
980
1115
|
|| detectBlackBerry()
|
1116
|
+
|| detectMeegoPhone()
|
981
1117
|
|| detectPalmOS());
|
982
1118
|
}
|
983
1119
|
|
@@ -989,45 +1125,39 @@ public class UAgentInfo {
|
|
989
1125
|
*/
|
990
1126
|
public boolean detectMobileQuick() {
|
991
1127
|
//Let's exclude tablets
|
992
|
-
if (
|
1128
|
+
if (isTierTablet) {
|
993
1129
|
return false;
|
994
|
-
|
995
|
-
if ((initCompleted == true) ||
|
996
|
-
(isMobilePhone == true))
|
997
|
-
return isMobilePhone;
|
998
|
-
|
1130
|
+
}
|
999
1131
|
//Most mobile browsing is done on smartphones
|
1000
|
-
if (detectSmartphone())
|
1132
|
+
if (detectSmartphone()) {
|
1001
1133
|
return true;
|
1134
|
+
}
|
1002
1135
|
|
1003
|
-
|
1004
|
-
|
1005
|
-
|| detectOperaMobile())
|
1136
|
+
//Catch-all for many mobile devices
|
1137
|
+
if (userAgent.indexOf(mobile) != -1) {
|
1006
1138
|
return true;
|
1139
|
+
}
|
1007
1140
|
|
1008
|
-
if ((
|
1009
|
-
|| (userAgent.indexOf(engineNetfront) != -1)
|
1010
|
-
|| (userAgent.indexOf(engineUpBrowser) != -1)
|
1011
|
-
|| (userAgent.indexOf(engineOpenWeb) != -1))
|
1141
|
+
if (detectOperaMobile()) {
|
1012
1142
|
return true;
|
1143
|
+
}
|
1013
1144
|
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|| detectArchos())
|
1145
|
+
//We also look for Kindle devices
|
1146
|
+
if (detectKindle()
|
1147
|
+
|| detectAmazonSilk()) {
|
1018
1148
|
return true;
|
1149
|
+
}
|
1019
1150
|
|
1020
|
-
if ((
|
1021
|
-
(
|
1022
|
-
|
1023
|
-
|
1024
|
-
if (userAgent.indexOf(mobile) != -1)
|
1151
|
+
if (detectWapWml()
|
1152
|
+
|| detectMidpCapable()
|
1153
|
+
|| detectBrewDevice()) {
|
1025
1154
|
return true;
|
1155
|
+
}
|
1026
1156
|
|
1027
|
-
|
1028
|
-
|
1029
|
-
|| detectAmazonSilk())
|
1157
|
+
if ((userAgent.indexOf(engineNetfront) != -1)
|
1158
|
+
|| (userAgent.indexOf(engineUpBrowser) != -1)) {
|
1030
1159
|
return true;
|
1160
|
+
}
|
1031
1161
|
|
1032
1162
|
return false;
|
1033
1163
|
}
|
@@ -1043,28 +1173,36 @@ public class UAgentInfo {
|
|
1043
1173
|
*/
|
1044
1174
|
public boolean detectMobileLong() {
|
1045
1175
|
if (detectMobileQuick()
|
1046
|
-
|| detectGameConsole()
|
1047
|
-
|| detectSonyMylo()) {
|
1176
|
+
|| detectGameConsole()) {
|
1048
1177
|
return true;
|
1049
1178
|
}
|
1050
1179
|
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
return true;
|
1056
|
-
if (userAgent.indexOf(manuericsson) != -1)
|
1057
|
-
return true;
|
1058
|
-
if (userAgent.indexOf(manuSamsung1) != -1)
|
1180
|
+
if (detectDangerHiptop()
|
1181
|
+
|| detectMaemoTablet()
|
1182
|
+
|| detectSonyMylo()
|
1183
|
+
|| detectArchos()) {
|
1059
1184
|
return true;
|
1185
|
+
}
|
1060
1186
|
|
1061
|
-
if (userAgent.indexOf(
|
1062
|
-
|
1063
|
-
|
1064
|
-
return true;
|
1065
|
-
if (userAgent.indexOf(svcVodafone) != -1)
|
1187
|
+
if ((userAgent.indexOf(devicePda) != -1) &&
|
1188
|
+
(userAgent.indexOf(disUpdate) < 0)) //no index found
|
1189
|
+
{
|
1066
1190
|
return true;
|
1191
|
+
}
|
1067
1192
|
|
1193
|
+
//Detect older phones from certain manufacturers and operators.
|
1194
|
+
if ((userAgent.indexOf(uplink) != -1)
|
1195
|
+
|| (userAgent.indexOf(engineOpenWeb) != -1)
|
1196
|
+
|| (userAgent.indexOf(manuSamsung1) != -1)
|
1197
|
+
|| (userAgent.indexOf(manuSonyEricsson) != -1)
|
1198
|
+
|| (userAgent.indexOf(manuericsson) != -1)
|
1199
|
+
|| (userAgent.indexOf(svcDocomo) != -1)
|
1200
|
+
|| (userAgent.indexOf(svcKddi) != -1)
|
1201
|
+
|| (userAgent.indexOf(svcVodafone) != -1))
|
1202
|
+
{
|
1203
|
+
return true;
|
1204
|
+
}
|
1205
|
+
|
1068
1206
|
return false;
|
1069
1207
|
}
|
1070
1208
|
|
@@ -1080,13 +1218,11 @@ public class UAgentInfo {
|
|
1080
1218
|
* @return detection of any device in the Tablet Tier
|
1081
1219
|
*/
|
1082
1220
|
public boolean detectTierTablet() {
|
1083
|
-
if ((this.initCompleted == true) ||
|
1084
|
-
(this.isTierTablet == true))
|
1085
|
-
return this.isTierTablet;
|
1086
|
-
|
1087
1221
|
if (detectIpad()
|
1088
1222
|
|| detectAndroidTablet()
|
1089
1223
|
|| detectBlackBerryTablet()
|
1224
|
+
|| detectFirefoxOSTablet()
|
1225
|
+
|| detectUbuntuTablet()
|
1090
1226
|
|| detectWebOSTablet()) {
|
1091
1227
|
return true;
|
1092
1228
|
}
|
@@ -1101,10 +1237,6 @@ public class UAgentInfo {
|
|
1101
1237
|
* @return detection of any device in the iPhone/Android/Windows Phone/BlackBerry/WebOS Tier
|
1102
1238
|
*/
|
1103
1239
|
public boolean detectTierIphone() {
|
1104
|
-
if ((this.initCompleted == true) ||
|
1105
|
-
(this.isTierIphone == true))
|
1106
|
-
return this.isTierIphone;
|
1107
|
-
|
1108
1240
|
if (detectIphoneOrIpod()
|
1109
1241
|
|| detectAndroidPhone()
|
1110
1242
|
|| detectWindowsPhone()
|
@@ -1114,6 +1246,9 @@ public class UAgentInfo {
|
|
1114
1246
|
|| detectPalmWebOS()
|
1115
1247
|
|| detectBada()
|
1116
1248
|
|| detectTizen()
|
1249
|
+
|| detectFirefoxOSPhone()
|
1250
|
+
|| detectSailfishPhone()
|
1251
|
+
|| detectUbuntuPhone()
|
1117
1252
|
|| detectGamingHandheld()) {
|
1118
1253
|
return true;
|
1119
1254
|
}
|
@@ -1129,12 +1264,7 @@ public class UAgentInfo {
|
|
1129
1264
|
* @return detection of any device in the 'Rich CSS' Tier
|
1130
1265
|
*/
|
1131
1266
|
public boolean detectTierRichCss() {
|
1132
|
-
if ((this.initCompleted == true) ||
|
1133
|
-
(this.isTierRichCss == true))
|
1134
|
-
return this.isTierRichCss;
|
1135
|
-
|
1136
1267
|
boolean result = false;
|
1137
|
-
|
1138
1268
|
//The following devices are explicitly ok.
|
1139
1269
|
//Note: 'High' BlackBerry devices ONLY
|
1140
1270
|
if (detectMobileQuick()) {
|
@@ -1151,9 +1281,9 @@ public class UAgentInfo {
|
|
1151
1281
|
|| detectWindowsMobile()
|
1152
1282
|
|| userAgent.indexOf(engineTelecaQ) != -1) {
|
1153
1283
|
result= true;
|
1154
|
-
}
|
1155
|
-
}
|
1156
|
-
}
|
1284
|
+
} // if detectWebkit()
|
1285
|
+
} //if !detectTierIphone()
|
1286
|
+
} //if detectMobileQuick()
|
1157
1287
|
return result;
|
1158
1288
|
}
|
1159
1289
|
|
@@ -1164,16 +1294,12 @@ public class UAgentInfo {
|
|
1164
1294
|
* @return detection of a mobile device in the less capable tier
|
1165
1295
|
*/
|
1166
1296
|
public boolean detectTierOtherPhones() {
|
1167
|
-
if ((this.initCompleted == true) ||
|
1168
|
-
(this.isTierGenericMobile == true))
|
1169
|
-
return this.isTierGenericMobile;
|
1170
|
-
|
1171
1297
|
//Exclude devices in the other 2 categories
|
1172
1298
|
if (detectMobileLong()
|
1173
1299
|
&& !detectTierIphone()
|
1174
|
-
&& !detectTierRichCss())
|
1300
|
+
&& !detectTierRichCss()) {
|
1175
1301
|
return true;
|
1176
|
-
|
1302
|
+
}
|
1177
1303
|
return false;
|
1178
1304
|
}
|
1179
|
-
}
|
1305
|
+
}
|