  Android apps should be designed to cope with stop-start events, which are the
events that require stopping and restoring the execution of an app while
leaving its state unaltered. These events can be caused by run-time
configuration changes, such as a screen rotation, and by context-switches, such
as a switch from one app to another. When a stop-start event occurs, Android
saves the state of the app, handles the event, and finally restores the saved
state. To let Android save and restore the state correctly, apps must provide
the appropriate support. Unfortunately, Android developers often implement this
support incorrectly, or do not implement it at all. This bad practice makes
apps to incorrectly react to stop-start events, thus generating what we defined
data loss problems, that is Android apps that lose user data, behave
unexpectedly, and crash due to program variables that lost their values. Data
loss problems are difficult to detect because they might be observed only when
apps are in specific states and with specific inputs. Covering all the possible
cases with testing may require a large number of test cases whose execution
must be checked manually to discover whether the app under test has been
correctly restored after each stop-start event. It is thus important to
complement traditional in-house testing activities with mechanisms that can
protect apps as soon as a data loss problem occurs in the field. In this paper
we present DataLossHealer, a technique for automatically identifying and
healing data loss problems in the field as soon as they occur. DataLossHealer
is a technique that checks at run-time whether states are recovered correctly,
and heals the app when needed. DataLossHealer can learn from experience,
incrementally reducing the overhead that is introduced avoiding to monitor
interactions that have been managed correctly by the app in the past.
