Skip to content

ADR-0073 Android Auto Backup & Session Restore#4427

Draft
dab246 wants to merge 2 commits intomasterfrom
add-adr-0073-disable-backup-data-android
Draft

ADR-0073 Android Auto Backup & Session Restore#4427
dab246 wants to merge 2 commits intomasterfrom
add-adr-0073-disable-backup-data-android

Conversation

@dab246
Copy link
Copy Markdown
Member

@dab246 dab246 commented Mar 31, 2026

Descriptions

An ADR suggests a solution to the problem https://github.com/linagora/james-project-private/issues/1177

Related

#4393

Summary by CodeRabbit

  • Documentation
    • Added an ADR detailing Android Auto Backup and session-restore behavior, outlining three user scenarios (app update, uninstall+reinstall after backup, fresh install), evaluated mitigation options, noted Android 12+ nuances, and recorded open questions; status set to "Proposed."

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 941f7d18-63fe-435c-a048-e19b752795e6

📥 Commits

Reviewing files that changed from the base of the PR and between dbec4af and f41cf73.

📒 Files selected for processing (1)
  • docs/adr/0073-android-auto-backup-and-session-restore.md
✅ Files skipped from review due to trivial changes (1)
  • docs/adr/0073-android-auto-backup-and-session-restore.md

Walkthrough

Adds ADR 0073 documenting Android Auto Backup/restore behavior where Android 6.0+ backups of Hive DB and SharedPreferences are restored before first app launch, causing unintended auto-login after uninstall/reinstall. Specifies required behavior for three scenarios (app update, uninstall+reinstall after backup, fresh install), notes that update vs restore are indistinguishable on the client, evaluates four mitigation options (disable backup, secure storage, file-timestamp heuristic, server-side token validation), includes Android 12+ note, and records status as "Proposed".

Suggested labels

Label

Suggested reviewers

  • tddang-linagora
  • hoangdat
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ADR-0073 Android Auto Backup & Session Restore' directly matches the main change—adding a new ADR document about Android Auto Backup and Session Restore behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-adr-0073-disable-backup-data-android

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/adr/0073-android-auto-backup-and-session-restore.md`:
- Around line 30-35: The decision matrix has an internal contradiction for Case
2: choose one invariant (either "reinstall must require login" or "first
reinstall auto-login acceptable") and apply it consistently; update the "Three
Cases" table row for Case 2, the corresponding entry in the "Option 4" table,
the summary paragraph, and any mentions in "Open Questions"/relevant discussion
so they all state the same requirement (refer to "Case 2", "Three Cases" table,
and "Option 4" table to locate the mismatched entries) and remove the
conflicting wording about "first reinstall auto-login" so acceptance criteria
are unambiguous.
- Around line 57-63: The ADR incorrectly states that "Option 1 logs out update
users"—update the document to reflect that setting allowBackup=false does not
impact in-place APK updates: change the prose that claims Option 1 logs out
update users and modify the table row for "Case 1 | Update app" so the "After
Fix" column shows "✅ Auto login" instead of "❌ Logged out"; ensure any nearby
references to "Case 1" or "allowBackup=false" are corrected to note that normal
updates retain SharedPreferences/databases/files and do not cause logout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1af9f2c0-240e-4211-b86d-9b96041879f3

📥 Commits

Reviewing files that changed from the base of the PR and between 1c1b16d and dbec4af.

📒 Files selected for processing (1)
  • docs/adr/0073-android-auto-backup-and-session-restore.md


## Context

Android 6.0+ enables Auto Backup by default, backing up Hive databases and SharedPreferences to Google Drive. On reinstall, this data is restored **before the app first launches** — causing the app to auto-login without re-authentication.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Upon uninstall is there an option to also clean the backup?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No. Uninstall only removes local data, it does not delete cloud/server backups.


**Option 2** stores the auth token in `flutter_secure_storage` (Android Keystore, never backed up). Uninstall clears it → force login. But users updating from old version have no token yet → also logged out, violating Case 1.

**Option 4** validates the session token server-side on each startup. The server invalidates old tokens on re-login, making Case 2 correct on the second reinstall. Only complete solution but requires backend changes and adds startup latency.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please @guimard review this.

Also how about

Option 5: upon uninstall the app triggers a logout effectively forcing to reconnect?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Option 5 is not feasible because the app cannot execute any code during uninstall → it cannot trigger a logout.

@dab246 dab246 requested a review from chibenwa April 1, 2026 07:55

| # | Scenario | Required Behavior |
|---|---|---|
| 1 | Update from old → new version | ✅ Keep auto login (hard requirement) |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
| 1 | Update from old → new version | Keep auto login (hard requirement) |
| 1 | Update from old → new version | Keep user not be logging out |

| # | Scenario | Required Behavior |
|---|---|---|
| 1 | Update from old → new version | ✅ Keep auto login (hard requirement) |
| 2 | Backup → uninstall → reinstall new version | ❌ Force login |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
| 2 | Backup → uninstall → reinstall new version | Force login |
| 2 | Backup → uninstall → reinstall new version | Force login |

|---|---|---|
| 1 | Update from old → new version | ✅ Keep auto login (hard requirement) |
| 2 | Backup → uninstall → reinstall new version | ❌ Force login |
| 3 | Fresh install | ❌ Force login |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
| 3 | Fresh install | Force login |
| 3 | Fresh install | Force login |

@chibenwa
Copy link
Copy Markdown
Member

chibenwa commented Apr 3, 2026

I understand there is decision to be made.

Let's do this on wednesday meeting.

@Crash-- Crash-- marked this pull request as draft April 8, 2026 04:20
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.

3 participants