ICAPS : Intelligent Context Aware Profile Switching

This paper presents a mobile application called ICAPS (Intelligent Context Aware Profile Switching) an intelligent system that takes advantage of three common technologies (Wi-Fi, Bluetooth and GPS) to provide the user with automated profile switching techniques depending on the user’s context. The system combines the three technologies together so that it determines the contexts around the user using one or more of these technologies. Upon detecting the user’s context, the system intelligently switches between profiles that are either set up by the user, or have been provided by an external source.


INTRODUCTION
This paper aims at developing a mobile assisting application that provides various functionalities to the user depending on different situations.The main functionality of the application is to switch between profiles based on actions by the user such as entering a specific area.
The need of this application is when users enter places that require a specific profile such as meeting rooms, auditorium, hospitals, and places of worship and so on.Several moments can be spotted in our daily lives where some people forget to switch their phone's profile to silent which leads to cause a disturbance if these phones ring.Some customers asked for a valid solution for this issue.Based on what the customers need, this paper discusses the development of a mobile application to achieve this.Despite that some other applications have developed similar ideas, many of them are not comprehensive enough and rely heavily on user intervention.The ICAPS application tries to think on behalf of the user if the user comes into a new context and provides a proactive approach to deal with the situation by using some form of intelligence.This intelligence can be acquired as the application tries to learn from past experience or by intervention of the user in similar situations.

LITERATURE REVIEW
The idea of examining and reacting to any changing in context and its state and surrounding environment according to the user's preferences to adapt his/her behaviour is known as context aware computing according to (AlNeaimi, 2007).The context aware is centric of four main ideas which are the location, time, activity and preferences of the user.We can represent the context aware as four questions, to identify "who" is the user to know the preferences."What" is he/she doing or the activity of the user?"When and Where" is to know the location and time of the user.If we have the answer the question "Why" can be answered as the action of the system (AlNeaimi, 2007).
The thought of the context aware using mobile phone was initiated in 1999 -2005 when context types such as user & role, process & task, location, time and device were distinguished and identified.Though, many projects nowadays use context aware technologies which can sense and react based on their environment (Cordeiro, 2003).
In term of context awareness, in 2009 a group of developers (Kaltz et. al. 2005) carried out research about the mobile context awareness.Their research had an intelligent selection for a suitable medical expert in an emergency situation, which interacts with the context-aware system and the user profiles.
There has been an application to change the phone profile automatically when entering an area with a Bluetooth transmitter that is registered in the http://dx.doi.org/10.14236/ewic/bcsme2014.4(Huang, 2008).It is almost the same idea on which our application is based on.However, this application only uses Bluetooth to detect a location and change profile, whereas we think of creating an application to include more features than this such as finding locations using GPS and Wi-Fi signals.
Another example for context-aware profile switching is a mobile application called "Context Aware Profile" (kuyu, 2013).This application uses the SSID of the Wi-Fi to change the profile depending on previously set choices.However, this application lacks the intelligence; because in a case where there are deferent areas with the same Wi-Fi name we will still have the same profile everywhere.
Some developers used the context-aware to change a profile but using other technologies such as GSM.
In 2006, a GSM-Based Context-Aware Profile Switcher was created (Jonfroehlich, 2006).It used the GSM location code area to perform some tasks such as: Changing a profile, executes an application, playing a sound ... etc.There are unlimited ways to use the concept of Context-Aware to develop some useful applications.However it is rather difficult to add the concept of intelligence and let the application take the right decisions.This is what makes the ICAPS so different.

SYSTEM OVERVIEW
This paper discusses the development of an intelligent smartphone application that is capable to perform context aware profile switching.To achieve the expected outcome the designed application uses several mobile technologies such as Bluetooth, Wi-Fi, GPS and accelerometer.Figure 1 illustrates the inputs and outputs of the system:

