Skip to content

fix(call): keep the incoming call window open on a sleeping phone - #6851

Open
ToteMeiSter wants to merge 4 commits into
nextcloud:masterfrom
ToteMeiSter:fix/call-window-stop-keeps-ringing
Open

ToteMeiSter wants to merge 4 commits into
nextcloud:masterfrom
ToteMeiSter:fix/call-window-stop-keeps-ringing

Conversation

@ToteMeiSter

@ToteMeiSter ToteMeiSter commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🖼️ Screenshots

No UI change.

🚧 Problem

On a sleeping phone the incoming call window is started by the full-screen intent and closes again after about one second. The caller does not get through.

Cause. The platform decides in ActivityRecord.completeResumeLocked whether a just resumed activity turns the screen on or goes to sleep (android-12.0.0_r34, ActivityRecord.java#5425): canTurnScreenOn() needs turnScreenOn and showWhenLocked. CallBaseActivity sets both with setTurnScreenOn() / setShowWhenLocked() in onCreate. These are one-way calls and reach the system server after that decision, so the window is resumed, paused for the sleeping display, often stopped, and resumed again when the screen wakes up. The documentation of R.attr.turnScreenOn describes exactly this: "When using the Window flag during activity startup, there may not be time to add it before the system stops your activity because the screen has not yet turned on. This leads to a double life-cycle as it is then restarted." The manifest only has showOnLockScreen, which is the old name of showForAllUsers.

Device logs (Android 12): all 7 call windows started on a sleeping screen got two onResume; 3 of them got an onStop in between, 35–70 ms after the first onResume.

The window then reads this onStop as the user leaving: onStop() cancels the call notification, and setupNotificationCanceledRoutine closes the window within a second because the notification is gone.

On API 26–30 the same pause also calls enterPipMode() from onTopResumedActivityChanged(false) / onPause(). It first calls enableKeyguard() (setShowWhenLocked(false)), and PiP is refused on the lock screen, so the window ends up behind the keyguard.

Possibly related: #6585, #2763.

🔧 Change

  1. Manifest: CallNotificationActivity declares android:showWhenLocked and android:turnScreenOn. The platform knows them before the start, wakes the screen at once and does not pause the window. The calls in dismissKeyguard() stay for API 26.
  2. The call notification is the state of the call. The window no longer cancels it in onStop; it cancels it in onDestroy only when finishing (decline, e2ee refusal, closing the window). A stop for any other reason (Home, power button, another app) keeps the notification, the ringing and the window. A window finished in onCreate has no timestamp and no longer crashes there.
  3. CallBaseActivity does not enter PiP while the screen is not interactive: a pause of a sleeping screen is not the user leaving. On API 26–30 the call window stays on the lock screen, the same as on API 31+.
  4. CallBaseActivity logs the interactive and keyguard state in onStart, onPause, onStop and onTopResumedActivityChanged.

Not changed:

  • Answer: CallActivity.processExtras cancels the notification for KEY_FROM_NOTIFICATION_START_CALL; the routine then closes the window.
  • Timeout, delete push, decline from the notification and the getPeersForCall check in NotificationWorker remove the notification as before; the routine closes the window.

🧪 How to verify

  1. Lock the phone and switch the screen off. Call this account from another client.
  2. Before: the call window appears and closes after about one second, the ringing stops.
  3. After: the window and the ringing stay until the call is answered, declined, or the caller hangs up or the call times out. Logcat of CallBaseActivity shows no onStop between start and answer.
  4. Press Home or the power button while the call rings: the notification and the ringing stay; waking the screen shows the window again.
  5. Decline in the window: the notification is removed and the window closes. Answer: the call starts, the notification is removed.
  6. On Android 10/11: same as 1–4, the window is not hidden behind the lock screen.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed. Not included: CallNotificationActivity cannot be created in a Robolectric test without the Dagger application graph (onCreate injects it), and the change in CallBaseActivity is a single check of PowerManager.isInteractive() inside the activity.
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The change was prepared with Claude Code (Assisted-by: Claude-Code:claude-opus-5-5). The cause was found in device logs of affected phones and in the AOSP sources; the fix has not been tested on a device yet.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough

Walkthrough

CallNotificationActivity now cancels the call notification in onDestroy() only when the activity is finishing and notificationTimestamp is non-null. The manifest enables lock-screen display and screen wake-up for this activity. CallBaseActivity logs screen and keyguard state and skips picture-in-picture handling when the device is non-interactive.



Priority: ➖ Normal

Merge Risk: 🔵 Low · up to d516c

A screen-off transition can leave the active call window eligible to appear over the lock screen when the phone wakes. Clear the lock-screen override before skipping PiP; the correction is localized, so the remaining risk is bounded.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly describes the primary change: keeping the incoming call window open when the phone is sleeping.
Description check Passed The description is detailed and relevant. It explains the problem, cause, implementation changes, verification steps, testing status, and AI usage. The exact TODO section is omitted, and several check…

Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ToteMeiSter ToteMeiSter changed the title fix(call): keep the incoming call ringing when the call window is only stopped fix(call): keep the incoming call window open on a sleeping phone Oct 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a14c18d0-6b96-4ab2-9207-d5d0228d4bd9
📥 Commits

Reviewing files that changed from the base of the PR and between ece8e08 and d516cb1.

📒 Files selected for processing (3)
  • app/src/main/AndroidManifest.xml
  • app/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.java
  • app/src/main/java/com/nextcloud/talk/callnotification/CallNotificationActivity.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@mahibi

mahibi commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Thank you for you contributions. We will try to review this soon!
If there are merge conflicts or other open points from review, please try to solve it or let us know which other PRs from you should be reviewed beforehand.

…y stopped

CallNotificationActivity.onStop() removed the call notification. The
window closes itself once the notification is gone. On a sleeping phone
the window opened by the full-screen intent gets a short onStop at once,
so the call screen disappeared after about a second and the caller did
not get through. Home and the power button did the same.

The notification is now removed only when the window is finishing.
Decline still removes it, answering is handled by CallActivity.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
…w in the manifest

The platform decides in ActivityRecord.completeResumeLocked whether a started
activity may pause for a sleeping screen. It reads turnScreenOn and
showWhenLocked from the manifest. The setTurnScreenOn() and
setShowWhenLocked() calls in onCreate reach the system server too late, so the
window paused, stopped and resumed again. With the manifest attributes the
platform wakes the screen at once and skips the extra pause.

The attributes need API 27. The calls in CallBaseActivity.dismissKeyguard()
stay for API 26.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
…ing screen

The incoming call window is started by a full-screen intent on a sleeping
screen. The platform then pauses and may stop it before the screen wakes up
and resumes it again. This is the normal lifecycle, so the window must not
read it as a decision of the user.

- CallNotificationActivity removes the call notification only when the window
  is finishing (decline, closing the window, e2ee refusal), in onDestroy. The
  old onStop override is gone. A window that finished in onCreate has no
  notification timestamp and does not crash.
- CallBaseActivity does not enter PiP when the screen is not interactive.
  Entering PiP calls enableKeyguard(), which hides the window behind the lock
  screen on API 26-30.
- CallBaseActivity logs the interactive and keyguard state in onStart,
  onPause, onStop and onTopResumedActivityChanged.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
@rapterjet2004
rapterjet2004 force-pushed the fix/call-window-stop-keeps-ringing branch from d516cb1 to f21d382 Compare November 19, 2026 17:09
… screen state

Addresses code-review findings on top of the sleeping-screen fix:

- CallNotificationActivity: the notification id is the push timestamp, but a
  missing KEY_NOTIFICATION_TIMESTAMP extra decodes to 0 (not null) via
  Bundle.getInt(). Add notificationIdOrNull() so notificationTimestamp is null
  when no notification backs the window; the onDestroy guard then no longer
  cancels an unrelated id 0, and setupNotificationCanceledRoutine() closes a
  window with no backing notification instead of polling id 0 forever.
- CallNotificationActivity: accepting a call now dismisses the ringing
  notification in proceedToCall() via a shared dismissCallNotification() helper
  instead of relying on CallActivity to cancel it from the forwarded extras.
- CallBaseActivity: gate setAutoEnterEnabled on the screen being interactive via
  the pure shouldAutoEnterPip() predicate, and re-evaluate it on ACTION_SCREEN_ON
  /OFF, so API 31+ does not auto-enter picture in picture behind the keyguard when
  the display sleeps.

Add unit tests for notificationIdOrNull() and shouldAutoEnterPip().

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
@rapterjet2004
rapterjet2004 force-pushed the fix/call-window-stop-keeps-ringing branch from f21d382 to acc45dd Compare November 19, 2026 17:12
@rapterjet2004

Copy link
Copy Markdown
Contributor
Event during an incoming call Before After
Screen asleep when call arrives window flashes, call dropped window + ringing stay until answered/declined/timeout
Press Home / power button ringing stopped ringing continues; waking shows the window again
Accept — call starts, notification cancelled
Decline / close notification cancelled notification cancelled (unchanged)
API ≤30 on lock screen window could hide behind keyguard stays visible, like API 31+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants