Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 12: Backup and restore - New format for the XML configuration #16699

Merged
merged 2 commits into from
Jun 3, 2022

Conversation

ashiagr
Copy link
Contributor

@ashiagr ashiagr commented Jun 3, 2022

Fixes #16067

This PR adds backup configuration xml in the new format for apps targetting Android 12. The old configuration is still required for devices running Android 11 or lower, hence renamed and retained.

Testing instructions

  1. Update targetSdkVersion to 31 in build.gradle.
  2. Switch to the flavor vanillaDebug.
  3. Make sure backup is enabled on the device by running adb shell bmgr enabled. If not, enable it from Settings > Google -> Backup.
  4. Run the app on an Android 12 device (make sure to log in and toggle through tabs so that at least wordpress database and org.wordpress.android_preferences.xml sharedprefs file is generated).
    To verify their existence, check the contents of the directory /data/data/org.wordpress.android/shared_prefs and confirm the existence of the file org.wordpress.android_preferences.xml, similarly check /data/data/org.wordpress.android/databases and confirm the existence of the file wordpress (you can use the tab "Device File Explorer" from Android Studio for this).
  5. Run the command: adb shell bmgr backupnow org.wordpress.android.
  6. Once the backup succeeds, delete contents of of the directory /data/data/org.wordpress.android/shared_prefs and /data/data/org.wordpress.android/databases.
  7. Make sure you don't run the app after this last step.
  8. Run the command adb shell dumpsys backup and grab the token of the Current section.
  9. Run the command adb shell bmgr restore {token} org.wordpress.android where the token is from the last step.
  10. Check the contents of the directory /data/data/org.wordpress.android/shared_prefs and confirm that the file org.wordpress.android_preferences.xml is restored.
  11. Check the contents of the directory /data/data/org.wordpress.android/databases and confirm that the file wordpress is restored.

For more details on the testing steps, check the official guide: https://developer.android.com/guide/topics/data/testingbackup

P.S. You may see a transport error on step 5. This section can help in troubleshooting common issues.
The first time I ran the backup command, I got this error:Transport rejected package because it wasn't able to process it at the time.
The issue was resolved on trying after few hours.

Regression Notes

  1. Potential unintended areas of impact
    N/A

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    N/A

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@ashiagr ashiagr added this to the 20.1 milestone Jun 3, 2022
@ashiagr ashiagr requested a review from AjeshRPai June 3, 2022 02:25
@ashiagr ashiagr self-assigned this Jun 3, 2022
@peril-wordpress-mobile
Copy link

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

You can test the changes on this Pull Request by downloading the APKs:

Copy link
Contributor

@AjeshRPai AjeshRPai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashiagr Thanks for working on this. Sorry for the delay in the review of this PR as I was reading upon backup configuration and how to test it.

I have tested the changes according to the instructions. All looks good. 👍🏼 🙌🏼

@AjeshRPai AjeshRPai merged commit 6458485 into trunk Jun 3, 2022
@AjeshRPai AjeshRPai deleted the issue/16067-android12-backup-restore-xml branch June 3, 2022 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android 12: Backup and restore - New format for the XML configuration
2 participants