Assigned
Status Update
Comments
pi...@gmail.com <pi...@gmail.com> #3
Thanks. Let us know when you have some API design (not looking for a doc, just commenting here is also fine, whichever is easier for you).
One tricky bit about this one is the "transactionality" of it.
e.g. we need to handle the case where we called onPopuplated but application crashed before onPopulated
could succeed. We need to re-run it in the next run.
We might do this by keeping a record in room_master_table
(there might be a better option, this is the first thing that comes to my mind)
ji...@honeywell.corp-partner.google.com <ji...@honeywell.corp-partner.google.com> #4
I looked around the code and I found out that actual copying of the database file is done in SQLiteCopyOpenHelper - getWritableDatabase() and getReadableDatabase() methods are calling verifyDatabaseFile() which does the copying under the hoods.
My idea is to:
1. Add RoomDatabase.Callback#onPopulated method
2. SQLiteCopyOpenHelper already has access to a list of callbacks (List<RoomDatabase.Callback>) through mDatabaseConfiguration.callbacks
3. Modify getWritableDatabase() and getReadableDatabase() so that after the file is copied I can iterate over those callbacks and call onPopulated. I would pass mDelegate.getWritableDatabase() and mDelegate.getReadableDatabase() as a parameter to onPopulated.
4. Add tests in DatabaseCallbackTest
I asked Danny about it and he said that I might need to temporarily open the DB with a vanilla open helper just to invoke onPopulated close it and then let Room re-open it through the normal path. Not sure how would I do that yet so I'm still reading and trying to get better understanding of the code.
This probably also doesn't take this "transactionality" thing into account so I need to look into it. I think I'll try to create some tests that will help me verify if it works or not.
I'm also wondering if there is a way to build the lib locally so I can test it on a sample project. Can I somehow publish it to local maven or something?
My idea is to:
1. Add RoomDatabase.Callback#onPopulated method
2. SQLiteCopyOpenHelper already has access to a list of callbacks (List<RoomDatabase.Callback>) through mDatabaseConfiguration.callbacks
3. Modify getWritableDatabase() and getReadableDatabase() so that after the file is copied I can iterate over those callbacks and call onPopulated. I would pass mDelegate.getWritableDatabase() and mDelegate.getReadableDatabase() as a parameter to onPopulated.
4. Add tests in DatabaseCallbackTest
I asked Danny about it and he said that I might need to temporarily open the DB with a vanilla open helper just to invoke onPopulated close it and then let Room re-open it through the normal path. Not sure how would I do that yet so I'm still reading and trying to get better understanding of the code.
This probably also doesn't take this "transactionality" thing into account so I need to look into it. I think I'll try to create some tests that will help me verify if it works or not.
I'm also wondering if there is a way to build the lib locally so I can test it on a sample project. Can I somehow publish it to local maven or something?
we...@gmail.com <we...@gmail.com> #5
1) We probably want a more descriptive name, maybe onPopulatedFromAssets or something like that.
For transactionality, we do actually have a table called `room_master_table` that we can use. I made a mistake on the design of that table by not having proper keys :facepalm: instead it only has 1 id column. It is possible to create a migration for it within room but for this task, we can just add another magic number (we use 42 for identity hash) to check if we did successfully call onPopuplated (and also, we need to call on populated as we propbably don't want to call it if it is not created from assets).
For testing, TestApp is probably sufficient.
If you want to build a maven repo, you can execute:
```
cd room && DIST_DIR=$(pwd)/../repo ./gradlew createDiffArchiveForAndroidxRoom
```
This is a special task that checks the versions inmaven.google.com and creates a zip with artifacts that do not exist in there (you may need to bump the LibrrayVersion).
For transactionality, we do actually have a table called `room_master_table` that we can use. I made a mistake on the design of that table by not having proper keys :facepalm: instead it only has 1 id column. It is possible to create a migration for it within room but for this task, we can just add another magic number (we use 42 for identity hash) to check if we did successfully call onPopuplated (and also, we need to call on populated as we propbably don't want to call it if it is not created from assets).
For testing, TestApp is probably sufficient.
If you want to build a maven repo, you can execute:
```
cd room && DIST_DIR=$(pwd)/../repo ./gradlew createDiffArchiveForAndroidxRoom
```
This is a special task that checks the versions in
Description
Suite / Plan GTS / gts
Suite / Build 12_r3 / 13064529
Host Info Result/@start (Linux - 4.15.0-142-generic)
Start time / End Time Wed Mar 19 18:38:51 CST 2025 / Wed Mar 19 18:41:19 CST 2025
Tests Passed 0
Tests Failed 2
Modules Done 2
Modules Total 2
Fingerprint ASKEY/RC40/RC40:14/1.0.0.20250319/20250319:userdebug/test-keys
Security Patch 2025-04-05
Release (SDK) 14 (34)
ABIs arm64-v8a,armeabi-v7a,armeabi
Module Passed Failed Assumption Failure Ignored Total Tests Done
arm64-v8a GtsOsTestCases 0 1 0 0 1 true
armeabi-v7a GtsOsTestCases 0 1 0 0 1 true
arm64-v8a GtsOsTestCases
Test Result Details
com.google.android.os.gts.GoogleRequirementFreezeTest#testChipsetInfo
fail
java.lang.AssertionError: A new launching device is using a vendor software older than allowed (enforced by ending api level).
The test case in GTS12_R2 it is PASS,
But in GTS12_R3 it fails.
I would like to ask if this test item has been modified recently