Skip to content

Commit

Permalink
Merge pull request #7 from motorro/play-core-1.6.4
Browse files Browse the repository at this point in the history
Play core 1.6.4
  • Loading branch information
motorro authored Oct 28, 2019
2 parents 1708825 + 2cfcb26 commit e4855b3
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions appupdatewrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ dependencies {

api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

api 'androidx.core:core:1.2.0-alpha04'
kapt 'androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha05'
api 'com.google.android.play:core:1.6.3'
api 'androidx.core:core:1.2.0-beta01'
kapt 'androidx.lifecycle:lifecycle-common-java8:2.2.0-rc01'
api 'com.google.android.play:core:1.6.4'

implementation 'com.jakewharton.timber:timber:4.7.1'

testImplementation project(":testapp")
testImplementation 'androidx.test:core:1.2.1-alpha02'
testImplementation 'androidx.test.ext:junit:1.1.2-alpha02'
testImplementation 'junit:junit:4.13-beta-3'
testImplementation 'junit:junit:4.13-rc-1'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.robolectric:robolectric:4.3.1'
}

dokka {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ internal sealed class FlexibleUpdateState : AppUpdateState(), Tagged {
with(appUpdateInfo) {
when (updateAvailability()) {
DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS -> when (installStatus()) {
REQUIRES_UI_INTENT -> updateConsent(appUpdateInfo)
PENDING, DOWNLOADING -> downloading()
DOWNLOADED -> installConsent()
INSTALLING -> completeUpdate()
Expand Down Expand Up @@ -305,6 +304,7 @@ internal sealed class FlexibleUpdateState : AppUpdateState(), Tagged {
)
)
}
else -> timber.w("Unexpected install status: %s", formatInstallStatus(state.installStatus()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ private fun AppUpdateInfo.formatUpdateAvailability(): String = when(updateAvaila
*/
fun formatInstallStatus(status: Int): String = when(status) {
InstallStatus.UNKNOWN -> "UNKNOWN"
InstallStatus.REQUIRES_UI_INTENT -> "REQUIRES_UI_INTENT"
InstallStatus.PENDING -> "PENDING"
InstallStatus.DOWNLOADING -> "DOWNLOADING"
InstallStatus.DOWNLOADED -> "DOWNLOADED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.motorro.appupdatewrapper
import android.app.Activity
import android.os.Looper.getMainLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.android.play.core.appupdate.AppUpdateInfo
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.install.model.ActivityResult
import com.google.android.play.core.install.model.AppUpdateType
Expand Down Expand Up @@ -154,10 +155,10 @@ internal class FlexibleUpdateStateTest: BaseAppUpdateStateTest() {

@Test
fun checkingStateWillNotProceedIfStoppedBeforeTaskCompletes() {
val updateInfo = createUpdateInfo(
UpdateAvailability.UPDATE_AVAILABLE,
InstallStatus.UNKNOWN
)
val updateInfo = mock<AppUpdateInfo> {
on { updateAvailability() } doReturn UpdateAvailability.UPDATE_AVAILABLE
on { installStatus() } doReturn InstallStatus.UNKNOWN
}
val testTask = createTestInfoTask()
val testUpdateManager: AppUpdateManager = mock {
on { this.appUpdateInfo } doReturn testTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ package com.motorro.appupdatewrapper
import android.app.Activity
import android.os.Looper
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.android.play.core.appupdate.AppUpdateInfo
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.install.model.ActivityResult
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.AppUpdateType.IMMEDIATE
import com.google.android.play.core.install.model.InstallStatus
import com.google.android.play.core.install.model.UpdateAvailability
Expand Down Expand Up @@ -121,10 +123,10 @@ internal class ImmediateUpdateStateTest: BaseAppUpdateStateTest() {

@Test
fun checkingStateWillNotProceedIfStoppedBeforeTaskCompletes() {
val updateInfo = createUpdateInfo(
UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS,
InstallStatus.UNKNOWN
)
val updateInfo = mock<AppUpdateInfo> {
on { updateAvailability() } doReturn UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS
on { installStatus() } doReturn InstallStatus.UNKNOWN
}
val testTask = createTestInfoTask()
val testUpdateManager: AppUpdateManager = mock {
on { this.appUpdateInfo } doReturn testTask
Expand Down Expand Up @@ -162,10 +164,11 @@ internal class ImmediateUpdateStateTest: BaseAppUpdateStateTest() {

@Test
fun updatingStateWillStartImmediateUpdateOnResume() {
val updateInfo = createUpdateInfo(
UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS,
InstallStatus.UNKNOWN
)
val updateInfo = mock<AppUpdateInfo> {
on { updateAvailability() } doReturn UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS
on { installStatus() } doReturn InstallStatus.UNKNOWN
on { isUpdateTypeAllowed(IMMEDIATE) } doReturn true
}

val state = ImmediateUpdateState.Update(updateInfo).init()
state.onResume()
Expand All @@ -177,11 +180,11 @@ internal class ImmediateUpdateStateTest: BaseAppUpdateStateTest() {

@Test
fun updatingStateWillSetFailedStateIfUpdateTypeNotSupported() {
val updateInfo = createUpdateInfo(
UpdateAvailability.UNKNOWN,
InstallStatus.UNKNOWN,
immediateAvailable = false
)
val updateInfo = mock<AppUpdateInfo> {
on { updateAvailability() } doReturn UpdateAvailability.UNKNOWN
on { installStatus() } doReturn InstallStatus.UNKNOWN
on { isUpdateTypeAllowed(IMMEDIATE) } doReturn false
}

val state = ImmediateUpdateState.Update(updateInfo).init()
state.onResume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,10 @@ import com.google.android.play.core.tasks.Task
import com.nhaarman.mockitokotlin2.spy
import org.robolectric.annotation.LooperMode

const val APP_PACKAGE = "com.motorro.appupdatewrapper"
const val APP_VERSION = 100500

/**
* Creates custom update info
* @param updateAvailability One of [com.google.android.play.core.install.model.UpdateAvailability] values
* @param installStatus One of [com.google.android.play.core.install.model.InstallStatus] values
* @param immediateAvailable If true, immediate update is available
* @param flexibleAvailable If true, flexible update is available
* Detects Windows OS
*/
fun createUpdateInfo(updateAvailability: Int, installStatus: Int, immediateAvailable: Boolean = true, flexibleAvailable: Boolean = true): AppUpdateInfo = object: AppUpdateInfo(){
override fun availableVersionCode(): Int = APP_VERSION
override fun updateAvailability(): Int = updateAvailability
override fun packageName(): String = APP_PACKAGE
override fun installStatus(): Int = installStatus
override fun isUpdateTypeAllowed(updateType: Int): Boolean = when(updateType) {
AppUpdateType.FLEXIBLE -> flexibleAvailable
AppUpdateType.IMMEDIATE -> immediateAvailable
else -> false
}
}
fun isRunningWindows() = true == System.getProperty("os.name")?.toLowerCase()?.contains("windows")

/**
* A task that may [succeed] or [fail] on demand
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.ajoberstar.grgit:grgit-gradle:3.0.0'
classpath 'com.novoda:bintray-release:0.9.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
2 changes: 1 addition & 1 deletion testapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/Theme.AppCompat.Light">
<activity android:name="com.motorro.appupdatewrapper.testapp.TestUpdateActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
12 changes: 1 addition & 11 deletions testapp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,4 @@
~
-->

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
<resources/>

0 comments on commit e4855b3

Please sign in to comment.