Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 3621745f authored by Eric Biggers's avatar Eric Biggers
Browse files

UserDataPreparer: be more careful about auto-deleting data on error

Currently UserDataPreparer automatically deletes all the user's data
directories if an error occurs.  There are several possible reasons for
this; the original motivation (when this code was added in Android 7) is
not clear.  In any case, it's been demonstrated that it's too dangerous
to apply to all users.  It should only apply to users being created.

Therefore, this CL limits the automatic data deletion to users that have
never "logged in", i.e. users where 'lastLoggedInTime == 0'.

It also limits the call to rebootPromptAndWipeUserData() to first boot.

The disadvantage of this change is that failures for existing users may
now go unnoticed again, considering that UserDataPreparer will just log
and ignore them.  But the error handling really needs to be in the
calling code, in UserController and UserManagerService.  E.g., when
starting (or unlocking) a user, maybe the start (or unlock) should be
cancelled if prepareUserData fails.  All things considered though, even
without other changes, auto-deletion seems like the wrong choice now.

Bug: 307627225
Test: atest UserDataPreparerTest
Test: Verified via the new log message that isNewUser is assigned the
      correct value for both system user and secondary user, both
      existing and newly created; and for both CE and DE storage.
Change-Id: If78d50b17eb4a579586bb659cae2c61f00deb79d
parent 3b84c2ca
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment