-
Notifications
You must be signed in to change notification settings - Fork 59
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
Crash after launch fixed #3508
Crash after launch fixed #3508
Conversation
b8e13cc
to
badf137
Compare
tools:ignore="UnusedAttribute,LockedOrientationActivity" | ||
tools:replace="android:theme"> | ||
tools:replace="android:allowBackup,android:theme"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We disallowed backup @Aleem92 for privacy & security reasons. This backup is stored in the Android logged-in user drive, compromising the confidentiality of the data collected via the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We disallowed backup @Aleem92 for privacy & security reasons. This backup is stored in the Android logged-in user drive, compromising the confidentiality of the data collected via the app.
1- allowBackup="false" and fullBackupContent="false" are disabling the backup system entirely.
2- dataExtractionRules="@xml/data_extraction_rules" is pointing to the XML file that would prevent any data from being backed up or transferred. This is now the recommended way to control backups for newer Android versions.
3- tools:replace="android:allowBackup"
does the following:
- Overrides the
android:allowBackup
value from any libraries. - Ensures the currently mentioned
android:allowBackup
setting in the manifest takes priority.
@@ -55,7 +55,7 @@ class FhirEngineModule { | |||
FhirEngineProvider.init( | |||
FhirEngineConfiguration( | |||
enableEncryptionIfSupported = !BuildConfig.DEBUG, | |||
databaseErrorStrategy = DatabaseErrorStrategy.UNSPECIFIED, | |||
databaseErrorStrategy = DatabaseErrorStrategy.RECREATE_AT_OPEN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the implication for using this DatabaseErrorStrategy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the implication for using this
DatabaseErrorStrategy
?
The DatabaseErrorStrategy.RECREATE_AT_OPEN was implemented to solve a critical issue where the app crashes on startup after restoring a backup. The application is unable to read from the restored database due to this error:
FATAL EXCEPTION: main Process: org.smartregister.opensrp.eusm, PID: 18215 java.lang.RuntimeException: Unable to create application org.smartregister.fhircore.quest.QuestApplication: android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master; at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7003) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) Caused by: android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master; at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method) at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:89) at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62) at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:91) at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:50) at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:60) at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:2019) at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1905) at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SQLiteDatabase.java:2672) at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2602) at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1250) at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1325) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:167) at com.google.android.fhir.db.impl.SQLCipherSupportHelper.getWritableDatabase(SQLCipherSupportHelper.kt:91) at com.google.android.fhir.db.impl.SQLCipherSupportHelper.<init>(SQLCipherSupportHelper.kt:122) at com.google.android.fhir.db.impl.SQLCipherSupportHelper.<init>(SQLCipherSupportHelper.kt:36) at com.google.android.fhir.db.impl.DatabaseImpl.lambda$2$lambda$1(DatabaseImpl.kt:97) at com.google.android.fhir.db.impl.DatabaseImpl$$ExternalSyntheticLambda0.create(D8$$SyntheticClass:0) at com.google.android.fhir.db.impl.ResourceDatabase_Impl.createOpenHelper(ResourceDatabase_Impl.java:378) at androidx.room.RoomDatabase.init(RoomDatabase.kt:186) at androidx.room.RoomDatabase$Builder.build(RoomDatabase.kt:1358) at com.google.android.fhir.db.impl.DatabaseImpl.<init>(DatabaseImpl.kt:116) at com.google.android.fhir.FhirServices$Builder.build(FhirServices.kt:83) at com.google.android.fhir.FhirEngineProvider.getOrCreateFhirService(FhirEngineProvider.kt:99) at com.google.android.fhir.FhirEngineProvider.getInstance(FhirEngineProvider.kt:63) at org.smartregister.fhircore.engine.di.FhirEngineModule.provideFhirEngine(FhirEngineModule.kt:82) at org.smartregister.fhircore.engine.di.FhirEngineModule_ProvideFhirEngineFactory.provideFhirEngine(FhirEngineModule_ProvideFhirEngineFactory.java:60) at org.smartregister.fhircore.quest.DaggerQuestApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerQuestApplication_HiltComponents_SingletonC.java:1384) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) at org.smartregister.fhircore.quest.DaggerQuestApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerQuestApplication_HiltComponents_SingletonC.java:1517) at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) 2024-09-18 14:47:49.475 18215-18215 AndroidRuntime pid-18215 E at org.smartregister.fhircore.quest.DaggerQuestApplication_HiltComponents_SingletonC$SingletonCImpl.injectQuestApplication2(DaggerQuestApplication_HiltComponents_SingletonC.java:1347) at org.smartregister.fhircore.quest.DaggerQuestApplication_HiltComponents_SingletonC$SingletonCImpl.injectQuestApplication(DaggerQuestApplication_HiltComponents_SingletonC.java:1336) at org.smartregister.fhircore.quest.Hilt_QuestApplication.hiltInternalInject(Hilt_QuestApplication.java:52) at org.smartregister.fhircore.quest.Hilt_QuestApplication.onCreate(Hilt_QuestApplication.java:43) at org.smartregister.fhircore.quest.QuestApplication.onCreate(QuestApplication.kt:59) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998) ... 9 more
This strategy ensures the app remains functional by resetting the database if it can't be read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This strategy is NOT respected when opening a previously unencrypted database with an encrypted configuration or vice versa. An IllegalStateException is thrown instead.
Out of curiosity does the new version of the APK use the same encryption for the DB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR fixes the problem at hanf. Good job on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity does the new version of the APK use the same encryption for the DB?
No changes were made to the encryption strategy in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aleem92 Just one comment then we can merge this
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3508 +/- ##
=========================================
- Coverage 27.2% 27.1% -0.1%
- Complexity 749 753 +4
=========================================
Files 275 275
Lines 13940 13995 +55
Branches 2532 2545 +13
=========================================
+ Hits 3794 3805 +11
- Misses 9622 9664 +42
- Partials 524 526 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
* Crash after launch fixed * Bump version * reset version code * Backup disabled * Added the unit tests --------- Co-authored-by: Benjamin Mwalimu <dubdabasoduba@gmail.com> (cherry picked from commit 041762f)
IMPORTANT: Where possible all PRs must be linked to a Github issue
Fixes [link to issue]
Engineer Checklist
strings.xml
file./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the project's style guideCode Reviewer Checklist
strings.xml
file