Skip to content

Commit 406524a

Browse files
committed
Add missing action to LaunchActivity intent
1 parent 910db32 commit 406524a

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class LaunchActivity : AppCompatActivity() {
149149
* apps cannot reach the alias and therefore cannot opt into this behavior.
150150
*/
151151
fun newInstance(context: Context, deepLink: DeepLink? = null, showWhenLocked: Boolean = false): Intent {
152-
return Intent().apply {
152+
return Intent(Intent.ACTION_MAIN).apply {
153153
component = if (showWhenLocked) {
154154
ComponentName(context, LOCK_SCREEN_ALIAS_CLASS)
155155
} else {

app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchActivityTest.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ import io.mockk.unmockkConstructor
3434
import io.mockk.unmockkObject
3535
import io.mockk.verify
3636
import org.junit.After
37-
import org.junit.Assert.assertFalse
38-
import org.junit.Assert.assertTrue
3937
import org.junit.Before
4038
import org.junit.Rule
4139
import org.junit.Test
40+
import org.junit.jupiter.api.Assertions.assertEquals
41+
import org.junit.jupiter.api.Assertions.assertFalse
42+
import org.junit.jupiter.api.Assertions.assertTrue
4243
import org.junit.runner.RunWith
4344
import org.robolectric.RobolectricTestRunner
4445
import org.robolectric.Shadows.shadowOf
@@ -152,6 +153,8 @@ class LaunchActivityTest {
152153
fun `Given showWhenLocked is true when launched then activity is shown over the lock screen`() {
153154
val intent = LaunchActivity.newInstance(ApplicationProvider.getApplicationContext(), showWhenLocked = true)
154155

156+
assertEquals(Intent.ACTION_MAIN, intent.action)
157+
155158
ActivityScenario.launch<LaunchActivity>(intent).use { scenario ->
156159
scenario.onActivity { activity ->
157160
assertTrue(shadowOf(activity).showWhenLocked)
@@ -163,6 +166,8 @@ class LaunchActivityTest {
163166
fun `Given showWhenLocked is false when launched then activity is not shown over the lock screen`() {
164167
val intent = LaunchActivity.newInstance(ApplicationProvider.getApplicationContext(), showWhenLocked = false)
165168

169+
assertEquals(Intent.ACTION_MAIN, intent.action)
170+
166171
ActivityScenario.launch<LaunchActivity>(intent).use { scenario ->
167172
scenario.onActivity { activity ->
168173
assertFalse(shadowOf(activity).showWhenLocked)

0 commit comments

Comments
 (0)