An Openssource Context Engine for Android : The Concepts

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:

  1. Packaged with your application, adding your own context components
  2. Packages outside your application, using the engine with your application(s)
Engine Usage

Engine Usage

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.

Component Class

Component Class

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:

Example Context

Example 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 acquisitionIn 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.

Vintage or Tawny? Middleware 2011

This week I was lucky enough to take a trip to the Middleware 2011 Conference in Lisbon, Portugal. The first two days were for the various workshops with the final three days for the main conference. As I landed late that evening, I just checked into the hotel and met Anna for dinner. The hotel I stayed in was the VIP Inn Berna, which so happens to be just across the road from an old bull fighting arena. Overall I have no complains about the hotel, but it was slightly basic, and I wish Internet was included.

M-MPAC Workshop

On the first day, there were a number of workshops to which I attended the PhD symposium in the morning and the M-MPAC workshop (to present a paper) in the afternoon. There were a number of interesting work published at this workshop, though one I wasn’t so sure about, as it was obvious they had not tested their concept on an actual device as they lead me to believe. It’s really this that I dislike in research where if someone claims something works on a mobile device I expect to have been tested on one, not assume it will work, as with mobile devices there are lots of different hardware and software constraints (some deliberate, some not) that can make the concept limiting or in some cases void.

When it came to presenting, I have to admit it was the most nervous presentation I’ve given, not sure exactly why as the paper had been accepted, but I was apprehensive about what the reaction/questions to the paper will be. At the end of the presentation, no quick questions were asked.

At the end of the workshop there was a panel section where all attendees sat in a circle to ask questions about the work presented. One question in particular that interested me was  brought up by David Evans from Cambridge University for the general discussion of all which was the notion of trust, and how can you ensure that context data/information is actually true or honest? Particularly if your context is based on what people submit to a service, it can be misused by different businesses to gain some unfair advantage.

For the presentation slides go to: https://deansserver.co.uk/files/presentations/ContextEngine_presentation.pdf

The Main Conference

The main conference began really the night before it started (if that makes sense?) where there was an organised dinner and few drinks for everyone to meet and socialize. I just continued to the mingle with some of the PhD students, and meet some of the conference delegates.

Most of the focus of the conference was on large datacenters, interoperability, data, and network efficiency. Particular some of the more interesting I found were on a filesystem for Virtual machine image storage for cloud computing systems, a middleware for managing software and hardware modules, and scaling micro blogging services.

At the end of the first day there were poster presentations, where Anna presented her poster and answered questions while delegates walked around. I spoke with a student researching into a context aware middleware for ambient intelligence, as it looked broadly the same as our ContextEngine. The student said that nothing had really been implemented yet and he only has an architecture diagram, to which I suggested he reads our paper and maybe there is room for extension or collaboration. During the poster session there was also roasted chestnuts with some local drink which was made from wine and fruit juice, which was a nice touch to the poster sessions.

Other research at the poster sessions that interested me was a poster on a way of streaming video to mobile devices using telephone masks and ad-hoc networks as a way of lowering the amount of load on the phone masks. This method broadly works on a similar method to Skype, whereby some nodes end up being like super nodes which others connect to, forming a connection chain, instead of each node needing a direct connection to the source.

Social Event

The social event was set at the Oceanario de Lisbon (Lisbon Aquarium). Currently there is an exhibit on different species of turtles, which was really interesting. We were given a tour guide who showed us different turtle species, what they eat etc. I managed to see a couple of them in the tanks, but most I think were out of sight sadly.

After a quick whip around the exhibit, we then went on to wine tasting which was great. I got to try local white, red, and some port. Until that night I never knew there were different styles of port, and I have to say I prefer tawny style port to vintage.

Sightseeing and Exploring

When it came to exploring the local surroundings, I spent two afternoons to try and at least see some of the city. First time round, Anna and I walked all the way from our hotels to the city center, taking photos of different sights on the way. We then progressed up the hill towards the Castelo Sao Jorge to see the castle.

View from Castelo Sao Jorge

View from Castelo Sao Jorge

The Castle was a fantastic place to visit and I would strongly recommend anyone visiting the area to put that on your list! The views from the castle are breathtaking, which are also 360 degrees. The castle itself was an interesting spectacle with history going back to the 12th century. There was in the castle an indoor view of the city, with the use of a hole in the ceiling and something else (perhaps a mirror?) projected a view of the city onto a large bowl like structure, which I found extraordinary.

On the last day of my stay in Lisbon, because Anna and I had checked out of our hotels we decided it would be best to not walk about with all our luggage so we hopped on a tour bus which took us from the city center round the coast line eastwards and round back  seeing the shipping ports, some convents, the first train station in Portugal, the Expo building, some of the newer developments and the parliament building. Overall a good decision, before going to the airport to return home.

Overall I had a fantastic time at the Middleware conference, met some great people, and are very thankful to those that organised and made the conference happen. I do think Lisbon is a very interesting place with lots to see, and would recommend anyone thinking of visiting Portugal to at least take a trip into the city.