A Grid-Based Algorithm for On-Device GSM Positioning