Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
import org.mtransit.commons.GTFSCommons;
import org.mtransit.commons.SourceUtils;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.UnknownHostException;
Expand Down Expand Up @@ -975,15 +977,29 @@ private List<ServiceUpdate> loadAgencyServiceUpdateDataFromWWW(@NonNull Context
setServiceUpdateLastUpdateCode(567); // SSL certificate not trusted (on this device)
getStorage(context).saveServiceUpdateLastUpdateMs(TimeUtils.currentTimeMillis());
return null;
} catch (InterruptedIOException iioe) {
MTLog.w(this, iioe, "Connection timeout!");
setServiceUpdateLastUpdateCode(567);
getStorage(context).saveServiceUpdateLastUpdateMs(TimeUtils.currentTimeMillis());
return null;
} catch (UnknownHostException uhe) {
if (MTLog.isLoggable(android.util.Log.DEBUG)) {
MTLog.w(this, uhe, "No Internet Connection!");
} else {
MTLog.w(this, "No Internet Connection!");
}
setServiceUpdateLastUpdateCode(567);
getStorage(context).saveServiceUpdateLastUpdateMs(TimeUtils.currentTimeMillis());
return null;
} catch (SocketException se) {
MTLog.w(LOG_TAG, se, "No Internet Connection!");
setServiceUpdateLastUpdateCode(567);
getStorage(context).saveServiceUpdateLastUpdateMs(TimeUtils.currentTimeMillis());
return null;
} catch (IOException ioe) {
MTLog.w(this, ioe, "I/O error!");
setServiceUpdateLastUpdateCode(567);
getStorage(context).saveServiceUpdateLastUpdateMs(TimeUtils.currentTimeMillis());
return null;
Comment thread
mmathieum marked this conversation as resolved.
} catch (Exception e) { // Unknown error
MTLog.e(LOG_TAG, e, "INTERNAL ERROR: Unknown Exception");
Expand Down Expand Up @@ -1711,6 +1727,8 @@ private void initAllDbTables(@NonNull SQLiteDatabase db) {
db.execSQL(T_GTFS_REAL_TIME_VEHICLE_LOCATION_SQL_CREATE);
db.execSQL(T_GTFS_REAL_TIME_SERVICE_UPDATE_SQL_CREATE);
storage.saveServiceUpdateLastUpdateMs(null);
storage.saveTripUpdateLastUpdateMs(null);
storage.saveVehicleLocationLastUpdateMs(null);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.mtransit.android.commons.provider.ca.info.stm

import android.content.Context
import android.util.Log
import androidx.annotation.VisibleForTesting
import org.mtransit.android.commons.Constants
import org.mtransit.android.commons.HtmlUtils
Expand Down Expand Up @@ -231,7 +230,7 @@ object StmInfoServiceUpdateProvider : MTLog.Loggable {
getStorage(context).saveServiceUpdateLastUpdate(TimeUtilsK.currentInstant())
return null
} catch (uhe: UnknownHostException) {
if (MTLog.isLoggable(Log.DEBUG)) {
if (MTLog.isLoggable(android.util.Log.DEBUG)) {
MTLog.w(this@StmInfoServiceUpdateProvider, uhe, "No Internet Connection!")
} else {
MTLog.w(this@StmInfoServiceUpdateProvider, "No Internet Connection!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ class GtfsRealTimeStorage(
prefLcl.getLong(PREF_KEY_TRIP_UPDATE_LAST_UPDATE_MS, default)

@WorkerThread
fun saveTripUpdateLastUpdateMs(lastUpdateInMs: Long) {
prefLcl.edit { putLong(PREF_KEY_TRIP_UPDATE_LAST_UPDATE_MS, lastUpdateInMs) }
fun saveTripUpdateLastUpdateMs(lastUpdateInMs: Long?) {
prefLcl.edit {
lastUpdateInMs?.let { putLong(PREF_KEY_TRIP_UPDATE_LAST_UPDATE_MS, it) }
?: remove(PREF_KEY_TRIP_UPDATE_LAST_UPDATE_MS)
}
}

@WorkerThread
Expand Down Expand Up @@ -77,8 +80,11 @@ class GtfsRealTimeStorage(
prefLcl.getLong(PREF_KEY_VEHICLE_LOCATION_LAST_UPDATE_MS, default)

@WorkerThread
fun saveVehicleLocationLastUpdateMs(lastUpdateInMs: Long) {
prefLcl.edit { putLong(PREF_KEY_VEHICLE_LOCATION_LAST_UPDATE_MS, lastUpdateInMs) }
fun saveVehicleLocationLastUpdateMs(lastUpdateInMs: Long?) {
prefLcl.edit {
lastUpdateInMs?.let { putLong(PREF_KEY_VEHICLE_LOCATION_LAST_UPDATE_MS, it) }
?: remove(PREF_KEY_VEHICLE_LOCATION_LAST_UPDATE_MS)
}
}

@WorkerThread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.mtransit.android.commons.provider.status

import android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND
import android.content.Context
import android.util.Log
import com.google.transit.realtime.headerOrNull
import org.mtransit.android.commons.Constants
import org.mtransit.android.commons.MTLog
Expand Down Expand Up @@ -37,6 +36,7 @@ import org.mtransit.android.commons.provider.gtfs.storage
import org.mtransit.commons.SourceUtils
import java.io.File
import java.io.IOException
import java.io.InterruptedIOException
import java.net.HttpURLConnection
import java.net.SocketException
import java.net.UnknownHostException
Expand All @@ -46,8 +46,8 @@ import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
import com.google.transit.realtime.GtfsRealtime.FeedMessage as GFeedMessage
import com.google.transit.realtime.GtfsRealtime.TripUpdate as GTripUpdate
import com.google.transit.realtime.GtfsRealtime.TripDescriptor.ScheduleRelationship as GTDScheduleRelationship
import com.google.transit.realtime.GtfsRealtime.TripUpdate as GTripUpdate

object GTFSRealTimeTripUpdatesProvider : MTLog.Loggable {

Expand Down Expand Up @@ -453,15 +453,29 @@ object GTFSRealTimeTripUpdatesProvider : MTLog.Loggable {
storage.saveTripUpdateLastUpdateCode(567) // SSL certificate not trusted (on this device)
storage.saveTripUpdateLastUpdateMs(TimeUtils.currentTimeMillis())
return false
} catch (iioe: InterruptedIOException) {
MTLog.w(LOG_TAG, iioe, "Connection timeout!")
storage.saveTripUpdateLastUpdateCode(567)
storage.saveTripUpdateLastUpdateMs(TimeUtils.currentTimeMillis())
return false
} catch (uhe: UnknownHostException) {
if (MTLog.isLoggable(Log.DEBUG)) {
if (MTLog.isLoggable(android.util.Log.DEBUG)) {
MTLog.w(LOG_TAG, uhe, "No Internet Connection!")
} else {
MTLog.w(LOG_TAG, "No Internet Connection!")
}
storage.saveTripUpdateLastUpdateCode(567)
storage.saveTripUpdateLastUpdateMs(TimeUtils.currentTimeMillis())
return false
} catch (se: SocketException) {
MTLog.w(LOG_TAG, se, "No Internet Connection!")
storage.saveTripUpdateLastUpdateCode(567)
storage.saveTripUpdateLastUpdateMs(TimeUtils.currentTimeMillis())
return false
} catch (ioe: IOException) {
MTLog.w(LOG_TAG, ioe, "I/O error!")
storage.saveTripUpdateLastUpdateCode(567)
storage.saveTripUpdateLastUpdateMs(TimeUtils.currentTimeMillis())
return false
Comment thread
mmathieum marked this conversation as resolved.
Comment thread
mmathieum marked this conversation as resolved.
} catch (e: Exception) { // Unknown error
MTLog.e(LOG_TAG, e, "INTERNAL ERROR: Unknown Exception")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import org.mtransit.android.commons.provider.gtfs.storage
import org.mtransit.android.commons.provider.vehiclelocations.VehicleLocationProvider.Companion.getCachedVehicleLocationsS
import org.mtransit.android.commons.provider.vehiclelocations.model.VehicleLocation
import org.mtransit.android.commons.secsToInstant
import java.io.IOException
import java.io.InterruptedIOException
import java.net.HttpURLConnection
import java.net.SocketException
import java.net.UnknownHostException
Expand Down Expand Up @@ -248,15 +250,29 @@ object GTFSRealTimeVehiclePositionsProvider : MTLog.Loggable {
storage.saveVehicleLocationLastUpdateCode(567) // SSL certificate not trusted (on this device)
storage.saveVehicleLocationLastUpdateMs(TimeUtils.currentTimeMillis())
return null
} catch (iioe: InterruptedIOException) {
MTLog.w(LOG_TAG, iioe, "Connection timeout!")
storage.saveVehicleLocationLastUpdateCode(567)
storage.saveVehicleLocationLastUpdateMs(TimeUtils.currentTimeMillis())
return null
} catch (uhe: UnknownHostException) {
if (MTLog.isLoggable(android.util.Log.DEBUG)) {
MTLog.w(LOG_TAG, uhe, "No Internet Connection!")
} else {
MTLog.w(LOG_TAG, "No Internet Connection!")
}
storage.saveVehicleLocationLastUpdateCode(567)
storage.saveVehicleLocationLastUpdateMs(TimeUtils.currentTimeMillis())
return null
} catch (se: SocketException) {
MTLog.w(LOG_TAG, se, "No Internet Connection!")
storage.saveVehicleLocationLastUpdateCode(567)
storage.saveVehicleLocationLastUpdateMs(TimeUtils.currentTimeMillis())
return null
} catch (ioe: IOException) {
MTLog.w(LOG_TAG, ioe, "I/O error!")
storage.saveVehicleLocationLastUpdateCode(567)
storage.saveVehicleLocationLastUpdateMs(TimeUtils.currentTimeMillis())
return null
Comment thread
mmathieum marked this conversation as resolved.
Comment thread
mmathieum marked this conversation as resolved.
} catch (e: Exception) { // Unknown error
MTLog.e(LOG_TAG, e, "INTERNAL ERROR: Unknown Exception")
Expand Down