navit  0.5.3-trunk
org.navitproject.navit.NavitTraff Class Reference
Inheritance diagram for org.navitproject.navit.NavitTraff:

Public Member Functions

native void onFeedReceived (long id, String feed)
 
void onReceive (Context context, Intent intent)
 

Static Public Member Functions

static void sendTraffIntent (Context context, String action, Uri data, Bundle extras, String packageName, String receiverPermission, BroadcastReceiver resultReceiver)
 

Package Functions

 NavitTraff (Context context, long cbid)
 
void close ()
 
void onFilterUpdate (String filterList)
 

Private Member Functions

void fetchMessages (Context context, Uri uri)
 

Static Private Member Functions

static String formatTraffError (int code)
 

Private Attributes

final long mCbid
 
final Context context
 
Map< String, String > subscriptions = new HashMap<String, String>()
 

Static Private Attributes

static final String ACTION_TRAFF_GET_CAPABILITIES = "org.traffxml.traff.GET_CAPABILITIES"
 
static final String ACTION_TRAFF_HEARTBEAT = "org.traffxml.traff.HEARTBEAT"
 
static final String ACTION_TRAFF_FEED = "org.traffxml.traff.FEED"
 
static final String ACTION_TRAFF_POLL = "org.traffxml.traff.POLL"
 
static final String ACTION_TRAFF_SUBSCRIBE = "org.traffxml.traff.SUBSCRIBE"
 
static final String ACTION_TRAFF_SUBSCRIPTION_CHANGE = "org.traffxml.traff.SUBSCRIPTION_CHANGE"
 
static final String ACTION_TRAFF_UNSUBSCRIBE = "org.traffxml.traff.UNSUBSCRIBE"
 
static final String COLUMN_DATA = "data"
 
static final String CONTENT_SCHEMA = "content"
 
static final String[] ERROR_STRINGS
 
static final String EXTRA_CAPABILITIES = "capabilities"
 
static final String EXTRA_FEED = "feed"
 
static final String EXTRA_FILTER_LIST = "filter_list"
 
static final String EXTRA_PACKAGE = "package"
 
static final String EXTRA_SUBSCRIPTION_ID = "subscription_id"
 
static final String MIME_TYPE_TRAFF = "vnd.android.cursor.dir/org.traffxml.message"
 
static final int RESULT_OK = -1
 
static final int RESULT_INTERNAL_ERROR = 7
 
static final int RESULT_INVALID = 1
 
static final int RESULT_SUBSCRIPTION_REJECTED = 2
 
static final int RESULT_NOT_COVERED = 3
 
static final int RESULT_PARTIALLY_COVERED = 4
 
static final int RESULT_SUBSCRIPTION_UNKNOWN = 5
 
static final String TAG = "NavitTraff"
 

Detailed Description

The TraFF receiver implementation.

This class registers the broadcast receiver for TraFF feeds, polls all registered sources once on creation, receives TraFF feeds and forwards them to the traffic module for processing.

Constructor & Destructor Documentation

◆ NavitTraff()

org.navitproject.navit.NavitTraff.NavitTraff ( Context  context,
long  cbid 
)
inlinepackage

Creates a new

NavitTraff(Context context, long cbid)
Definition: NavitTraff.java:108

instance.

Creating a new

instance registers a broadcast receiver for TraFF broadcasts and polls all registered sources once to ensure we have messages which were received by these sources before we started up.

Parameters
contextThe context
cbidThe callback identifier for the native method to call upon receiving a feed

References org.navitproject.navit.NavitTraff.ACTION_TRAFF_FEED, org.navitproject.navit.NavitTraff.ACTION_TRAFF_GET_CAPABILITIES, org.navitproject.navit.NavitTraff.ACTION_TRAFF_POLL, org.navitproject.navit.NavitTraff.CONTENT_SCHEMA, and org.navitproject.navit.NavitTraff.MIME_TYPE_TRAFF.

Member Function Documentation

◆ close()

◆ fetchMessages()

void org.navitproject.navit.NavitTraff.fetchMessages ( Context  context,
Uri  uri 
)
inlineprivate

Fetches messages from a content provider.

Parameters
contextThe context to use for the content resolver
uriThe content provider URI

References org.navitproject.navit.NavitTraff.COLUMN_DATA, org.navitproject.navit.NavitTraff.mCbid, org.navitproject.navit.NavitTraff.onFeedReceived(), and org.navitproject.navit.NavitTraff.TAG.

Referenced by org.navitproject.navit.NavitTraff.onReceive().

◆ formatTraffError()

static String org.navitproject.navit.NavitTraff.formatTraffError ( int  code)
inlinestaticprivate

◆ onFeedReceived()

native void org.navitproject.navit.NavitTraff.onFeedReceived ( long  id,
String  feed 
)

Forwards a newly received TraFF feed to the traffic module for processing.

This is called when a TraFF feed is received.

Parameters
idThe identifier for the native callback implementation
feedThe TraFF feed

Referenced by org.navitproject.navit.NavitTraff.fetchMessages(), and org.navitproject.navit.NavitTraff.onReceive().

◆ onFilterUpdate()

◆ onReceive()

◆ sendTraffIntent()

static void org.navitproject.navit.NavitTraff.sendTraffIntent ( Context  context,
String  action,
Uri  data,
Bundle  extras,
String  packageName,
String  receiverPermission,
BroadcastReceiver  resultReceiver 
)
inlinestatic

Sends a TraFF intent to a source. This encapsulates most of the low-level Android handling.

If the recipient specified in

packageName

declares multiple receivers for the intent in its manifest, a separate intent will be delivered to each of them. The intent will not be delivered to receivers registered at runtime.

All intents are sent as explicit ordered broadcasts. This means two things:

