Skip to content

Bug: Timer native channel contract is incomplete and TimerRing uses the wrong channel for foreground restore #886

@Rahul-2k4

Description

@Rahul-2k4

Description

The timer feature has a native-channel contract mismatch.

Flutter invokes timer methods that are not fully implemented on the Android side, and TimerRingController also sends one foregrounding call over the wrong channel.

Affected Code

  • lib/app/modules/timer/controllers/timer_controller.dart
  • lib/app/modules/timerRing/controllers/timer_ring_controller.dart
  • android/app/src/main/kotlin/com/ccextractor/ultimate_alarm_clock/ultimate_alarm_clock/MainActivity.kt

Observed Problems

1. cancelTimer is called from Flutter but not implemented on the timer channel

Flutter code calls:

  • timerChannel.invokeMethod('cancelTimer')

but the Android timer channel handler in MainActivity.kt only implements:

  • playDefaultAlarm
  • stopDefaultAlarm
  • runtimerNotif
  • clearTimerNotif

So cancelTimer currently falls through to notImplemented.

2. TimerRingController calls bringAppToForeground on the wrong channel

TimerRingController uses:

  • MethodChannel('timer')

and then invokes:

  • bringAppToForeground

But bringAppToForeground is implemented on the alarm channel, not the timer channel.

That means the timer ring flow depends on a method that is not exposed on the channel it actually uses.

Why this matters

This creates silent timer-flow breakage:

  • timer cleanup may not actually happen natively
  • timer ring foreground recovery is fragile
  • background/foreground timer behavior becomes inconsistent

Expected Behavior

  • every Flutter timer-channel method must exist on the Android timer channel
  • timer ring foreground recovery must use the correct method/channel contract
  • unsupported timer methods should not silently fail

Suggested Fix

  • define the timer channel contract explicitly
  • add cancelTimer support on the Android timer channel, or remove the Flutter call if it is obsolete
  • route bringAppToForeground through the correct channel, or expose it on the timer channel if that is the intended contract
  • add a small contract test or integration check for the timer method names

Acceptance Criteria

  • cancelTimer from Flutter does not hit notImplemented
  • timer ring background-to-foreground recovery uses a valid native method path
  • timer channel method names are documented and aligned between Flutter and Android
  • regression coverage exists for the timer channel contract

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions