Skip to content

App crashes when sleep timer is reset and then canceled #345

@whyyys

Description

@whyyys

Checklist

  • I can reproduce the bug with the latest version given here.
  • I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • This issue contains only one bug.
  • I have read and understood the contribution guidelines.

Affected app version

1.7.0

Affected Android/Custom ROM version

Android 12

Affected device model

OPPO Reno8 and others

How did you install the app?

GitHub releases

Steps to reproduce the bug

  1. Open Fossify Music Player.
  2. Set a sleep timer for playback.
  3. Set the sleep timer again.
  4. Observe that the countdown stops.
  5. Cancel the timer.
  6. Observe that the application exits immediately.

Expected behavior

The sleep timer should continue functioning normally after being reset, and canceling it should not cause the app to exit.

Actual behavior

The timer stops counting, and canceling it causes the application to exit immediately.

Screenshots/Screen recordings

ignoreImageMinify ignoreImageMinify ignoreImageMinify ignoreImageMinify ignoreImageMinify

Additional information

The bug can be reproduced and verified using the following Kea2 script logic:

  1. Set a sleep timer (Timer A);
  2. Set the sleep timer again (Timer B);
  3. Use Kea2 property-based assertions to monitor the timer status;
  4. Cancel the timer while Timer B is active;
  5. Observe whether the application exits immediately.

Example Kea2 assertion:

  • property: timer_is_active → true
  • action: cancel_timer
  • expected: Application continues running, timer_is_active becomes false
  • actual: Application crashes (exits)

Reference Code:

import unittest
import uiautomator2 as u2

from time import sleep
from kea2 import precondition, prob, KeaTestRunner, Options
from kea2.u2Driver import U2Driver


class Player_Timer_Test(unittest.TestCase):

    def setUp(self):
        self.d = u2.connect()
    
    @prob(0.7)
    @precondition(
        lambda self: self.d.xpath('//*[@content-desc="More options"]').exists
    )
    def test_setTimer(self):
        """
        Test setting the timer in the music player.
        """
        print("Setting timer")
        self.d.xpath('//*[@content-desc="More options"]').click()
        if self.d.xpath('//*[@text="Sleep timer"]').exists:
            self.d.xpath('//*[@text="Sleep timer"]').click()
        sleep(0.5)
        if self.d.xpath('//android.widget.RadioButton[@text="10 minutes"]').exists:
            self.d.xpath('//android.widget.RadioButton[@text="10 minutes"]').click()


    @prob(0.5)
    @precondition(
        lambda self: self.d.xpath('//*[@resource-id="org.fossify.musicplayer:id/sleep_timer_stop"]').exists
    )
    def test_cancelTimer(self):
        """
        Test canceling the timer and asserting app stability.
        """
        print("Canceling timer")
        self.d.xpath('//*[@resource-id="org.fossify.musicplayer:id/sleep_timer_stop"]').click()
        sleep(0.5)

        assert self.d.app_current()['package'] == "org.fossify.musicplayer", \
        f"Expected org.fossify.musicplayer running, but current is {self.d.app_current()['package']}"

    def tearDown(self):
        print("Test completed")


if __name__ == "__main__":
    KeaTestRunner.setOptions(
        Options(
            driverName="d",
            Driver=U2Driver,
            packageNames=["org.fossify.musicplayer"],
            serial="emulator-5554",
            maxStep=20,
            profile_period=10,
            take_screenshots=True,
            agent="u2"
        )
    )
    unittest.main(testRunner=KeaTestRunner)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions