-
public class DoorstepAI
-
-
Field Summary
Fields Modifier and Type Field Description private BooleandevModeprivate BooleanmanualForegroundprivate DoubleautoStopAfterDropoffSecondsprivate final Flow<GeofenceSessionEvent>geofenceSessionEventsprivate final List<DeliveryStop>monitoredStopsprivate final Flow<Long>configFetchedpublic final static DoorstepAIINSTANCE
-
Method Summary
Modifier and Type Method Description final Unitinit(Context context, String notificationTitle, String notificationText, Function1<Result<Unit>, Unit> callback)final UnitstartDeliveryByPlaceID(String placeID, String deliveryId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByPlaceID(String placeID, String deliveryId, Double timeoutSeconds, Boolean manualForeground, Double autoStopAfterDropoffSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)final UnitretryGnssCallbacks()Retry GNSS callback registration after permissions have been granted. final UnitstartDeliveryByPlusCode(String plusCode, String deliveryId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByPlusCode(String plusCode, String deliveryId, Double timeoutSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByAddressString(String address, String deliveryId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByAddressString(String address, String deliveryId, Double timeoutSeconds, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByAddressString(String address, String deliveryId, LatLngObject coordinates, Double timeoutSeconds, Boolean manualForeground, Double autoStopAfterDropoffSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByLatLng(Double latitude, Double longitude, String deliveryId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByLatLng(Double latitude, Double longitude, String subUnit, String deliveryId, Double timeoutSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByAddressType(AddressType address, String deliveryId, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByAddressType(AddressType address, String deliveryId, Double timeoutSeconds, Function1<Result<String>, Unit> callback)final UnitstartDeliveryByAddressType(AddressType address, String deliveryId, LatLngObject coordinates, Double timeoutSeconds, Boolean manualForeground, Double autoStopAfterDropoffSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)final UnitnewEvent(String eventName, String deliveryId, Double timestamp, Function1<Result<String>, Unit> callback)final UnitnewEvent(String eventName, String deliveryId, Double timestamp)final UnitmarkDropoff(String deliveryId, DropoffType dropoffType)final UnitstopDelivery(String deliveryId)Stop a delivery. final UnitstartRouteGeofencing(List<DeliveryStop> stops, RouteGeofenceOptions options, Function1<Result<Unit>, Unit> callback)Begin in-SDK route geofencing for stops. final UnitupdateRouteStops(List<DeliveryStop> stops, Function1<Result<Unit>, Unit> callback)Replace the active route's stop set mid-route (add/remove). final UnitstopRouteGeofencing()Stop route geofencing: clear all geofences, stop any active route sessions, end the service. final UnitresumeRouteGeofencingIfNeeded()Idempotent restore of route geofencing from persisted state. final UnitsetAPIKey(String key, Boolean shouldGetConfig)Set the bearer token used by every Network call and (by default) trigger an immediate config fetch. final UnitsetConfigOverride(String patchJson, Boolean enabled)Set or clear a config override. final BooleanisConfigOverrideEnabled()True if a config override is currently active. final StringgetConfigOverridePatch()The stored override patch JSON (regardless of enabled state), or null. final StringgetEffectiveConfigJson()The currently-applied effective config, serialized to JSON (for display/seeding an editor). final UnitrefreshConfig()Best-effort re-fetch + apply of the config (honours the override). final UnitsetLiveMonitorEnabled(Boolean enabled)Enable/disable the read-only live data monitor. final BooleanisLiveMonitorEnabled()True if the live monitor is currently mirroring samples. final LiveStreamSnapshotgetLiveStream(String stream)Live snapshot for one stream (accel/gyro/mag/pressure/light/location/wifi/ble). final List<LiveDeviceEntry>getLiveDevices(String stream)Live discovered devices/APs/satellites for a scan stream (ble/wifi/gnss). final LiveAxisSnapshotgetLiveAxis(String stream)Per-axis live history for a 3-axis stream (accel/gyro/mag); null otherwise. final List<LiveLatLng>getLiveTrack()Recent location fixes for the live track map. final BooleanenableDevMode()Securely enables dev mode after validating the API token. final BooleanvalidateDevModeAccess()Validates whether the current API key has dev mode privileges without changing devMode state. final UnitdisableDevMode()Disables dev mode safely. final BooleangetDevMode()final UnitsetDevMode(Boolean devMode)final BooleangetManualForeground()When true, the SDK will NOT promote its internal TrackingService to the foreground. final UnitsetManualForeground(Boolean manualForeground)final DoublegetAutoStopAfterDropoffSeconds()Host-app override for the post-dropoff auto-stop timer, in seconds. final UnitsetAutoStopAfterDropoffSeconds(Double autoStopAfterDropoffSeconds)final Flow<GeofenceSessionEvent>getGeofenceSessionEvents()Hot stream of route-geofencing session start/stop events, so the host can update UI without polling. final List<DeliveryStop>getMonitoredStops()final Flow<Long>getConfigFetched()Hot stream of "config fetch succeeded" events. -
-
Method Detail
-
init
final Unit init(Context context, String notificationTitle, String notificationText, Function1<Result<Unit>, Unit> callback)
-
startDeliveryByPlaceID
final Unit startDeliveryByPlaceID(String placeID, String deliveryId, Function1<Result<String>, Unit> callback)
-
startDeliveryByPlaceID
final Unit startDeliveryByPlaceID(String placeID, String deliveryId, Double timeoutSeconds, Boolean manualForeground, Double autoStopAfterDropoffSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)
-
retryGnssCallbacks
final Unit retryGnssCallbacks()
Retry GNSS callback registration after permissions have been granted. Call this after the user grants location permissions to enable GNSS data collection.
-
startDeliveryByPlusCode
@Deprecated(message = Use startDeliveryByAddressString(address, deliveryId, coordinates, timeoutSeconds, callback) instead.) final Unit startDeliveryByPlusCode(String plusCode, String deliveryId, Function1<Result<String>, Unit> callback)
-
startDeliveryByPlusCode
@Deprecated(message = Use startDeliveryByAddressString(address, deliveryId, coordinates, timeoutSeconds, callback) instead.) final Unit startDeliveryByPlusCode(String plusCode, String deliveryId, Double timeoutSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)
-
startDeliveryByAddressString
final Unit startDeliveryByAddressString(String address, String deliveryId, Function1<Result<String>, Unit> callback)
-
startDeliveryByAddressString
final Unit startDeliveryByAddressString(String address, String deliveryId, Double timeoutSeconds, Function1<Result<String>, Unit> callback)
-
startDeliveryByAddressString
final Unit startDeliveryByAddressString(String address, String deliveryId, LatLngObject coordinates, Double timeoutSeconds, Boolean manualForeground, Double autoStopAfterDropoffSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)
-
startDeliveryByLatLng
@Deprecated(message = Use startDeliveryByAddressType(...) or startDeliveryByAddressString(...) with coordinates instead.) final Unit startDeliveryByLatLng(Double latitude, Double longitude, String deliveryId, Function1<Result<String>, Unit> callback)
-
startDeliveryByLatLng
@Deprecated(message = Use startDeliveryByAddressType(...) or startDeliveryByAddressString(...) with coordinates instead.) final Unit startDeliveryByLatLng(Double latitude, Double longitude, String subUnit, String deliveryId, Double timeoutSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)
-
startDeliveryByAddressType
final Unit startDeliveryByAddressType(AddressType address, String deliveryId, Function1<Result<String>, Unit> callback)
-
startDeliveryByAddressType
final Unit startDeliveryByAddressType(AddressType address, String deliveryId, Double timeoutSeconds, Function1<Result<String>, Unit> callback)
-
startDeliveryByAddressType
final Unit startDeliveryByAddressType(AddressType address, String deliveryId, LatLngObject coordinates, Double timeoutSeconds, Boolean manualForeground, Double autoStopAfterDropoffSeconds, String customerId, String driverId, Function1<Result<String>, Unit> callback)
-
newEvent
final Unit newEvent(String eventName, String deliveryId, Double timestamp, Function1<Result<String>, Unit> callback)
-
markDropoff
final Unit markDropoff(String deliveryId, DropoffType dropoffType)
-
stopDelivery
final Unit stopDelivery(String deliveryId)
Stop a delivery. If an auto-stop delay is configured for it (the
autoStopAfterDropoffSecondsargument tostartDelivery*, ormisc.autoStopAfterDropoffSecondsfrom server config), the actual teardown is DEFERRED by that many seconds — collection continues, then a Doze-safe alarm fires the real stop. A second stopDelivery during the delay is a no-op. No delay -> stops now.
-
startRouteGeofencing
final Unit startRouteGeofencing(List<DeliveryStop> stops, RouteGeofenceOptions options, Function1<Result<Unit>, Unit> callback)
Begin in-SDK route geofencing for stops. The SDK fences each stop and auto-starts/stops sessions on enter/exit (exit gated on markDropoff). Requires location permission; for background operation also requires
ACCESS_BACKGROUND_LOCATION("Allow all the time").
-
updateRouteStops
final Unit updateRouteStops(List<DeliveryStop> stops, Function1<Result<Unit>, Unit> callback)
Replace the active route's stop set mid-route (add/remove). Re-diffs geofence registration.
-
stopRouteGeofencing
final Unit stopRouteGeofencing()
Stop route geofencing: clear all geofences, stop any active route sessions, end the service.
-
resumeRouteGeofencingIfNeeded
final Unit resumeRouteGeofencingIfNeeded()
Idempotent restore of route geofencing from persisted state. The host should call this on every launch (including OS-initiated background relaunches) so the SDK re-asserts monitoring without the host re-supplying the stop list. No-op if no route is active.
-
setAPIKey
final Unit setAPIKey(String key, Boolean shouldGetConfig)
Set the bearer token used by every Network call and (by default) trigger an immediate config fetch.
- Parameters:
key- the JWT to send asAuthorization: Bearer <key>.shouldGetConfig- whentrue(default) the SDK kicks off a config fetch right now — typical production flow, so motion / location / fields config is ready before the host callsstartDeliveryByX(...).
-
setConfigOverride
final Unit setConfigOverride(String patchJson, Boolean enabled)
Set or clear a config override. patchJson is a JSON object (merge-patch) applied on top of the server config; pass null/blank to clear it. When enabled is false the patch is stored but inactive (server config is used as-is). Throws IllegalArgumentException if patchJson isn't valid JSON. Call refreshConfig afterward to re-fetch and apply without a relaunch.
-
isConfigOverrideEnabled
final Boolean isConfigOverrideEnabled()
True if a config override is currently active.
-
getConfigOverridePatch
final String getConfigOverridePatch()
The stored override patch JSON (regardless of enabled state), or null.
-
getEffectiveConfigJson
final String getEffectiveConfigJson()
The currently-applied effective config, serialized to JSON (for display/seeding an editor).
-
refreshConfig
final Unit refreshConfig()
Best-effort re-fetch + apply of the config (honours the override). Non-blocking.
-
setLiveMonitorEnabled
final Unit setLiveMonitorEnabled(Boolean enabled)
Enable/disable the read-only live data monitor. Enabling starts mirroring samples into ring buffers; disabling clears them. Off by default.
-
isLiveMonitorEnabled
final Boolean isLiveMonitorEnabled()
True if the live monitor is currently mirroring samples.
-
getLiveStream
final LiveStreamSnapshot getLiveStream(String stream)
Live snapshot for one stream (accel/gyro/mag/pressure/light/location/wifi/ble).
-
getLiveDevices
final List<LiveDeviceEntry> getLiveDevices(String stream)
Live discovered devices/APs/satellites for a scan stream (ble/wifi/gnss).
-
getLiveAxis
final LiveAxisSnapshot getLiveAxis(String stream)
Per-axis live history for a 3-axis stream (accel/gyro/mag); null otherwise.
-
getLiveTrack
final List<LiveLatLng> getLiveTrack()
Recent location fixes for the live track map.
-
enableDevMode
final Boolean enableDevMode()
Securely enables dev mode after validating the API token. This function checks if the current API key has dev mode privileges before enabling it.
-
validateDevModeAccess
final Boolean validateDevModeAccess()
Validates whether the current API key has dev mode privileges without changing devMode state.
-
disableDevMode
final Unit disableDevMode()
Disables dev mode safely. This is the only way to disable dev mode since devMode has a private setter.
-
getDevMode
final Boolean getDevMode()
-
setDevMode
final Unit setDevMode(Boolean devMode)
-
getManualForeground
final Boolean getManualForeground()
When true, the SDK will NOT promote its internal TrackingService to the foreground. It expects the host app to already be running a foreground service that keeps the process alive for background tracking. Exposed read-only to the host app; set per-delivery via the
startDeliveryByX(...)functions and persisted to SharedPreferences so TrackingService can read it after process recreation.
-
setManualForeground
final Unit setManualForeground(Boolean manualForeground)
-
getAutoStopAfterDropoffSeconds
final Double getAutoStopAfterDropoffSeconds()
Host-app override for the post-dropoff auto-stop timer, in seconds.
If
null(default), the SDK falls back to the value in remote config (com.doorstepai.sdks.tracking.internal.MiscConfiguration.autoStopAfterDropoffSeconds).If non-null, this value ALWAYS wins over remote config.
If the resolved value is
nullor <= 0, no auto-stop is scheduled.
When scheduled, the timer is backed by android.app.AlarmManager with
setAndAllowWhileIdle, so it is Doze-safe and reliable for long values (10 minutes up to several hours). It does NOT require theSCHEDULE_EXACT_ALARMpermission.Exposed read-only to the host app; set per-delivery via the
startDeliveryByX(...)functions.
-
setAutoStopAfterDropoffSeconds
final Unit setAutoStopAfterDropoffSeconds(Double autoStopAfterDropoffSeconds)
-
getGeofenceSessionEvents
final Flow<GeofenceSessionEvent> getGeofenceSessionEvents()
Hot stream of route-geofencing session start/stop events, so the host can update UI without polling. Replays the most recent event to late subscribers.
-
getMonitoredStops
final List<DeliveryStop> getMonitoredStops()
-
getConfigFetched
final Flow<Long> getConfigFetched()
Hot stream of "config fetch succeeded" events. Each emission carries the wall-clock timestamp (ms since epoch) of the successful landing. Replays the most recent value so a late subscriber sees the current state immediately. Useful for surfacing "Config fetched at HH:mm:ss" in a host-app status panel without poking at SDK internals.
-
-
-
-