-
Notifications
You must be signed in to change notification settings - Fork 58
Update room version to 2.8.4 #1394
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
base: main
Are you sure you want to change the base?
Conversation
In addition bump gradle and AGP version
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.
Pull request overview
This PR updates the Android Room library from version 2.4.3 to 2.8.4 to fix compatibility issues with modern Android applications. The main change addresses Room's requirement that database queries must not run on the main thread, particularly in constructors.
Key Changes:
- Refactored
OfflineRoomconstructor to remove PRAGMA queries and implement lazy initialization of page size - Updated build infrastructure: Gradle 7.5 → 8.5, AGP 7.3.1 → 8.2.2, minimum SDK 19 → 23
- Simplified native library dependencies by linking maesdk directly via CMake subdirectory
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/OfflineRoom.java | Core fix: moved database queries from constructor to lazy-loaded initPageSize() method; improved field encapsulation |
| lib/android_build/maesdk/build.gradle | Updated Room dependency to 2.8.4 and test dependencies; added Kotlin generation flag |
| lib/android_build/build.gradle | Bumped Android Gradle Plugin from 7.3.1 to 8.2.2 |
| lib/android_build/tools.gradle | Updated compile/target SDK from 32/31 to 34/34, min SDK from 19 to 23 |
| lib/android_build/gradle/wrapper/gradle-wrapper.properties | Updated Gradle wrapper from 7.5 to 8.5 |
| lib/android_build/gradlew | Updated Gradle wrapper scripts with newer template |
| lib/android_build/gradlew.bat | Updated Windows Gradle wrapper script |
| lib/android_build/gradle/wrapper/gradle-wrapper.jar | Binary update for Gradle 8.5 wrapper |
| tools/build-android-aar.sh | New script for building Android AAR files locally with NDK support |
| tests/unittests/PalTests.cpp | Added Android-specific path handling for filesystem tests |
| lib/android_build/app/src/main/cpp/CMakeLists.txt | Changed from importing prebuilt library to building maesdk via subdirectory |
| lib/android_build/app/src/main/java/com/microsoft/applications/events/maesdktest/MainActivity.java | Removed explicit maesdk library loading (handled by CMake now) |
| lib/android_build/app/src/androidTest/java/com/microsoft/applications/events/maesdktest/SDKUnitNativeTest.java | Removed explicit maesdk library loading |
| lib/android_build/app/src/androidTest/java/com/microsoft/applications/events/maesdktest/OfflineRoomUnitTest.java | Added test for lazy-loaded page size; updated deprecated assertion syntax |
| lib/android_build/app/build.gradle | Updated test dependencies to match maesdk module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/OfflineRoom.java
Show resolved
Hide resolved
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/OfflineRoom.java
Outdated
Show resolved
Hide resolved
| private void initPageSize() { | ||
| if (m_pageSize == -1) { | ||
| try (Cursor c = m_db.query("PRAGMA page_size", null)) { | ||
| if (c.getCount() == 1 && c.getColumnCount() == 1) { | ||
| c.moveToFirst(); | ||
| m_pageSize = c.getLong(0); | ||
| } else { | ||
| m_pageSize = PAGE_SIZE_DEFAULT; | ||
| Log.e("MAE", | ||
| String.format("Unexpected result from PRAGMA page_size: %d rows, %d columns", | ||
| c.getCount(), | ||
| c.getColumnCount())); | ||
| } | ||
| } | ||
| } | ||
| } |
Copilot
AI
Dec 23, 2025
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 initPageSize() method is not thread-safe. Multiple threads calling methods like totalSize() or loadPageSize() concurrently could result in race conditions where the PRAGMA query is executed multiple times simultaneously. Consider adding synchronization to ensure the page size is loaded only once.
| assertEquals(1, room.getRecordCount(StorageRecord.EventLatency_Normal)); | ||
| assertThat(room.totalSize(), Matchers.greaterThan(new Long(0))); | ||
| assertThat(room.totalSize(), Matchers.greaterThan(0L)); | ||
| assertNotEquals(room.loadPageSize(), -1L); |
Copilot
AI
Dec 23, 2025
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 test now verifies that loadPageSize() returns a value not equal to -1L, which is good for testing the lazy initialization. However, consider also adding a test to verify that the returned value is actually a valid page size (e.g., greater than 0 and typically a power of 2 like 4096).
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.
@copilot open a new pull request to apply changes based on this feedback
…ons/events/OfflineRoom.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan * Enhance loadPageSize test to verify valid page size Co-authored-by: anod <171704+anod@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: anod <171704+anod@users.noreply.github.com>
Fix #1372 Not Compatible with latest android room 2.7.2
Unblock android apps for upgrading Room library