skip to main content
research-article
Open access

LiveDroid: identifying and preserving mobile app state in volatile runtime environments

Published: 13 November 2020 Publication History

Abstract

Mobile operating systems, especially Android, expose apps to a volatile runtime environment. The app state that reflects past user interaction and system environment updates (e.g., battery status changes) can be destroyed implicitly, in response to runtime configuration changes (e.g., screen rotations) or memory pressure. Developers are therefore responsible for identifying app state affected by volatility and preserving it across app lifecycles. When handled inappropriately, the app may lose state or end up in an inconsistent state after a runtime configuration change or when users return to the app.
To free developers from this tedious and error-prone task, we propose a systematic solution, LiveDroid, which precisely identifies the necessary part of the app state that needs to be preserved across app lifecycles, and automatically saves and restores it. LiveDroid consists of: (i) a static analyzer that reasons about app source code and resource files to pinpoint the program variables and GUI properties that represent the necessary app state, and (ii) a runtime system that manages the state saving and recovering. We implemented LiveDroid as a plugin in Android Studio and a patching tool for APKs. Our evaluation shows that LiveDroid can be successfully applied to 966 Android apps. A focused study with 36 Android apps shows that LiveDroid identifies app state much more precisely than an existing solution that includes all mutable program variables but ignores GUI properties. As a result, on average, LiveDroid is able to reduce the costs of state saving and restoring by 16.6X (1.7X - 141.1X) and 9.5X (1.1X - 43.8X), respectively. Furthermore, compared with the manual state handling performed by developers, our analysis reveals a set of 46 issues due to incomplete state saving/restoring, all of which can be successfully eliminated by LiveDroid.

Supplementary Material

Auxiliary Presentation Video (oopsla20main-p129-p-video.mp4)
Mobile operating systems, especially Android, expose apps to a volatile runtime environment. The app state that reflects past user interaction and system environment updates can be destroyed implicitly, in response to runtime configuration changes (e.g., screen rotations) or memory pressure. Developers are therefore responsible for identifying app state affected by volatility and preserving it across app lifecycles. When handled inappropriately, the app may lose state or end up in an inconsistent state after a runtime configuration change or when users return to the app. We propose a systematic solution, LiveDroid, which precisely identifies the necessary part of the app state that needs to be preserved, and automatically saves and restores it. LiveDroid consists of: (i) a static analyzer that pinpoints the program variables and GUI properties that represent the necessary app state, and (ii) a runtime system that manages the state saving and recovering.

References

