Skip to content

refactor: Migrate SQLCipher Android to new API #4874

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

Conversation

ShadowRZ
Copy link
Contributor

Content

Migrate SQLCipher for Android to use the refreshed API

Motivation and context

The legacy API of SQLCipher for Android has been deprecated in favor of the new API.

Additionally the new SQLCipher library supports 16kb alignment.

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 15

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@ShadowRZ ShadowRZ requested a review from a team as a code owner June 13, 2025 07:49
@ShadowRZ ShadowRZ requested review from bmarty and removed request for a team June 13, 2025 07:49
Copy link
Contributor

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • Your branch should be based on origin/develop, at least when it was created.
  • The title of the PR will be used for release notes, so it needs to describe the change visible to the user.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Jun 13, 2025
Copy link

codecov bot commented Jun 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.30%. Comparing base (4eb4692) to head (54db580).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
...n/io/element/encrypteddb/SqlCipherDriverFactory.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4874      +/-   ##
===========================================
- Coverage    80.30%   80.30%   -0.01%     
===========================================
  Files         2155     2155              
  Lines        57332    57333       +1     
  Branches      7221     7221              
===========================================
- Hits         46043    46041       -2     
  Misses        8841     8841              
- Partials      2448     2451       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
Tested on a local nightly build (so with enabled optimization), and application can be upgraded from a previous version (so with the previous version of the library) without any issue.

Do you know why the latest GitHub release is 4.6.0 and not 4.7.2?(see https://github.com/sqlcipher/sqlcipher-android/releases)?

Also we will merge the PR after the next release candidate has been build to avoid any risk on this sensitive update. In particular one of the encrypted database contains the user credentials, so a problem could break the user access to their session.

@ShadowRZ
Copy link
Contributor Author

@bmarty sqlcipher/sqlcipher-android does not create GitHub Releases anymore, they only push Git tags to the repo.

As for 4.7.2, it's used in SQLCipher for Android Migration, and I'll bump to the latest version 4.9.0 shortly. (Using 4.7.2 is primarily for testing binding migration before bumping to 4.9.0)

@ShadowRZ ShadowRZ force-pushed the features/shadowrz/migrate-sqlcipher-to-new-api branch from 82c8c04 to f198c7e Compare June 17, 2025 09:18
@jmartinesp
Copy link
Member

From what I could test locally, the upgrade seems to work fine, the Maestro run is failing with an unrelated issue:

CommandMetadata(numberOfRuns=null, evaluatedCommand=MaestroCommand(runScriptCommand=RunScriptCommand(script=// This array contains all the required environment variable. When adding a variable, add it here also.
// If a variable is missing, an error will occur.
if (MAESTRO_APP_ID == null) throw "Fatal: missing env variable MAESTRO_APP_ID"
if (MAESTRO_USERNAME == null) throw "Fatal: missing env variable MAESTRO_USERNAME"
if (MAESTRO_PASSWORD == null) throw "Fatal: missing env variable MAESTRO_PASSWORD"
if (MAESTRO_RECOVERY_KEY == null) throw "Fatal: missing env variable MAESTRO_RECOVERY_KEY"
if (MAESTRO_ROOM_NAME == null) throw "Fatal: missing env variable MAESTRO_ROOM_NAME"
if (MAESTRO_INVITEE1_MXID == null) throw "Fatal: missing env variable MAESTRO_INVITEE1_MXID"
if (MAESTRO_INVITEE2_MXID == null) throw "Fatal: missing env variable MAESTRO_INVITEE2_MXID"
, env={}, sourceDescription=./scripts/checkEnv.js, condition=null, label=null, optional=false)), logMessages=[], insight=Insight(message=, level=NONE), aiReasoning=null)
15:45:02.622 [ERROR] maestro.orchestra.Orchestra.executeCommands: [Command execution] CommandFailed: Fatal: missing env variable MAESTRO_PASSWORD (./scripts/checkEnv.js#6)
15:45:02.623 [ INFO] maestro.Maestro.takeScreenshot: Taking screenshot
15:45:02.625 [TRACE] maestro.utils.ScreenshotUtils.takeScreenshot: Taking screenshot to output sink
15:45:13.211 [ERROR] maestro.cli.runner.TestRunner.runCatching: Failed to run flow
org.mozilla.javascript.JavaScriptException: Fatal: missing env variable MAESTRO_PASSWORD (./scripts/checkEnv.js#6)

@bmarty
Copy link
Member

bmarty commented Jun 23, 2025

OK, that's fine then, since forks cannot access GitHub secret (code). Thanks @jmartinesp !

@bmarty bmarty merged commit 3f520f5 into element-hq:develop Jun 23, 2025
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants