Upgrade to Pro — share decks privately, control downloads, hide ads and more …

About Affinity between SQLCipher and Room/CoreData

About Affinity between SQLCipher and Room/CoreData

Bruce Evans
LINE / LINE Communication service development team / Software Engineer
Yuta Takanashi
LINE / LINE Communication service development team / Software Engineer

https://linedevday.linecorp.com/2021/ja/sessions/127
https://linedevday.linecorp.com/2021/en/sessions/127
https://linedevday.linecorp.com/2021/ko/sessions/127

LINE DEVDAY 2021

November 11, 2021
Tweet

More Decks by LINE DEVDAY 2021

Other Decks in Technology

Transcript

  1. Agenda - Introductions - Why? - What is SQLCipher? -

    Android & Room Integration - iOS & CoreData Integration
  2. Yuta Takanashi - Android Engineer - Joined LINE in 2020

    @shiita_0903 [email protected] - iOS Engineer - Joined LINE in 2017 @brevansio [email protected] Bruce Evans
  3. Why? - E2EE (LINE Letter Sealing) covers in-transit data but

    not local data - User Privacy - Legal Issues
  4. Using SQLite Database in Android - Provide an abstraction layer

    over SQLite - Less boilerplate code by code generation - Room is strongly recommended instead of low-level API High-level API(AndroidX Room) Low-level API(BOESPJEEBUBCBTFTRMJUF) - Powerful API - Require a great deal of time and effort to use
  5. Using SQLite Database in Android - Provide an abstraction layer

    over SQLite - Less boilerplate code by code generation - Room is strongly recommended instead of low-level API High-level API(AndroidX Room) Low-level API(BOESPJEEBUBCBTFTRMJUF) - Powerful API - Require a great deal of time and effort to use
  6. Classes in SQLCipher - Encapsulates compilation of SQL statement and

    release of the compiled statement object OFUTRMDJQIFSEBUBCBTF42-JUF$PNQJMFE4RM TRMJUF@TUNU - An object in native code - Represents a single SQL statement OFUTRMDJQIFSEBUBCBTF42-JUF4UBUFNFOU - A pre-compiled statement that can be reused - The statement can return 1x1 result sets 42-JUF$PNQJMFE4RM 42-JUF4UBUFNFOU TRMJUF@TUNU 1 1 1 1
  7. The cause of the SQLCipher problem SFMFBTF4RM4UBUFNFOU is called when

     42-JUF4UBUFNFOU is closed (42-JUF4UBUFNFOU manages 42-JUF$PNQJMFE4RM)  GJOBMJ[F in 42-JUF$PNQJMFE4RM is called
  8. The cause of the SQLCipher problem SFMFBTF4RM4UBUFNFOU is called when

     42-JUF4UBUFNFOU is closed (42-JUF4UBUFNFOU manages 42-JUF$PNQJMFE4RM)  GJOBMJ[F in 42-JUF$PNQJMFE4RM is called
  9. The cause of the Room problem Generated code from DAO

    function with @Query - INSERT/UPDATE/DELETE query - Pass a collection of parameters to a query
  10. Summary of causes  42-JUF$PNQJMFE4RM that isn't closed is released

    in GJOBMJ[F - DB lock can't be acquired in time - Some generated code by Room doesn't call DMPTF
  11. Handling in LINE Android application We considered two workarounds for

    usage of Room - Use low-level API instead of Room - Use @RawQuery instead of @Query
  12. Handling in LINE Android application We considered two workarounds for

    usage of Room - Use low-level API instead of Room - Use @RawQuery instead of @Query
  13. Summary of Android side - Specific conditions on Room and

    SQLCipher cause an exception - We decided to use a workaround with @RawQuery - We should use room better than low-level API
  14. Summary - Introductions - Why? - What is SQLCipher -

    Android & Room Integration - iOS & CoreData Integration