uap-core icon indicating copy to clipboard operation
uap-core copied to clipboard

Android fixes

Open ajvondrak opened this issue 9 years ago • 4 comments

I've just observed (in the wild) a couple of user agents that appear to specify the Android API level instead of the actual Android OS version, even though they're isomorphic:

Mozilla/5.0 (Linux; U; Android 19; en-us; sm-p607t Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

Mozilla/5.0 (Linux; U; Android 16; en-us; samsung-sgh-i437p Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

I can't seem to find any references online that indicate Android may send along the API level instead of the OS version, but it also seemed easy to just drop in some v1_replacement & v2_replacement statements for all the API levels to date. I've also gone ahead and added/corrected "funky" Android UAs for newer versions code names.

Not sure yet if all the tests will pass, so I'm submitting this PR and waiting for the Travis build. Might take a couple more commits, depending on any issues discovered. EDIT: And there we go, everything's green. Let me know how it looks!

ajvondrak avatar Mar 06 '15 18:03 ajvondrak

I have strong doubts that this PR can be accepted this way, as you do not deal with real user-agent strings. I can hardly imagine that Samsung supports the oldest as well as the newest version for an initial Android 4.3 device.

Mozilla/5.0 (Linux; U; Android 1.0; en-us; samsung-sgh-i437p Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Mozilla/5.0 (Linux; U; Android 21; en-us; samsung-sgh-i437p Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

Please provide real user-agents.

commenthol avatar Mar 13 '15 05:03 commenthol

You're right, they aren't "real" user agent strings. The only two I've seen in the wild are the ones noted in my first comment. I used those UAs to extrapolate "fake" ones for the various ways of specifying Android versions.

I'd love to use more legitimate user agents, but...

  1. Where do you suggest I find an exhaustive list of real UAs for each of the (apparent) ways of specifying Android versions? Like I said, I couldn't find any reference online---even for Samsung devices---that suggested they sent API levels instead of actual versions, and yet there sit the examples I saw on my own website. Do I wait until I see traffic from a certain API level before adding it as a test? (Even though that means there will almost certainly be holes in the test cases.)
  2. The concept of "real" user agents is a bit tenuous, since the strings are essentially arbitrary to begin with. Basically GIGO: nothing could stop someone from sending Mozilla/5.0 (Linux; U; Android 1.0; en-us; samsung-sgh-i437p Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 as their user agent. If they did (and unless uap-core got regexes to parse Build/* versions), what other version of Android would the string parse as, if not Android 1.0? Would it be better if I just removed the samsung-sgh-i437p Build/JWR66Y from all those test cases, since it has no bearing on the (OS) test at hand?
  3. If, down the line, there was something more accurate for that string to parse as, it's not like the test is infallible: fix the tests if they need fixing. After all, that's what had to happen for the existing Android Donut = 1.2 test case (Donut is actually 1.6). But perhaps I'm more cavalier here than the maintainers of uap-core.

I'll go hunting through my logs for all the real cases I can find, but assuming there are holes in my traffic & in people's proclivity for weird UAs...is there really much harm in extrapolating some test cases for the other version replacements? Do you prefer there to be holes in the test suite, as long as all the UAs are "real" ones? The only alternative I could think of for maintaing parity between the regexes & tests is to remove regexes for, say, Android API level 15 if I can't find a test case for it (even though we can observe other API levels getting sent & intuit what Android 15 should parse as). I assume this wouldn't be preferable?

ajvondrak avatar Mar 13 '15 16:03 ajvondrak

At any rate, I have trudged out some interesting examples from my logs - not exhaustive, but looking somewhat thorough so far (and still looking compliant with the formats tested by the existing test cases in this PR, by the by...):

Android Version User Agent
Android 8 Mozilla/5.0 (Linux; U; Android 8; en-us; vm670 Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 10 Mozilla/5.0 (Linux; U; Android 10; en-us; lg-l38c Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 12 Mozilla/5.0 (Linux; U; Android 12; en-us; lg-v909 Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 13 Mozilla/5.0 (Linux; U; Android 13; en-us; a100 Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 15 Mozilla/5.0 (Linux; U; Android 15; en-us; sch-s738c Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 16 Mozilla/5.0 (Linux; U; Android 16; en-us; sgh-t599n Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 17 Mozilla/5.0 (Linux; U; Android 17; en-us; htc6435lvw Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 18 Mozilla/5.0 (Linux; U; Android 18; en-us; c6530n Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 19 Mozilla/5.0 (Linux; U; Android 19; en-us; sm-n900v Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 20 Mozilla/5.0 (Linux; U; Android 20; en-us; nexus 5 Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 21 Mozilla/5.0 (Linux; U; Android 21; en-us; nexus 7 Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 1.5 Mozilla/5.0 (Linux; U; Android 1.5; es-us; MB501 Build/CUPCAKE) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1
Android 1.6 Mozilla/5.0 (Linux; U; Android 1.6; en-us; calgary Build/DRC92) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1
Android 2.0 Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17
Android 2.0.1 Mozilla/5.0 (Linux; U; Android 2.0.1; en-us; Droid Build/ESD56) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17
Android 2.1 Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; S7 Build/4749) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.2 Mozilla/5.0 (Android 2.2; Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Android 2.2.1 Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; SCH-I510 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.2.2 Mozilla/5.0 (Linux; U; Android 2.2.2; en-us; SCH-M828C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.2.3 Mozilla/5.0 (Linux; U; Android 2.2.3; en-us; Droid Build/FRK76) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3 Mozilla/5.0 (Linux; U; Android 2.3; en-us) AppleWebKit/999+ (KHTML, like Gecko) Safari/999.9
Android 2.3.1 Mozilla/5.0 (Linux; U; Android 2.3.1; en-us; NXM726HN Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3.2 Mozilla/5.0 (Linux; U; Android 2.3.2; en-us Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3.3 Mozilla/5.0 (Linux; U; Android 2.3.3; en-gb; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3.4 Mozilla/5.0 (Linux; U; Android 2.3.4; en-my; HTC Flyer P510e Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3.5 Dalvik/1.4.0 (Linux; U; Android 2.3.5; PC36100 Build/GRJ90)
Android 2.3.6 Mozilla/5.0 (Linux; U; Android 2.3.6; en-gb; GT-S5839i Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3.7 Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; XT557 Build/V1.65K) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 2.3.9 Mozilla/5.0 (Linux; U; Android 2.3.9; en-us; X10i Build/6.0.B.0.743) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 3.0 Mozilla/5.0 (Linux; U; Android 3.0; en-us; MID_Serials Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 3.0.1 Dalvik/1.5.0 (Linux; U; Android 3.0.1; LG-V905R Build/HRI66)
Android 3.1 Mozilla/5.0 (Linux; U; Android 3.1; en-us; GT-P7510 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
Android 3.2 Mozilla/5.0 (Linux; U; Android 3.2; en-us; SGH-T869 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
Android 3.2.1 Mozilla/5.0 (Linux; U; Android 3.2.1; en-us; PantechP4100 Build/HTK75) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
Android 3.2.2 Dalvik/1.5.1 (Linux; U; Android 3.2.2; MZ617 Build/1.6.0M_279_MZ617)
Android 4.0 Mozilla/5.0 (Linux; U; Android 4.0; en-us; SKK A7 Build/MocorDroid2.3.5) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 4.0.1 Mozilla/5.0 (Linux; U; Android 4.0.1; en-us; Galaxy Nexus Build/ITL41F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.0.2 Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 wiziapp_user_agent=android_app
Android 4.0.3 Dalvik/1.6.0 (Linux; U; Android 4.0.3; HTC Desire C Build/IML74K)
Android 4.0.4 Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; BNTV400 Build/IMM76L) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.0.4.0.4.0.4 Mozilla/5.0 (Linux; U; Android 4.0.4.0.4.0.4; en-us; Build/IMM76L) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.1 Dalvik/1.6.0 (Linux; U; Android 4.1; UM-A13B Build/IMM76D)
Android 4.1.1 Dalvik/1.6.0 (Linux; U; Android 4.1.1; HUAWEI Y300-0151 Build/HuaweiY300-0151)
Android 4.1.2 Mozilla/5.0 (Linux; U; Android 4.1.2; sv-se; GT-I9100 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.1.4 Mozilla/5.0 (Linux; U; Android 4.1.4; en-us; Luna TAB07-101 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.1.9 Mozilla/5.0 (Linux; U; Android 4.1.9; es-us; I9220 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.2 Mozilla/5.0 (Linux; U; Android 4.2; en-gb; Nexus 7 Build/JOP40C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.2.0 Mozilla/5.0 (Linux; U; Android 4.2.0; en-au; MID-756 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.2.1 Mozilla/5.0 (Linux; U; Android 4.2.1; en-us; WM-8880-MID Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.2.2 Mozilla/5.0 (Linux; U; Android 4.2.2; tr-tr; SM-T310 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.2.3 Mozilla/5.0 (Linux; U; Android 4.2.3; zh-tw; T200S Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.2.9 Mozilla/5.0 (Linux; U; Android 4.2.9; en-us; TURBO DG2014 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.3 Mozilla/5.0 (Linux; U; Android 4.3; en-gb; GT-I9300 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.3.0 Mozilla/5.0 (Linux; U; Android 4.3.0; zh-cn; GT-I9300 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.3.1 Mozilla/5.0 (Linux; Android 4.3.1; Touchpad Build/JLS36I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Safari/537.36
Android 4.3.2 Mozilla/5.0 (Linux; U; Android 4.3.2; en-us; T90 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.3.2.1.000.000 Mozilla/5.0 (Linux; U; Android 4.3.2.1.000.000; en-us; Amazon Kindle Fire Build/OPENMASTER) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.3.3 Dalvik/1.6.0 (Linux; U; Android 4.3.3; GT-I9100 Build/JZO54K)
Android 4.3.9 Mozilla/5.0 (Linux; U; Android 4.3.9; zh-tw; ASK 882SP HD Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 4.4 Mozilla/5.0 (Linux; Android 4.4; LGL34C Build/KRT16S.L34CV10c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Android 4.4.0 Mozilla/5.0 (Linux; U; Android 4.4.0; en-us; Android Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Android 4.4.1 Mozilla/5.0 (Linux; Android 4.4.1; Nexus 4 Build/KOT49E) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Android 4.4.2 Mozilla/5.0 (Linux; Android 4.4.2; VS980 4G Build/KOT49I.VS98027A) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Android 4.4.3 Mozilla/5.0 (Linux; Android 4.4.3; KFTHWI Build/KTU84M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/34.0.0.0 Safari/537.36
Android 4.4.4 Mozilla/5.0 (Linux; Android 4.4.4; SM-G900V Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36
Android 4.4.99 Mozilla/5.0 (Linux; Android 4.4.99; tbonethagr8 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Mobile Safari/537.36
Android 5.0 Mozilla/5.0 (Linux; Android 5.0; XT1096 Build/LXE22.46-11) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36
Android 5.0.1 Mozilla/5.0 (Linux; Android 5.0.1; LGLS990 Build/LRX21Y) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36
Android 5.0.2 Mozilla/5.0 (Linux; Android 5.0.2; Xperia Z3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36
Android 5.1 Mozilla/5.0 (Linux; Android 5.1; Nexus 5 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36
Android 5.1.3.0 Mozilla/5.0 (Linux; U; Android 5.1.3.0; zh-cn; Unknown Build/Unknown) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 hao123/5.1.3.0 (Baidu; P1 4.3)/OVONEL_81_3.4_t887A+ovoneL/381b/a76b47ba509becdc788123f257d4b8f8/1/5.1.3.0/94/1
Android 5.2.1 Mozilla/5.0 (Linux; U; Android 5.2.1(Android 5.1.1); es-es; mtk6515_6626_gb2 Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Android 5.2.2 Mozilla/5.0 (Linux; U; Android 5.2.2; en-us; GT90H Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Android 6.0 Mozilla/5.0 (Linux; Android 6.0; SPH-L720 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Android 9.0 Mozilla/5.0 (Linux; Android 9.0; SP-92A Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36
Android Eclair Mozilla/5.0 (Linux; U; Android Eclair; en-us Build/ECLAIR) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17
Android Jelly Bean Dalvik/1.6.0 (Linux; U; Android Jelly Bean 4.1.2; GT-P3100 Build/JZO54K)

Still looking further back. We'll see how many examples I can find...

ajvondrak avatar Mar 13 '15 18:03 ajvondrak

Maybe i'm stupid...my android version (google play) doesn't match my phone info (settings). Moreover, my chrome version does'nt match my dashboard...mostly, I only have the cell phone-no CPU! My logs and my files are remotely used and my location sign on is 1000 miles away! Who the hell?

jakesterdawg avatar Sep 13 '15 01:09 jakesterdawg