Repository navigation
fix(call): keep the incoming call window open on a sleeping phone - #6851
ToteMeiSter wants to merge 4 commits into
Conversation
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a14c18d0-6b96-4ab2-9207-d5d0228d4bd9
📒 Files selected for processing (3)
app/src/main/AndroidManifest.xmlapp/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.javaapp/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.
|
Hello there, 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.) |
|
Thank you for you contributions. We will try to review this soon! |
…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
d516cb1 to
f21d382
Compare
… 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
f21d382 to
acc45dd
Compare
|
🖼️ 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.completeResumeLockedwhether a just resumed activity turns the screen on or goes to sleep (android-12.0.0_r34, ActivityRecord.java#5425):canTurnScreenOn()needsturnScreenOnandshowWhenLocked.CallBaseActivitysets both withsetTurnScreenOn()/setShowWhenLocked()inonCreate. 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 ofR.attr.turnScreenOndescribes 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 hasshowOnLockScreen, which is the old name ofshowForAllUsers.Device logs (Android 12): all 7 call windows started on a sleeping screen got two
onResume; 3 of them got anonStopin between, 35–70 ms after the firstonResume.The window then reads this
onStopas the user leaving:onStop()cancels the call notification, andsetupNotificationCanceledRoutinecloses the window within a second because the notification is gone.On API 26–30 the same pause also calls
enterPipMode()fromonTopResumedActivityChanged(false)/onPause(). It first callsenableKeyguard()(setShowWhenLocked(false)), and PiP is refused on the lock screen, so the window ends up behind the keyguard.Possibly related: #6585, #2763.
🔧 Change
CallNotificationActivitydeclaresandroid:showWhenLockedandandroid:turnScreenOn. The platform knows them before the start, wakes the screen at once and does not pause the window. The calls indismissKeyguard()stay for API 26.onStop; it cancels it inonDestroyonly 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 inonCreatehas no timestamp and no longer crashes there.CallBaseActivitydoes 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+.CallBaseActivitylogs the interactive and keyguard state inonStart,onPause,onStopandonTopResumedActivityChanged.Not changed:
CallActivity.processExtrascancels the notification forKEY_FROM_NOTIFICATION_START_CALL; the routine then closes the window.getPeersForCallcheck inNotificationWorkerremove the notification as before; the routine closes the window.🧪 How to verify
CallBaseActivityshows noonStopbetween start and answer.🏁 Checklist
CallNotificationActivitycannot be created in a Robolectric test without the Dagger application graph (onCreateinjects it), and the change inCallBaseActivityis a single check ofPowerManager.isInteractive()inside the activity./backport to stable-xx.x🤖 AI (if applicable)
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.