oalders/http-browserdetect

This Kindle Fire doesn't get detected as such

akarelas opened this issue · 9 comments

Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Safari/533.1

$ua->kindlefire == 0

Whereas MY test detects it as such:

my $is_amazon = $ua->android && ($ua->silk or $ua_string =~ /\bKF[A-Z]+\s+Build\// or $ua_string =~ /\bkindle\b/i);
$is_amazon == 1;

I found this user-agent string here: https://developer.amazon.com/public/solutions/devices/fire-tablets/specifications/04-user-agent-strings

Sure, should be easy to fix. The pull request I made should address Kindle Fires that use "Kindle Fire" as the model instead of "KFxx". How about the $ua->silk case though? Do you see a UA string that identifies the browser as silk but the model doesn't match either "Kindle Fire" or "KFxx"?

It says right here: http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html

that a 1st-generation Silk UA string for mobile is this:

Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Silk/1.0.13.81_10003810) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Silk-Accelerated=true

No KF substring.

Though if someday Silk comes out for other Android devices, then we're in trouble with my method.

Wait, what? I'm confused now. Kindle Fire is a tablet, Fire Phone is a mobile device, Silk is a browser which runs on both of those things. I have that right, right?

The three UA strings under "Examples of the Amazon Silk User Agent String" on the page you just sent look like things we should test; I'm not 100% sure that we're handling them properly right now, especially that "desktop" value (which is a Kindle Fire tablet which has been configured to pretend to be a desktop... right?) The UA strings under "UA for Kindle Fire 1st Generation" don't make sense to me, because they include a mobile example, and I thought "Kindle Fire 1st Generation" would only refer to the Kindle Fire tablet, not anything I would call mobile.

Am I missing something? I feel like I'm missing something. Does "Kindle Fire" also refer to the Fire phone or something?

I have no idea whether Kindle Fire is just a tablet. I don't know much about Amazon's devices. Sorry, but I can't be of much help on this.

Okay, I read Amazon's web site for a while and I think I figured it out. I was missing something; that "mobile" entry indicates a Kindle Fire tablet configured to pretend it's a mobile device. Fire Phones are a different issue.

The code in my pull request does correctly distinguish between tablet, desktop, and mobile for Kindle Fire devices depending on what they've been configured to pretend to be. It doesn't always correctly identify the device; a Kindle Fire configured to pretend to be a desktop will set its user agent like a Linux system with a Silk browser, and that's what we report to the user, which in my opinion is what we should be doing. If the web user is pretending to be a desktop, I think we should honor that pretense in what we report, so that the interface the web user sees is appropriate to what they want.

I don't really see harm in setting kindlefire() for any case where the user agent is recognizably identifying itself as such; I'll amend the pull request to do that. We're not setting kindlefire() in all cases right now. I think though that for what you want ("Is this an Amazon branded device?"), probably $ua->kindlefire || $ua->silk is actually what you should be doing. You're going to need to do that anyway to catch Fire Phones (which in the current interface wouldn't have kindlefire() set).

Okay, I updated the pull request to have the best behavior I could figure out. There are some tricky cases as mentioned above (the Linux machine that's really a tablet pretending to be a desktop), but I implemented it with what'll lead to the best behavior I could determine. In a lot of cases that means honoring what the Kindle Fire is pretending to be even if we know better (and sometimes setting kindlefire() alongside linux() or some equally confusing thing).

Thanks. So, if an Amazon phone uses a browser other than Silk, there's no way to detect it as being an Amazon one?

We could. The code in the pull request will theoretically detect Kindle Fire tablets running a non-Silk browser (assuming that's even possible) as long as the browser reports the model string in the same format as for other Android devices. There's no reason we couldn't do the same thing to detect Fire Phones running non-Silk browsers (again assuming that's even possible). I'd really rather have a real user-agent string to work from in order to do that, though; writing test cases based on guessing what things might look like doesn't sound good. :-)

Ok...! Thanks.