-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes crash caused by FileObserver on LG devices (#39)
* Fix for persistent OOM crashing issue (cherry picked from commit 4874d79) * Added unit test and logging for OOM issue (cherry picked from commit 8d4c475) * Fix issue with crash due to bad transaction file (#36) * Fix for persistent OOM crashing issue (cherry picked from commit 4874d79) * Added unit test and logging for OOM issue (cherry picked from commit 8d4c475) * Update all libraries, roll version * Update to AGP 7 and update other gradle plugins * Use LG device for testing Harmony * Use proper model name * Create test to replicate issue with LG * Check for info on what is available for LG devices * Remove testing run * Potential fix for LG device crashes * Clean up code, testing negative case * Revert negative test case * Fix test upload * Update test dependencies * Fix issue where FileObserver thread my not be started yet * Improve on FileObserver thread start * Rename some lock objects, ensure FileObserver is initialized immediately * Revert some changes, cleanup * More cleanup * Test negative case again * Reset back to normal test case
- Loading branch information
1 parent
df43a08
commit 9b39b6f
Showing
6 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
harmony/src/androidTest/java/com/frybits/harmony/HarmonyFileObserverTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.frybits.harmony | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.async | ||
import kotlinx.coroutines.awaitAll | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.util.UUID | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class HarmonyFileObserverTest { | ||
|
||
// This tests for regression on a bug specific to LG devices running Android 9 and below | ||
// See https://github.com/pablobaxter/Harmony/issues/38 | ||
@OptIn(ExperimentalStdlibApi::class) | ||
@Test | ||
fun testMultipleHarmonyPrefsImplementation() = runBlocking { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
|
||
val prefsJob = buildList { | ||
repeat(100) { | ||
val prefs = appContext.getHarmonySharedPreferences("prefs-${UUID.randomUUID()}") | ||
add(async(Dispatchers.IO) { | ||
prefs.getString("test-$it", null) | ||
return@async | ||
}) | ||
} | ||
} | ||
|
||
prefsJob.awaitAll() | ||
return@runBlocking | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters