Commit 6f6208d9 authored by Bartek Fabiszewski's avatar Bartek Fabiszewski
Browse files

Fix potential null pointer dereference

parent b4016de0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -86,7 +86,9 @@ public class LoggerService extends Service {
        if (Logger.DEBUG) { Log.d(TAG, "[onCreate]"); }

        mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (mNotificationManager != null) {
            mNotificationManager.cancelAll();
        }

        locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locListener = new mLocationListener();
+3 −3
Original line number Diff line number Diff line
@@ -65,9 +65,9 @@ class ProviderPreference extends ListPreference {

        LocationManager locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        missingProviders = new ArrayList<>();
        final boolean existsGPS = locManager.getAllProviders().contains(LocationManager.GPS_PROVIDER);
        final boolean existsNet = locManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER);
        if (Logger.DEBUG) { Log.d(TAG, "[Providers available: " + locManager.getAllProviders()); }
        final boolean existsGPS = locManager != null && locManager.getAllProviders().contains(LocationManager.GPS_PROVIDER);
        final boolean existsNet = locManager != null && locManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER);
        if (Logger.DEBUG) { Log.d(TAG, "[Providers available: " + (locManager != null ? locManager.getAllProviders() : null)); }
        defaultValue = VALUE_ALL;
        if (!existsGPS) {
            missingProviders.add(VALUE_GPS);
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class WebHelper {
    private String postWithParams(Map<String, String> params) throws IOException, WebAuthException {
        URL url = new URL(host + "/" + CLIENT_SCRIPT);
        if (Logger.DEBUG) { Log.d(TAG, "[postWithParams: " + url + " : " + params + "]"); }
        String response = null;
        String response;

        String dataString = "";
        for (Map.Entry<String, String> p : params.entrySet()) {
+6 −2
Original line number Diff line number Diff line
@@ -78,7 +78,9 @@ public class WebSyncService extends IntentService {
            // cancel pending alarm
            if (Logger.DEBUG) { Log.d(TAG, "[websync cancel alarm]"); }
            AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
            if (am != null) {
                am.cancel(pi);
            }
            pi = null;
        }

@@ -206,9 +208,11 @@ public class WebSyncService extends IntentService {
            AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
            Intent syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
            pi = PendingIntent.getService(this, 0, syncIntent, FLAG_ONE_SHOT);
            if (am != null) {
                am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + FIVE_MINUTES, pi);
            }
        }
    }

    /**
     * Convert cursor to map of request parameters