diff options
author | maxwelb <maxwelb@google.com> | 2017-10-10 17:17:18 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-10-11 07:09:33 -0700 |
commit | 36a5f1a127ca18869cd25cef0315076591a0b518 (patch) | |
tree | d51a48886fe21dc7b2ed4ac17fbae3dd382c5f79 /java | |
parent | 58cefb413c11c02d0c1be8504df027724617f175 (diff) |
Handle race condition with CallComposerActivity.onBackPressed
For fast users/testing suites, it's possible to hit a race condition
where onBackPressed is called multiple times in a way that allows the
second call to endCallComposerSession to happen and crash.
This CL fixes the issue by checking that the session still exists prior
to calling endCallComposerSession.
I tried to write tests for this, but since the code guards against this
from happening, I wasn't able to get the code into a situation to cause
the crash.
Bug: 64136293
Test: none
PiperOrigin-RevId: 171758119
Change-Id: Ie12fd2f4390329b9bebb503fa3cf0f26d3bc1caf
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialer/callcomposer/CallComposerActivity.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/java/com/android/dialer/callcomposer/CallComposerActivity.java b/java/com/android/dialer/callcomposer/CallComposerActivity.java index b02e32543..83fe2d9de 100644 --- a/java/com/android/dialer/callcomposer/CallComposerActivity.java +++ b/java/com/android/dialer/callcomposer/CallComposerActivity.java @@ -528,12 +528,18 @@ public class CallComposerActivity extends AppCompatActivity @Override public void onBackPressed() { + LogUtil.enterBlock("CallComposerActivity.onBackPressed"); if (!isSendAndCallHidingOrHidden) { ((CallComposerFragment) adapter.instantiateItem(pager, currentIndex)).clearComposer(); } else if (!runningExitAnimation) { // Unregister first to avoid receiving a callback when the session closes getEnrichedCallManager().unregisterStateChangedListener(this); - getEnrichedCallManager().endCallComposerSession(sessionId); + + // If the user presses the back button when the session fails, there's a race condition here + // since we clean up failed sessions. + if (getEnrichedCallManager().getSession(sessionId) != null) { + getEnrichedCallManager().endCallComposerSession(sessionId); + } runExitAnimation(); } } |