Bug 1095914 - Fix NPE due to no telephony manager. r=vng, a=lsblakk
authorGarvan Keeley <gkeeley@mozilla.com>
Sat, 08 Nov 2014 09:08:00 -0500
changeset 233999 a3ae3d724956576aafc6609d961ed28d75de3cd7
parent 233998 bd7fbe828b1080f9b7e66f66cd4550e0501caf9b
child 234000 5c8a21d22dc32013747d837d045b805cd5975c48
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvng, lsblakk
bugs1095914
milestone35.0a2
Bug 1095914 - Fix NPE due to no telephony manager. r=vng, a=lsblakk https://github.com/mozilla/MozStumbler/pull/1194 1185 NPE Reporter.startup (no telephony manager)
mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
@@ -58,17 +58,22 @@ public final class Reporter extends Broa
 
     void startup(Context context) {
         if (mIsStarted) {
             return;
         }
 
         mContext = context.getApplicationContext();
         TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
-        mPhoneType = tm.getPhoneType();
+        if (tm != null) {
+            mPhoneType = tm.getPhoneType();
+        } else {
+            Log.d(LOG_TAG, "No telephony manager.");
+            mPhoneType = TelephonyManager.PHONE_TYPE_NONE;
+        }
 
         mIsStarted = true;
 
         resetData();
         IntentFilter intentFilter = new IntentFilter();
         intentFilter.addAction(WifiScanner.ACTION_WIFIS_SCANNED);
         intentFilter.addAction(CellScanner.ACTION_CELLS_SCANNED);
         intentFilter.addAction(GPSScanner.ACTION_GPS_UPDATED);