Stop backing up the ancestral record version unless it has changed
The ancestral record version is a number that's contained in the backup created by the PackageManagerBackupAgent. It's used to indicate how to restore the backed up data. This allows the PackageManagerBackupAgent to change how it stores its data without worrying that it may break other versions of the backup agent during restore. Backup agents should only back up key/value pairs that haven't changed since the last time a backup was done. It should do this by maintaining a local state. The agent is given the state file from the previous backup run (if any) and is given a file to write the new state to. The ancestral record version that the PackageManagerBackupAgent writes to the backup almost never changes. However, this key/value pair was not stored in the local state. As a result, the backup agent backs up this key/value pair on every backup causing unnecessary backup traffic. This change fixes that by storing the ancestral record version in the local state. It then avoids backing it up again when it's present in the local state. It's possible for the ancestral record version in the state file to be different from the current value in the backup agent, for example after a system update. If this happens that means a change was made to the format of the data we back up, so we intentionally back up all key/value pairs to ensure they're all written in the new format. In addition, there may be key/value pairs that were backed up in the past but are no longer backed up (e.g. an app was uninstalled). We remove these key/value pairs since they were created with the older ancestral record version but we can't update them. Bug: 268341874 Test: atest PackageManagerBackupAgentTest.java Change-Id: Iaa805198801b38b0c4867536749095fff243e18e
Loading
Please register or sign in to comment