This method is created twice. In order to prevent DRY how about you move it to one of the utility classes? Maybe DeviceUtils?