You could probably move the android check to line 35 and avoid a lot of the duplicate code.  Also it'd be helpful to comment this or add a link to this pull request in the comments.