[1]
2020. Glucosio for Android. https://github.com/Glucosio/glucosio-android. Accessed: 2020-07-22.
[2]
2020. K-9 Mail. https://github.com/k9mail/k-9. Accessed: 2020-07-22.
[3]
2020. MapBox. https://github.com/mapbox/mapbox-gl-native. Accessed: 2020-09-08.
[4]
2020. Open MF. https://github.com/openMF/android-client. Accessed: 2020-09-08.
[5]
2020. StackOveflow Question 456211. https://stackoverflow.com/questions/456211/activity-restart-on-rotation-android. Accessed: 2020-09-08.
[6]
2020. TileView Library. https://github.com/moagrius/TileView. Accessed: 2020-09-08.
[7]
2020. WordPress-Android. https://github.com/wordpress-mobile/WordPress-Android. Accessed: 2020-09-08.
[8]
Christofer Quist Adamsen, Gianluca Mezzetti, and Anders Møller. 2015. Systematic execution of android test suites in adverse conditions. In Proceedings of the 2015 International Symposium on Software Testing and Analysis. ACM, 83-93.
[9]
Alfred V Aho, Monica S Lam, Ravi Sethi, and Jefrey D Ullman. 2006. Compilers: Principles Techniques and Tools. 2007. Google Scholar Google Scholar Digital Library Digital Library ( 2006 ).
[10]
Elvira Albert, Samir Genaim, and Miguel Gómez-Zamalloa Gil. 2009. Live heap space analysis for languages with garbage collection. In Proceedings of the 2009 international symposium on Memory management. 129-138.
[11]
alliedmarketresearch. 2020. Mobile Application Market by Marketplace. https://www.alliedmarketresearch.com/mobileapplication-market. Accessed: 2020-04-30.
[12]
Apple. 2020a. About the Virtual Memory System. https://developer.apple.com/library/archive/documentation/Performance/ Conceptual/ManagingMemory/Articles/MemoryAlloc.html. Accessed: 2020-09-08.
[13]
Apple. 2020b. Preserving Your App's UI Across Launches. https://developer.apple.com/documentation/uikit/view_controllers/preserving_your_app_s_ui_across_launches. Accessed: 2020-10-06.
[14]
Apple. 2020c. Reducing Disk Writes. https://developer.apple.com/documentation/xcode/improving_your_app_s_performance/reducing_disk_writes. Accessed: 2020-09-08.
[15]
Apple. 2020d. Reducing Your App's Memory Use. https://developer.apple.com/documentation/xcode/improving_your_app_s_performance/reducing_your_app_s_memory_use. Accessed: 2020-09-08.
[16]
Niaz Arijo, Reiko Heckel, Mirco Tribastone, and Stephen Gilmore. 2011. Modular performance modelling for mobile applications. In ACM SIGSOFT Software Engineering Notes, Vol. 36. ACM, 329-334.
[17]
Steven Arzt, Siegfried Rasthofer, Christian Fritz, Eric Bodden, Alexandre Bartel, Jacques Klein, Yves Le Traon, Damien Octeau, and Patrick McDaniel. 2014. FlowDroid: Precise Context, Flow, Field, Object-sensitive and Lifecycle-aware Taint Analysis for Android Apps. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI '14). ACM, New York, NY, USA, 259-269. https://doi.org/10.1145/2594291.2594299
[18]
Gabriele Bavota, Bernardino De Carluccio, Andrea De Lucia, Massimiliano Di Penta, Rocco Oliveto, and Orazio Strollo. 2012. When does a refactoring induce bugs? an empirical study. In Source Code Analysis and Manipulation (SCAM), 2012 IEEE 12th International Working Conference on. IEEE, 104-113.
[19]
Luca Berardinelli, Vittorio Cortellessa, and Antinisca Di Marco. 2010. Performance modeling and analysis of context-aware mobile software systems. Fundamental Approaches to Software Engineering ( 2010 ), 353-367.
[20]
Sam Blackshear, Nikos Gorogiannis, Peter W O'Hearn, and Ilya Sergey. 2018. RacerD: compositional static race detection. Proceedings of the ACM on Programming Languages 2, OOPSLA ( 2018 ), 1-28.
[21]
Eric Bodden. 2012. Inter-procedural data-flow analysis with ifds/ide and soot. In Proceedings of the ACM SIGPLAN International Workshop on State of the Art in Java Program analysis. ACM, 3-8.
[22]
Arnab De and Deepak D'Souza. 2012. Scalable Flow-Sensitive Pointer Analysis for Java with Strong Updates. In ECOOP 2012-Object-Oriented Programming-26th European Conference, Beijing, China, June 11-16, 2012. Proceedings (Lecture Notes in Computer Science), James Noble (Ed.), Vol. 7313. Springer, 665-687. https://doi.org/10.1007/978-3-642-31057-7_29
[23]
F-Droid. 2020. F-Droid. https://f-droid.org/. Accessed: 2020-07-22.
[24]
Umar Farooq and Zhijia Zhao. 2018. RuntimeDroid: Restarting-Free Runtime Change Handling for Android Apps. In Proceedings of the 16th ACM International Conference on Mobile Systems, Applications, and Services (MobiSys '18). ACM, New York, NY, USA, 110-122. https://doi.org/10.1145/3210240.3210327
[25]
George Fourtounis and Yannis Smaragdakis. 2019. Deep Static Modeling of invokedynamic. In 33rd European Conference on Object-Oriented Programming.
[26]
Github. 2020. Github. https://github.com/. Accessed: 2020-09-10.
[27]
Google. 2020a. Android AsyncTask. https://developer.android.com/reference/android/os/AsyncTask. Accessed: 2020-08-30.
[28]
Google. 2020b. Android Developer Guides: Handle Configuration Changes. https://developer.android.com/guide/topics/ resources/runtime-changes. Accessed: 2020-04-30.
[29]
Google. 2020c. Android NativeActivity. https://developer.android.com/reference/android/app/NativeActivity. Accessed: 2020-08-30.
[30]
Google. 2020d. Android Processes and Application Lifecycle. https://developer.android.com/guide/components/activities/ process-lifecycle. Accessed: 2020-04-30.
[31]
Google. 2020e. Android Saving UI States. https://developer.android.com/topic/libraries/architecture/saving-states. Accessed: 2020-04-30.
[32]
Google. 2020f. IntentService. https://developer.android.com/reference/android/app/IntentService. Accessed: 2020-09-10.
[33]
Google. 2020g. A Java serialization/deserialization library to convert Java Objects into JSON and back. https://github.com/ google/gson. Accessed: 2020-4-30.
[34]
Google. 2020h. Overview of memory management. https://developer.android.com/topic/performance/memory-overview. Accessed: 2020-04-30.
[35]
Google. 2020i. Services overview. https://developer.android.com/guide/components/services. Accessed: 2020-09-10.
[36]
Google. 2020j. ViewModel Overview. https://developer.android.com/topic/libraries/architecture/viewmodel. Accessed: 2020-09-08.
[37]
GooglePlay. 2020. Google Play. https://play.google.com/. Accessed: 2020-07-22.
[38]
Chun-Hung Hsiao, Jie Yu, Satish Narayanasamy, Ziyun Kong, Cristiano L Pereira, Gilles A Pokam, Peter M Chen, and Jason Flinn. 2014. Race detection for event-driven mobile applications. ACM SIGPLAN Notices 49, 6 ( 2014 ), 326-336.
[39]
Cuixiong Hu and Iulian Neamtiu. 2011. Automating GUI testing for Android applications. In Proceedings of the 6th International Workshop on Automation of Software Test. ACM, 77-83.
[40]
Gang Hu, Xinhao Yuan, Yang Tang, and Junfeng Yang. 2014. Eficiently, efectively detecting mobile app bugs with appdoctor. In Proceedings of the Ninth European Conference on Computer Systems. ACM, 18.
[41]
Niel Lebeck, Arvind Krishnamurthy, Henry M. Levy, and Irene Zhang. 2020. End the Senseless Killing: Improving Memory Management for Mobile Operating Systems. In 2020 USENIX Annual Technical Conference (USENIX ATC 20). USENIX Association, 873-887. https://www.usenix.org/conference/atc20/presentation/lebeck
[42]
K Rustan M Leino and Peter Müller. 2004. Object invariants in dynamic contexts. In European Conference on Object-Oriented Programming. Springer, 491-515.
[43]
Ondřej Lhoták and Laurie Hendren. 2003. Scaling Java Points-to Analysis Using Spark. In Compiler Construction, 12th International Conference (LNCS), G. Hedin (Ed.), Vol. 2622. Springer, Warsaw, Poland, 153-169.
[44]
Chieh-Jan Mike Liang, Nicholas D Lane, Niels Brouwers, Li Zhang, Börje F Karlsson, Hao Liu, Yan Liu, Jun Tang, Xiang Shan, Ranveer Chandra, et al. 2014. Caiipa: Automated large-scale mobile app testing through contextual fuzzing. In Proceedings of the 20th annual international conference on Mobile computing and networking. ACM, 519-530.
[45]
Max Lillack, Christian Kästner, and Eric Bodden. 2014. Tracking load-time configuration options. In Proceedings of the 29th ACM/IEEE international conference on Automated software engineering. ACM, 445-456.
[46]
Yu Lin, Cosmin Radoi, and Danny Dig. 2014. Retrofitting concurrency for android applications through refactoring. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering. ACM, 341-352.
[47]
Yepang Liu, Chang Xu, and Shing-Chi Cheung. 2014. Characterizing and detecting performance bugs for smartphone applications. In Proceedings of the 36th International Conference on Software Engineering. ACM, 1013-1024.
[48]
Pallavi Maiya, Aditya Kanade, and Rupak Majumdar. 2014. Race detection for android applications. In ACM SIGPLAN Notices, Vol. 49. ACM, 316-325.
[49]
Henry Muccini, Antonio Di Francesco, and Patrizio Esposito. 2012. Software testing of mobile applications: Challenges and future research directions. In Proceedings of the 7th International Workshop on Automation of Software Test. IEEE Press, 29-35.
[50]
Semih Okur, David L Hartveld, Danny Dig, and Arie van Deursen. 2014. A study and toolkit for asynchronous programming in C. In Proceedings of the 36th International Conference on Software Engineering. ACM, 1117-1127.
[51]
Thomas Reps, Susan Horwitz, and Mooly Sagiv. 1995. Precise interprocedural dataflow analysis via graph reachability. In Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, 49-61.
[52]
Cagri Sahin, Lori Pollock, and James Clause. 2014. How do code refactorings afect energy usage?. In Proceedings of the 8th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement. ACM, 36.
[53]
Malavika Samak, Murali Krishna Ramanathan, and Suresh Jagannathan. 2015. Synthesizing racy tests. ACM SIGPLAN Notices 50, 6 ( 2015 ), 175-185.
[54]
Malavika Samak, Omer Tripp, and Murali Krishna Ramanathan. 2016. Directed synthesis of failing concurrent executions. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications. 430-446.
[55]
Max Schäfer, Julian Dolby, Manu Sridharan, Emina Torlak, and Frank Tip. 2010. Correct refactoring of concurrent java code. ECOOP 2010-Object-Oriented Programming ( 2010 ), 225-249.
[56]
Max Schafer, Manu Sridharan, Julian Dolby, and Frank Tip. 2011. Refactoring Java programs for flexible locking. In Software Engineering (ICSE), 2011 33rd International Conference on. IEEE, 71-80.
[57]
Zhiyong Shan, Tanzirul Azim, and Iulian Neamtiu. 2016. Finding resume and restart errors in Android applications. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications. ACM, 864-880.
[58]
Soot. 2020. Soot: a Java Optimization Framework. https://www.sable.mcgill.ca/soot/. Accessed: 2020-07-01.
[59]
Manu Sridharan, Satish Chandra, Julian Dolby, Stephen J Fink, and Eran Yahav. 2013. Alias analysis for object-oriented programs. In Aliasing in Object-Oriented Programming. Types, Analysis and Verification. Springer, 196-232.
[60]
Manu Sridharan, Denis Gopan, Lexin Shan, and Rastislav Bodík. 2005. Demand-Driven Points-to Analysis for Java. SIGPLAN Not. 40, 10 (Oct. 2005 ), 59-76. https://doi.org/10.1145/1103845.1094817
[61]
Statista. 2020. Mobile operating systems' market share worldwide from January 2012 to July 2020. https://www.statista. com/statistics/272698/global-market-share-held-by-mobile-operating-systems-since-2009 /. Accessed: 2020-09-08.
[62]
statista. 2020. Number of smartphone users worldwide 2016-2021. https://www.statista.com/statistics/330695/number-ofsmartphone-users-worldwide/. Accessed: 2020-04-30.
[63]
Omer Tripp, Marco Pistoia, Patrick Cousot, Radhia Cousot, and Salvatore Guarnieri. 2013. Andromeda: Accurate and Scalable Security Analysis of Web Applications. In Proceedings of the 16th International Conference on Fundamental Approaches to Software Engineering (Lecture Notes in Computer Science), Vol. 7793. Springer International Publishing, 210-225. https://doi.org/10.1007/978-3-642-37057-1_15
[64]
Guoqing Xu, Atanas Rountev, and Manu Sridharan. 2009. Scaling CFL-reachability-based points-to analysis using contextsensitive must-not-alias analysis. In European Conference on Object-Oriented Programming. Springer, 98-122.
[65]
Dacong Yan, Guoqing Xu, and Atanas Rountev. 2011. Demand-Driven Context-Sensitive Alias Analysis for Java (ISSTA '11). Association for Computing Machinery, New York, NY, USA, 155-165. https://doi.org/10.1145/2001420.2001440
[66]
Dacong Yan, Shengqian Yang, and Atanas Rountev. 2013. Systematic testing for resource leaks in Android applications. In Software Reliability Engineering (ISSRE), 2013 IEEE 24th International Symposium on. IEEE, 411-420.
[67]
Razieh Nokhbeh Zaeem, Mukul R Prasad, and Sarfraz Khurshid. 2014. Automated generation of oracles for testing userinteraction features of mobile apps. In Software Testing, Verification and Validation (ICST), 2014 IEEE Seventh International Conference on. IEEE, 183-192.

Cited By

View all
  • (2024)DMMPP: Constructing Dummy Main Methods for Android Apps with Path-Sensitive PredicatesProceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3650212.3685302(1826-1830)Online publication date: 11-Sep-2024
  • (2023)DDLDroid: A Static Analyzer for Automatically Detecting Data Loss Issues in Android ApplicationsProceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3597926.3604916(1471-1474)Online publication date: 12-Jul-2023
  • (2023)An Empirical Study of Functional Bugs in Android AppsProceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3597926.3598138(1319-1331)Online publication date: 12-Jul-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 4, Issue OOPSLA
November 2020
3108 pages
EISSN:2475-1421
DOI:10.1145/3436718
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 13 November 2020
Published in PACMPL Volume 4, Issue OOPSLA

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Android
  2. Runtime Configuration Change
  3. Software Restart
  4. Static Analysis

Qualifiers

  • Research-article

Funding Sources

  • National Science Foundation
  • Google

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)231
  • Downloads (Last 6 weeks)34
Reflects downloads up to 15 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2024)DMMPP: Constructing Dummy Main Methods for Android Apps with Path-Sensitive PredicatesProceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3650212.3685302(1826-1830)Online publication date: 11-Sep-2024
  • (2023)DDLDroid: A Static Analyzer for Automatically Detecting Data Loss Issues in Android ApplicationsProceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3597926.3604916(1471-1474)Online publication date: 12-Jul-2023
  • (2023)An Empirical Study of Functional Bugs in Android AppsProceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3597926.3598138(1319-1331)Online publication date: 12-Jul-2023
  • (2023)DDLDroid: Efficiently Detecting Data Loss Issues in Android AppsProceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3597926.3598089(703-714)Online publication date: 12-Jul-2023
  • (2023)Detecting Potential User-data Save & Export Losses due to Android App Termination2023 IEEE/ACM International Conference on Automation of Software Test (AST)10.1109/AST58925.2023.00019(152-162)Online publication date: May-2023
  • (2022)iFixDataloss: a tool for detecting and fixing data loss issues in Android appsProceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3533767.3543297(785-788)Online publication date: 18-Jul-2022
  • (2022)Detecting resource utilization bugs induced by variant lifecycles in AndroidProceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3533767.3534413(642-653)Online publication date: 18-Jul-2022
  • (2022)Detecting and fixing data loss issues in Android appsProceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3533767.3534402(605-616)Online publication date: 18-Jul-2022

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media