Site Metrics and Web Analytics by NextSTAT

Tuesday, November 20, 2012

Google cancels Christmas? Why Android can't remember December


Zero-index error in coding for month picker in 'Jelly Bean' means that you can't add birthdates in December to your contacts.

If you've got Android 4.2 on your device - whether phone or tablet - congratulations: you've got the most modern version of Google's mobile operating system.

However, you might discover a problem if you're trying to add peoples' birthdays to your contacts, and they happen to be born in December. Reason: Android 4.2 doesn't include December as a month for peoples' birthdays.

That means that anyone who has 4.2 will have to wait for 4.2.1 to roll out if this is important. At the moment, it's not clear when that might be. Though Google is apparently aware of the problem, it will need to make the update, package it and get it distributed via carriers and thus to the majority of Android devices running 4.2, or directly to owners of Nexus devices.
The problem was first spotted by Android Police, which wrote:
File this one under How did Google not have a test for this? Got a birthday or anniversary in December? Sorry - Android 4.2 doesn't know what December is. Well, rather the People/Contacts app that comes stock and is part of the Android Open Source Project (AOSP) doesn't. Wait... what?
We couldn't believe it either, but it's true. Google forgot to include December. As in, there are 11 months in a year. January after November. Christmas is ruined. Santa is dead. At least we'll save money on buying presents, right?
Here's the discussion on the Android code site, where it was first raised on 14 November by a user who complained "Today I was inserting birthday of a friend in my contact list so that I can sync the birthdays in my calendar. I noticed that the December month is missing. When I pressed new event the calendar came but it was not having the option for the month December."

The cause turns out to be a subtle but common one in the world of programming: an off-by-one mistake, where the array that's used for the month references is zero-indexed, so it goes {0,1,2,3… 11}. But the month numbers go {1,2,3….12}. If you shift the index by 1, but forget to allow the highest value of the array to be 12 rather than 11, you'll kill December.

As one of the commenters on the Google thread explains, having tracked down the offending tweak (itself fixing a crashing bug): "It checks "maxValue" and resets it to ".length - 1" it's too high. But DatePicker.java (line 140) sets maxValue to 12 and the string array "months" is only 12 entries long so maxValue gets truncated to 11 by the new check in this commit which in the end will skip "December" as it is the 12th and last month.

The name of the Google staffer who made the change on Friday September 28 is clearly shown in the commit file (it was before lunch, too, so can't blame that).
This ought not to affect existing contacts with December birthdays, because this is a flaw in the input method, not the data store.

Another staffer at Google has spotted the error, and it's now a filed bug (and the programmer who caused it is cc'd in).

So another subtle coding error victim - to add to the Zune leap-year bug and (as far as we know, though it's never been acknowledged) Apple's daylight savings time alarm bug.

Now the only question is how long it will take for this to roll out.

Source: guardian.co.uk

0 σχόλια:

Post a Comment