From 9a3bac25fd63069ed9c164e8687c130fe7d5bdea Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 28 Jun 2018 11:56:35 -0600 Subject: [PATCH 1/2] Disable "internal" when adoption not possible. When adoption isn't possible, we shortcut to try formatting as external, but that still results in a warning dialog that the user could cancel away from and then manually pick "internal." Bug: 110863258 Test: atest com.android.settings.ui.StorageWizardTest Change-Id: I04645c3fce11a883c10996772d73440a0dcd51ec --- src/com/android/settings/deviceinfo/StorageWizardInit.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java index 076e606cb31..51dd74bdb3e 100644 --- a/src/com/android/settings/deviceinfo/StorageWizardInit.java +++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java @@ -56,6 +56,7 @@ public class StorageWizardInit extends StorageWizardBase { if (!mDisk.isAdoptable()) { // If not adoptable, we only have one choice + mInternal.setEnabled(false); onNavigateExternal(null); } else if (!mIsPermittedToAdopt) { // TODO: Show a message about why this is disabled for guest and From 87007778393facface3753401ac8d830280485fa Mon Sep 17 00:00:00 2001 From: Doris Ling Date: Fri, 29 Jun 2018 14:22:36 -0700 Subject: [PATCH 2/2] Fix continous playing of gesture animation video. In the gesture settings, we listen to surface texture updates to determine when both the view and video is ready, and we auto play the animation video. However, sometimes, the video listener will receive the surface texture updates after the settings activity is being paused, in which case, the video will continue to play until the user navigate back to that gesture settings page. In onSurfaceTextureUpdated(), check for view visibility before we try to update anything to avoid unnecessary operation. Change-Id: I46474c9f461d5705f599deb8b2535d8505f2fe75 Bug: 110923173 Test: make RunSettingsRoboTests --- .../settings/widget/VideoPreference.java | 9 +++++++- .../settings/widget/VideoPreferenceTest.java | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java index fcbad465f97..ad08ebe49e4 100644 --- a/src/com/android/settings/widget/VideoPreference.java +++ b/src/com/android/settings/widget/VideoPreference.java @@ -48,10 +48,12 @@ public class VideoPreference extends Preference { MediaPlayer mMediaPlayer; @VisibleForTesting boolean mAnimationAvailable; - private boolean mVideoReady; + @VisibleForTesting + boolean mVideoReady; private boolean mVideoPaused; private float mAspectRadio = 1.0f; private int mPreviewResource; + private boolean mViewVisible; public VideoPreference(Context context, AttributeSet attrs) { super(context, attrs); @@ -144,6 +146,9 @@ public class VideoPreference extends Preference { @Override public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { + if (!mViewVisible) { + return; + } if (mVideoReady) { if (imageView.getVisibility() == View.VISIBLE) { imageView.setVisibility(View.GONE); @@ -172,6 +177,7 @@ public class VideoPreference extends Preference { } public void onViewVisible(boolean videoPaused) { + mViewVisible = true; mVideoPaused = videoPaused; if (mVideoReady && mMediaPlayer != null && !mMediaPlayer.isPlaying()) { mMediaPlayer.seekTo(0); @@ -179,6 +185,7 @@ public class VideoPreference extends Preference { } public void onViewInvisible() { + mViewVisible = false; if (mMediaPlayer != null && mMediaPlayer.isPlaying()) { mMediaPlayer.pause(); } diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java index 153a91b2656..26b102bba9a 100644 --- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java +++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java @@ -17,11 +17,17 @@ package com.android.settings.widget; import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; +import android.graphics.SurfaceTexture; import android.media.MediaPlayer; import android.view.LayoutInflater; +import android.view.TextureView; import com.android.settings.R; import com.android.settings.testutils.SettingsRobolectricTestRunner; @@ -70,4 +76,20 @@ public class VideoPreferenceTest { (AspectRatioFrameLayout) mPreferenceViewHolder.findViewById(R.id.video_container); assertThat(layout.mAspectRatio).isWithin(0.01f).of(VIDEO_WIDTH / (float) VIDEO_HEIGHT); } + + @Test + public void onSurfaceTextureUpdated_viewInvisible_shouldNotStartPlayingVideo() { + final TextureView video = + (TextureView) mPreferenceViewHolder.findViewById(R.id.video_texture_view); + mVideoPreference.mAnimationAvailable = true; + mVideoPreference.mVideoReady = true; + mVideoPreference.onBindViewHolder(mPreferenceViewHolder); + mVideoPreference.onViewInvisible(); + when(mMediaPlayer.isPlaying()).thenReturn(false); + final TextureView.SurfaceTextureListener listener = video.getSurfaceTextureListener(); + + listener.onSurfaceTextureUpdated(mock(SurfaceTexture.class)); + + verify(mMediaPlayer, never()).start(); + } }