Only rewrite file when there has been a change to a list of users

Due to I/O operations being performed on BG thread, every call, especially during user boot, adds to the overall performance impact. This change adds extra checks to ensure writing only happens when the change occured.

Bug: 331980379
Bug: 335667295
Test: perfetto trace && manual
Change-Id: I86c04ef7307b10e6336b80699c1091f107d8d1bc
2 files changed