Skip to content

Commit

Permalink
Apollo: Release source code for 51.7
Browse files Browse the repository at this point in the history
  • Loading branch information
acrespo committed Jan 24, 2024
1 parent 2edc05e commit f9c102a
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 5 deletions.
7 changes: 7 additions & 0 deletions android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ follow [https://changelog.md/](https://changelog.md/) guidelines.

## [Unreleased]

## [51.6] - 2024-01-24

### FIXED

- A crash when trying to change password using Recovery Code
- A probable source of crashes regarding handling of MuunHeader

## [51.6] - 2024-01-17

### FIXED
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package io.muun.apollo.domain

import androidx.annotation.VisibleForTesting
import io.muun.apollo.data.preferences.BackgroundTimesRepository
import javax.inject.Inject

class BackgroundTimesService @Inject constructor(
private val backgroundTimesRepository: BackgroundTimesRepository,
) {

private val MAX_BKG_TIMES_ARRAY_SIZE: Int = 100
companion object {
@VisibleForTesting
val MAX_BKG_TIMES_ARRAY_SIZE: Int = 100
}

fun enterBackground() {
backgroundTimesRepository.recordEnterBackground()
Expand Down
4 changes: 2 additions & 2 deletions android/apolloui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ android {
applicationId "io.muun.apollo"
minSdkVersion 19
targetSdkVersion 33
versionCode 1106
versionName "51.6"
versionCode 1107
versionName "51.7"

// Needed to make sure these classes are available in the main DEX file for API 19
// See: https://spin.atomicobject.com/2018/07/16/support-kitkat-multidex/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.muun.apollo.domain

import android.content.Context
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import io.muun.apollo.data.preferences.BackgroundTimesRepository
import io.muun.apollo.data.preferences.RepositoryRegistry
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
@RunWith(AndroidJUnit4::class)
class BackgroundTimesServiceTest {

private lateinit var context: Context
private lateinit var backgroundTimesService: BackgroundTimesService
private lateinit var backgroundTimesRepository: BackgroundTimesRepository

@Before
fun setUp() {
context = InstrumentationRegistry.getInstrumentation().targetContext
backgroundTimesRepository = BackgroundTimesRepository(context, RepositoryRegistry())
backgroundTimesService = BackgroundTimesService(
backgroundTimesRepository
)

backgroundTimesRepository.clear()
}

@After
fun cleanUp() {
backgroundTimesRepository.clear()
}

@Test
fun saveSingleBackgroundEventWorks() {
backgroundTimesService.enterBackground()
backgroundTimesService.enterForeground()

val bkgTimes = backgroundTimesRepository.getBackgroundTimes()
assertThat(bkgTimes).isNotEmpty
assertThat(bkgTimes.size).isEqualTo(1)
}

@Test
fun recordForegroundBeforeGoingToBackgroundDoesntStoreAnything() {
// E.g on first open we record enterForeground but since we didn't record enterBackground
// we can't calculation bkgEvent duration so we ignore it.

backgroundTimesService.enterForeground()

val bkgTimes = backgroundTimesRepository.getBackgroundTimes()
assertThat(bkgTimes).isEmpty()
assertThat(bkgTimes.size).isEqualTo(0)

saveSingleBackgroundEventWorks()
}

@Test
fun pruneEventListUponReachingCapLimit() {

val capLimit = BackgroundTimesService.MAX_BKG_TIMES_ARRAY_SIZE

for (i in 1..capLimit + 20) {
backgroundTimesService.enterBackground()
backgroundTimesService.enterForeground()
}

val bkgTimes = backgroundTimesRepository.getBackgroundTimes()
assertThat(bkgTimes).isNotEmpty
// Due to an impl detail we're actually always keeping capLimit + 1 items (hehe)
assertThat(bkgTimes.size).isEqualTo(capLimit + 1)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ private boolean hasFragments() {
* - Fragment#onAttach (so fragment is attached to activity, getActivity returns non null).
*/
final void attachHeader() {
getHeader().attachToActivity(this);
final MuunHeader header = getHeader();
if (header != null) { // MuunHeader's optional for SingleFragment (see SingleActionFragment)
header.attachToActivity(this);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RecoveryCodeFragment : SingleFragment<RecoveryCodePresenter>(), RecoveryCo
presenter.submitRecoveryCode(recoveryCodeBox.segmentInputsContent)
}

override fun setRecoveryCodeError(error: UserFacingError) {
override fun setRecoveryCodeError(error: UserFacingError?) {
recoveryCodeBox.setError(error)
}

Expand Down

0 comments on commit f9c102a

Please sign in to comment.