diff options
3 files changed, 19 insertions, 9 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 6f9767c41..0f19f1491 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -188,7 +188,6 @@ public class CallLogFragment extends Fragment setHasOptionsMenu(true); mVoicemailPlaybackPresenter = new VoicemailPlaybackPresenter(activity, state); - activity.setVolumeControlStream(VoicemailPlaybackPresenter.PLAYBACK_STREAM); } /** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */ diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index cc6437627..60425e484 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -121,6 +121,7 @@ public class VoicemailPlaybackPresenter */ private final AtomicInteger mDuration = new AtomicInteger(0); + private Activity mActivity; private Context mContext; private PlaybackView mView; private static MediaPlayer mMediaPlayer; @@ -147,11 +148,14 @@ public class VoicemailPlaybackPresenter private PowerManager.WakeLock mProximityWakeLock; private AudioManager mAudioManager; - public VoicemailPlaybackPresenter(Context context, Bundle savedInstanceState) { - mContext = context; + public VoicemailPlaybackPresenter(Activity activity, Bundle savedInstanceState) { + mActivity = activity; + mContext = activity; mAsyncTaskExecutor = AsyncTaskExecutors.createAsyncTaskExecutor(); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); + mActivity.setVolumeControlStream(VoicemailPlaybackPresenter.PLAYBACK_STREAM); + if (savedInstanceState != null) { // Restores playback state when activity is recreated, such as after rotation. mVoicemailUri = (Uri) savedInstanceState.getParcelable(VOICEMAIL_URI_KEY); diff --git a/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java b/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java index 96ef62abf..ea341a30e 100644 --- a/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java +++ b/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java @@ -18,6 +18,7 @@ package com.android.dialer.voicemail; import static com.android.dialer.voicemail.VoicemailPlaybackPresenter.Tasks.CHECK_FOR_CONTENT; +import android.app.Activity; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; @@ -25,13 +26,14 @@ import android.content.Context; import android.content.res.AssetManager; import android.net.Uri; import android.provider.VoicemailContract; -import android.test.InstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; import android.view.View; import android.widget.TextView; import com.android.contacts.common.test.IntegrationTestUtils; import com.android.dialer.R; +import com.android.dialer.calllog.CallLogActivity; import com.android.dialer.util.AsyncTaskExecutors; import com.android.dialer.util.FakeAsyncTaskExecutor; import com.android.dialer.util.LocaleTestUtils; @@ -48,13 +50,13 @@ import java.util.Locale; * Unit tests for the {@link VoicemailPlaybackPresenter} and {@link VoicemailPlaybackLayout}. */ @LargeTest -public class VoicemailPlaybackTest extends InstrumentationTestCase { +public class VoicemailPlaybackTest extends ActivityInstrumentationTestCase2<CallLogActivity> { private static final String TEST_ASSET_NAME = "quick_test_recording.mp3"; private static final String MIME_TYPE = "audio/mp3"; private static final String CONTACT_NUMBER = "+1412555555"; private static final String VOICEMAIL_FILE_LOCATION = "/sdcard/sadlfj893w4j23o9sfu.mp3"; - private Context mContext; + private Activity mActivity; private VoicemailPlaybackPresenter mPresenter; private VoicemailPlaybackLayout mLayout; @@ -63,6 +65,10 @@ public class VoicemailPlaybackTest extends InstrumentationTestCase { private LocaleTestUtils mLocaleTestUtils; private FakeAsyncTaskExecutor mFakeAsyncTaskExecutor; + public VoicemailPlaybackTest() { + super(CallLogActivity.class); + } + @Override public void setUp() throws Exception { super.setUp(); @@ -75,10 +81,11 @@ public class VoicemailPlaybackTest extends InstrumentationTestCase { mLocaleTestUtils = new LocaleTestUtils(getInstrumentation().getTargetContext()); mLocaleTestUtils.setLocale(Locale.US); - mContext = getInstrumentation().getTargetContext(); - mLayout = new VoicemailPlaybackLayout(mContext); + mActivity = getActivity(); + mLayout = new VoicemailPlaybackLayout(mActivity); mLayout.onFinishInflate(); - mPresenter = new VoicemailPlaybackPresenter(mContext, null); + + mPresenter = new VoicemailPlaybackPresenter(mActivity, null); } @Override |