Figure 1: System input and output
According to Figure 1, the system uses the three main components (Wi-Fi, GPS and Bluetooth technology) to detect the user location.The GPS is used by the system to locate the user's location by defining latitude and longitude values based on the user's position.The Wi-Fi signal provides the system with appropriate information to help detecting the user location indoors.The system uses the SSID and BSSID values that are provided from the Wi-Fi signal to gather more information about the user's location and perform the appropriate actions.In a similar way, the Bluetooth signal is also used to detect information about the user's location.This can be used in indoor locations that require a silent profile, such as hospitals, worship places, libraries, auditoriums, etc.The accelerometer and time are also used to define the user context in terms of movement and time.In addition to these technologies, the system uses predefined settings in the application to provide user customization.The inputs are delivered to the system to produce the outputs which are the appropriate profiles for the user's location, the location of the user on a map and additional settings predefined by the user.

ICAPS DATABASE
The ICAPS system uses a SQLite database to store the historical data it needs.This eases the profile changing process while keeping the initial profile.All the data collected by the ICAPS is stored in the database to create the right profile for the right place.
Example of how the database looks like is shown in Table 1: The database of the system consists of three main parts: The History, The waitlist and the Main Database (see Fig. 2).Each one of the three technologies has its own history, which is a database type that stores new entries found by the system.Each entry has its own counter and every time an entry is found in the history, its counter is increased by one.Eventually, the counter will reach a certain limit where the entry is moved into the waitlist.

The Waitlist
The waitlist is a common database across the three technologies.Each entry in the waitlist consists of a Wi-Fi BSSID, a Bluetooth MAC address and a GPS coordinates (Latitude and Longitude).The waitlist has been designed to create a list of the common places the user has been to.

The Main Database
The main database is the one that has the main profiles to switch between.While the main database has the same structure as the waitlist, the main database is related to the process of performing actions and switching between the profiles where the wait list is not.The entries of this database are added when the user specifies a new profile either manually or using a waitlist.

SYSTEM FUNCTIONALITY
The core of the system relies on a background service that runs in a periodic way.The service scans for the three technologies, starting with the Wi-Fi, then the Bluetooth and finishing with the GPS.The order of use is designed to minimize the consumption of battery power.Each one of the three technologies represents an agent that performs various tasks to gather data and perform actions.If any of the agents have succeeded in finding and switching a profile then the service skips the other agents.The service manages the three agents in the following order (see Fig. 3):

Figure 3: System hierarchy
The Wi-Fi is always the first used to find the profiles since it is the most common and efficient technology, the second one is the Bluetooth since it has longer scan time and consumes more power.The last one is the GPS since it is not always used indoors and it uses more battery power despite its better accuracy.

Gathering data
The agent starts scanning around for multiple signals depending on the type of the agent (Wi-Fi signals, BT signals or GPS coordinates).When the agent finishes scanning, it returns either one signal (GPS coordinates) or a set of the available signals around (Wi-Fi and BT set of signals).

Checking the Main Database
When the agent returns the appropriate data, the system scans this data and compares it with the entries in the main database.For the Wi-Fi and BT agents, the main goal is to find the best signal (one with most strength) that is found in the database.For the GPS agent, the main goal is to find the user's distance to the nearest area from him while checking if the user is within that area's radius.These goals were chosen due to 2 main advantages: (i) Prevent the agents from retrieving lots of useless data and only concentrating on the most useful ones.
(ii) Prevent the system from having two profiles for one place and switching between two profiles in a confusing way.
The Bluetooth agent also has a feature where it scans the names of the nearby BT devices while comparing them to a set of names in the system's settings.When the BT agent finds a familiar name, it attempts to perform a Bluetooth authentication with it under a certain UUID channel.If the connection is successful then the BT device will send a predefined profile to the system and activate it.If the goal is found, then the appropriate profile is switched on and the agents will try to improve the detected entry.Otherwise, the system skips to the waitlist.

