Fix crash when altering rate for voicemails without content.
- Repro for crash was to click on voicemail from call log without
content, try to play it (which would silently fail), then try to
use the rate increase/decrease buttons.
- The error being reported to the ui was disabling all the ui elements
but not the rate buttons.
- This fix makes the ui disable the rate buttons too, as well as showing
a Toast, and logging the exception to logcat.
- This cl also adds the unit tests that prove that the bug is fixed.
- In the process, I discovered another bug where missing extras from
the intent used to start the CallDetailsActivity could cause a crash,
so this adds a test and a fix for that case too.
- Also introduces IntegrationTestUtils class, with some useful methods
for doing things like clicking on different parts of the ui.
Bug: 5047879
Change-Id: I46d18723fe783a7a820446e1e13e19b5af82fa5c
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index 2bea2f3..14fec85 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -174,13 +174,7 @@
public void onResume() {
super.onResume();
updateData(getCallLogEntryUris());
- Uri voicemailUri = getIntent().getExtras().getParcelable(EXTRA_VOICEMAIL_URI);
- optionallyHandleVoicemail(voicemailUri);
- if (voicemailUri != null) {
- mAsyncQueryHandler.startVoicemailStatusQuery(voicemailUri);
- } else {
- mStatusMessageView.setVisibility(View.GONE);
- }
+ optionallyHandleVoicemail();
}
/**
@@ -189,18 +183,22 @@
* If the Intent used to start this Activity contains the suitable extras, then start voicemail
* playback. If it doesn't, then hide the voicemail ui.
*/
- private void optionallyHandleVoicemail(Uri voicemailUri) {
+ private void optionallyHandleVoicemail() {
+ Uri voicemailUri = getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
FragmentManager manager = getFragmentManager();
VoicemailPlaybackFragment fragment = (VoicemailPlaybackFragment) manager.findFragmentById(
R.id.voicemail_playback_fragment);
- if (voicemailUri == null) {
- // No voicemail uri: hide the voicemail fragment.
- manager.beginTransaction().hide(fragment).commit();
- } else {
- // A voicemail: extra tells us if we should start playback or not.
- boolean startPlayback = getIntent().getExtras().getBoolean(
+ if (voicemailUri != null) {
+ // Has voicemail uri: leave the fragment visible. Optionally start the playback.
+ // Do a query to fetch the voicemail status messages.
+ boolean startPlayback = getIntent().getBooleanExtra(
EXTRA_VOICEMAIL_START_PLAYBACK, false);
fragment.setVoicemailUri(voicemailUri, startPlayback);
+ mAsyncQueryHandler.startVoicemailStatusQuery(voicemailUri);
+ } else {
+ // No voicemail uri: hide the voicemail fragment and the status view.
+ manager.beginTransaction().hide(fragment).commit();
+ mStatusMessageView.setVisibility(View.GONE);
}
}