Context-awareness--the ability of systems to sense and react to their environment-- can enable software to intelligently adapt its functionality across time, locations, and operating conditions. In this thesis, we introduce CAreDroid, a Context-Aware runtime adaptation system for Android. CAreDroid allows the runtime system to switch between blocks of code that perform alternative or comparable functionality. At any point in time, CAreDroid activates the blocks of code that best fit the device's context. CAreDroid targets both the Java and native layers of Android and can help users develop and analyze tradeoffs between accuracy and cost in different contexts. The proposed framework enables applications to dynamically and transparently adapt their functionality, quality, and timeliness of results, leading to a range of 3-12x reduction in execution time compared to context-aware Android apps that do not rely on CAreDroid.
Context-aware operation is particularly important for energy efficiency. In mobile phones the marginal energy cost of performing any operation changes according to device context as determined by, for example, remaining battery capacity, connectivity status, or sources of environmental and process variability like operating temperature. We show that context-aware applications using CAreDroid can achieve 20%-40% energy savings with acceptable quality degradation.