Smart phones in recent years have seen high proliferation, allowing more users to stay productive while away from the desktop. This proliferation has seen the increasing amount of mobile applications being developed and becoming available to consumers through centralised application repositories. It has become highly predictable for these devices to have an array of sensors including GPS, accelerometers, digital compass, proximity sensors, sound etc.
Using these sensors with other equipment already found in phones, a wide set of contextual information can be acquired. This contextual information is consumed by context-aware mobile applications. Context aware applications have been described to be intelligent applications that can monitor the user’s context and, in case of changes in this context, consequently adapt their behaviour in order to satisfy the user’s current needs or anticipate the user’s intentions.
Within this article, I will introduce an openssource engine for context acquisition and composition for Android. This engine is primarily intended to be used in two cases:
- Packaged with your application, adding your own context components
- Packages outside your application, using the engine with your application(s)
Ideally, we hope this engine can turn-into a globally used engine that is used by several applications on the device, leading to more efficient resource handling, preserving precious battery power.
Essentially within the engine context types are contained within their own Component. A Component can be seen as an encapsulation of constants, and methods for acquiring & reasoning that context value from the sensor/data resource.
Where this gets interesting is, in many situations a context wont be based on a single point or single component, but more based on the composition of many contexts. Because of this, its quickly foreseeable that many contexts will be used in more than one Composite context. With this, and the increasing interest to incorporate context-awareness into mobile applications, its important to manage this carefully to prevent wasteful use of resources.
How our engine attempts to help this issue is to work with context tree structures, in which context changes for individual contexts are broadcasted up the tree to the level above for reasoning and so on. These contexts should not need to know who is listening/requesting the context changes, but just broadcast its state on context change and carry on. Using this approach we aim to make contexts completely self contained and generic.
To help explain this tree structure, we can consider the following Composite context:
In the Connection Composite, there is a Data Sync Composite, which uses the Wifi and 3G context, and the Battery Context. If there is a change in the Wifi or 3G contexts, the Data Sync context receives the broadcast and then checks its own state. If its state has changed, then it then broadcasts its state, which is then received by the Connection context.
These contexts are then listened to by the application, which then can define its different adaptation logic.
Because of this approach, we need not implement Composite Components for each composition, but instead just define this context composition and let the engine do the work, allowing the engine to be more dynamic in its use.
For more details, please see our paper:
Kramer, D., Kocurova, A., Oussena, S., Clark, T., Komisarczuk, P. (2011) An extensible, self contained, layered approach to context acquisition. In the Proceedings of the 3nd International Workshop on Middleware for Pervasive Mobile and Embedded Computing.
This software is licensed using the Apache License. Please see https://deansserver.co.uk/~dean/software/context-engine-for-android/ for upto date information of where the source is hosted.