Checking the Wait List
The agents perform the same process they did when checking the database but here they deal with the waitlist instead of the main database.If the goal is found then the agents will only try improving the detected entry.If no entry was found, the agents will switch to the history.

Checking the History
If the agent could not find an appropriate entry in the main database and the waitlist, it will take the best signal (Wi-Fi and BT) or the user's coordinates (GPS) and look it up in the history.If the signal is not found in the history then a new entry is created using the given data, otherwise, the candidate of the history entry is increased by one.Eventually, the candidate will keep increasing until it reaches a limit where the history entry becomes a waitlist entry.

THE SYSTEM'S INTELLIGENCE
The ICAPS mobile application can act intelligently and considered proactive in new situations.The intelligence part has been added in various parts across the system to achieve the following multiple goals:

Power efficiency
To minimize the waste of battery power, the background service has been designed so that whenever an agent finds a profile whether in the main database or in the wait list, then it will check if the profile has missing data or not.For example, if the Wi-Fi agent found a profile then it will check whether the profile has a Bluetooth data or not.If so, then the BT agent will be skipped and the GPS agent will be started instead.This action saves the time and the power of using the BT agent.
Another way to improve the power efficiency is to link the period of the background service to the mobile device's accelerometer sensor.When the sensor is active then it indicates that the user is moving from place to another which will require a frequent update for the system.However, when the sensor is stable then the service will take longer time to rescan again which saves power.

Merging the three agents together
Most of the intelligence in the system has been dedicated to this part.When an agent finds a profile with some missing data, the other agents will attempt to improve this profile until it has all the data required.For example, when a Wi-Fi profile with missing GPS data is found, the GPS agent gathers data to fill in the missing GPS data in the profile so that in case the Wi-Fi signal could not be transmitted for some reason, the system will still be able to detect the profile using the GPS coordinates.

TESTING
After implementing the system, the system has been tested by starting the main service while turning on the Wi-Fi, Bluetooth and GPS adapters in an area with signals of three types.All of the three adapters have succeeded on providing appropriate data to represent the current context (see Fig. 4):  When the customization is over, the profile will be in the main database.And when the context is detected, the system will switch the profile settings to the ones the user customized as shown in Fig. 6: We applied some test cases on the application and the following errors appear so we provide some methods to solve the issues:

Dealing with communications devices
Our application deals with a communication signals such as Bluetooth and Wi-Fi.And sometimes the devices do not find the signal and stop the profile.So we provide a timer that searches for the signals three times and if it disappears the application will exit the profile but if it appears it will stay in the loop.

Using Nearest signals
As we test the application we found that the application takes only the nearest profile to the phone.So we modify the code to take the nearest signal that is in the database.

Power consumption
We have found that our application consumes more power so we provided a modification to the searching algorithm by using the accelerometer of the device to start the service in longer time if the phone is not in use.

Beta testing
We have tested our application among 20 users and we asked them about the validation and verification.Moreover, we asked about the ease of use, the user interface and if there are any ideas to improve the application even further.And we obtained good feedback to improve the application.

CONCLUSION
ICAPS is a mobile application that uses the current technologies to provide smarter ways to change the user's profiles based on his/her context.While the main technologies used in this system are the Wi-Fi, the Bluetooth and the GPS, more technologies can be implemented in the system such as NFC communication to locate users indoors.

ACKNOWLEDGMENT
We would like to acknowledge Khalifa University for their valuable helps and support in providing a great environment to work in.

Figure
Figure 2: System Database hierarchy

Figure 4 :
Figure 4: Detected data from the main agents The Wi-Fi agent gathered enough data about the available Wi-Fi signals and created a profile in the Wait list Fig 5.A. Eventually the Bluetooth and GPS

Figure 5 :
Figure 5: A. Wait list database, B. Profile with all data available C. Customizing the new profile

Figure 5 :
Figure 5: the new profile in action 7.1 Alpha testing

Table 1 :
SQLite Database Demonstration