Any app which declares a matching receiver in its manifest will be woken up to process the intent. This works even with certain Android 7 builds which restrict intent delivery to apps which are not currently running.

It is safe for the recipient to unconditionally set result data. If the recipient does not set result data, the result will have a result code of RESULT_INTERNAL_ERROR, no data and no extras.

Parameters
contextThe context
actionThe intent action.
dataThe intent data (for TraFF, this is the content provider URI), or null
extrasThe extras for the intent
packageNameThe package name for the recipient, or null to deliver the intent to all matching receivers
receiverPermissionA permission which the recipient must hold, or null if not required
resultReceiverA BroadcastReceiver which will receive the result for the intent

References data, and org.navitproject.navit.NavitTraff.RESULT_INTERNAL_ERROR.

Referenced by org.navitproject.navit.NavitTraff.close(), org.navitproject.navit.NavitTraff.onFilterUpdate(), and org.navitproject.navit.NavitTraff.onReceive().

Field Documentation

◆ ACTION_TRAFF_FEED

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_FEED = "org.traffxml.traff.FEED"
staticprivate

◆ ACTION_TRAFF_GET_CAPABILITIES

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_GET_CAPABILITIES = "org.traffxml.traff.GET_CAPABILITIES"
staticprivate

◆ ACTION_TRAFF_HEARTBEAT

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_HEARTBEAT = "org.traffxml.traff.HEARTBEAT"
staticprivate

◆ ACTION_TRAFF_POLL

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_POLL = "org.traffxml.traff.POLL"
staticprivate

◆ ACTION_TRAFF_SUBSCRIBE

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_SUBSCRIBE = "org.traffxml.traff.SUBSCRIBE"
staticprivate

◆ ACTION_TRAFF_SUBSCRIPTION_CHANGE

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_SUBSCRIPTION_CHANGE = "org.traffxml.traff.SUBSCRIPTION_CHANGE"
staticprivate

◆ ACTION_TRAFF_UNSUBSCRIBE

final String org.navitproject.navit.NavitTraff.ACTION_TRAFF_UNSUBSCRIBE = "org.traffxml.traff.UNSUBSCRIBE"
staticprivate

◆ COLUMN_DATA

final String org.navitproject.navit.NavitTraff.COLUMN_DATA = "data"
staticprivate

◆ CONTENT_SCHEMA

final String org.navitproject.navit.NavitTraff.CONTENT_SCHEMA = "content"
staticprivate

◆ context

final Context org.navitproject.navit.NavitTraff.context
private

◆ ERROR_STRINGS

final String [] org.navitproject.navit.NavitTraff.ERROR_STRINGS
staticprivate
Initial value:
= {
"unknown (0)",
"invalid request (1)",
"subscription rejected by the source (2)",
"requested area not covered (3)",
"requested area partially covered (4)",
"subscription ID not recognized by the source (5)",
"unknown (6)",
"source reported an internal error (7)"
}

Referenced by org.navitproject.navit.NavitTraff.formatTraffError().

◆ EXTRA_CAPABILITIES

final String org.navitproject.navit.NavitTraff.EXTRA_CAPABILITIES = "capabilities"
staticprivate

◆ EXTRA_FEED

final String org.navitproject.navit.NavitTraff.EXTRA_FEED = "feed"
staticprivate

◆ EXTRA_FILTER_LIST

final String org.navitproject.navit.NavitTraff.EXTRA_FILTER_LIST = "filter_list"
staticprivate

◆ EXTRA_PACKAGE

final String org.navitproject.navit.NavitTraff.EXTRA_PACKAGE = "package"
staticprivate

◆ EXTRA_SUBSCRIPTION_ID

final String org.navitproject.navit.NavitTraff.EXTRA_SUBSCRIPTION_ID = "subscription_id"
staticprivate

◆ mCbid

final long org.navitproject.navit.NavitTraff.mCbid
private

◆ MIME_TYPE_TRAFF

final String org.navitproject.navit.NavitTraff.MIME_TYPE_TRAFF = "vnd.android.cursor.dir/org.traffxml.message"
staticprivate

◆ RESULT_INTERNAL_ERROR

final int org.navitproject.navit.NavitTraff.RESULT_INTERNAL_ERROR = 7
staticprivate

◆ RESULT_INVALID

final int org.navitproject.navit.NavitTraff.RESULT_INVALID = 1
staticprivate

◆ RESULT_NOT_COVERED

final int org.navitproject.navit.NavitTraff.RESULT_NOT_COVERED = 3
staticprivate

◆ RESULT_OK

final int org.navitproject.navit.NavitTraff.RESULT_OK = -1
staticprivate

◆ RESULT_PARTIALLY_COVERED

final int org.navitproject.navit.NavitTraff.RESULT_PARTIALLY_COVERED = 4
staticprivate

◆ RESULT_SUBSCRIPTION_REJECTED

final int org.navitproject.navit.NavitTraff.RESULT_SUBSCRIPTION_REJECTED = 2
staticprivate

◆ RESULT_SUBSCRIPTION_UNKNOWN

final int org.navitproject.navit.NavitTraff.RESULT_SUBSCRIPTION_UNKNOWN = 5
staticprivate

◆ subscriptions

Map<String, String> org.navitproject.navit.NavitTraff.subscriptions = new HashMap<String, String>()
private

Active subscriptions (key is the subscription ID, value is the package ID).

Referenced by org.navitproject.navit.NavitTraff.close(), org.navitproject.navit.NavitTraff.onFilterUpdate(), and org.navitproject.navit.NavitTraff.onReceive().

◆ TAG

final String org.navitproject.navit.NavitTraff.TAG = "NavitTraff"
staticprivate

The documentation for this class was generated from the following file: