skip to main content
research-article
Open Access

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

Published:13 November 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

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.Google ScholarGoogle Scholar
  2. 2020. K-9 Mail. https://github.com/k9mail/k-9. Accessed: 2020-07-22.Google ScholarGoogle Scholar
  3. 2020. MapBox. https://github.com/mapbox/mapbox-gl-native. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  4. 2020. Open MF. https://github.com/openMF/android-client. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  5. 2020. StackOveflow Question 456211. https://stackoverflow.com/questions/456211/activity-restart-on-rotation-android. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  6. 2020. TileView Library. https://github.com/moagrius/TileView. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  7. 2020. WordPress-Android. https://github.com/wordpress-mobile/WordPress-Android. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 ).Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. alliedmarketresearch. 2020. Mobile Application Market by Marketplace. https://www.alliedmarketresearch.com/mobileapplication-market. Accessed: 2020-04-30.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  14. Apple. 2020c. Reducing Disk Writes. https://developer.apple.com/documentation/xcode/improving_your_app_s_performance/reducing_disk_writes. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. F-Droid. 2020. F-Droid. https://f-droid.org/. Accessed: 2020-07-22.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. George Fourtounis and Yannis Smaragdakis. 2019. Deep Static Modeling of invokedynamic. In 33rd European Conference on Object-Oriented Programming.Google ScholarGoogle Scholar
  26. Github. 2020. Github. https://github.com/. Accessed: 2020-09-10.Google ScholarGoogle Scholar
  27. Google. 2020a. Android AsyncTask. https://developer.android.com/reference/android/os/AsyncTask. Accessed: 2020-08-30.Google ScholarGoogle Scholar
  28. Google. 2020b. Android Developer Guides: Handle Configuration Changes. https://developer.android.com/guide/topics/ resources/runtime-changes. Accessed: 2020-04-30.Google ScholarGoogle Scholar
  29. Google. 2020c. Android NativeActivity. https://developer.android.com/reference/android/app/NativeActivity. Accessed: 2020-08-30.Google ScholarGoogle Scholar
  30. Google. 2020d. Android Processes and Application Lifecycle. https://developer.android.com/guide/components/activities/ process-lifecycle. Accessed: 2020-04-30.Google ScholarGoogle Scholar
  31. Google. 2020e. Android Saving UI States. https://developer.android.com/topic/libraries/architecture/saving-states. Accessed: 2020-04-30.Google ScholarGoogle Scholar
  32. Google. 2020f. IntentService. https://developer.android.com/reference/android/app/IntentService. Accessed: 2020-09-10.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  34. Google. 2020h. Overview of memory management. https://developer.android.com/topic/performance/memory-overview. Accessed: 2020-04-30.Google ScholarGoogle Scholar
  35. Google. 2020i. Services overview. https://developer.android.com/guide/components/services. Accessed: 2020-09-10.Google ScholarGoogle Scholar
  36. Google. 2020j. ViewModel Overview. https://developer.android.com/topic/libraries/architecture/viewmodel. Accessed: 2020-09-08.Google ScholarGoogle Scholar
  37. GooglePlay. 2020. Google Play. https://play.google.com/. Accessed: 2020-07-22.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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/lebeckGoogle ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Pallavi Maiya, Aditya Kanade, and Rupak Majumdar. 2014. Race detection for android applications. In ACM SIGPLAN Notices, Vol. 49. ACM, 316-325.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Malavika Samak, Murali Krishna Ramanathan, and Suresh Jagannathan. 2015. Synthesizing racy tests. ACM SIGPLAN Notices 50, 6 ( 2015 ), 175-185.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. Soot. 2020. Soot: a Java Optimization Framework. https://www.sable.mcgill.ca/soot/. Accessed: 2020-07-01.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  62. statista. 2020. Number of smartphone users worldwide 2016-2021. https://www.statista.com/statistics/330695/number-ofsmartphone-users-worldwide/. Accessed: 2020-04-30.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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.Google ScholarGoogle Scholar

Index Terms

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

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!