diff options
author | junjiez <junjiez@codeaurora.org> | 2018-11-20 17:52:11 +0800 |
---|---|---|
committer | junjiez <junjiez@codeaurora.org> | 2018-11-21 10:35:51 +0800 |
commit | 963fb695cf83cc2f9ba96b3f22041aaf4c3cc286 (patch) | |
tree | b69dcb454e995ab3e4a870c3ac62c98fa83c0444 | |
parent | 41de1355ef13aa6ed7793415ee6cb40cd8386f4e (diff) | |
download | android_packages_apps_Gallery2-963fb695cf83cc2f9ba96b3f22041aaf4c3cc286.tar.gz android_packages_apps_Gallery2-963fb695cf83cc2f9ba96b3f22041aaf4c3cc286.tar.bz2 android_packages_apps_Gallery2-963fb695cf83cc2f9ba96b3f22041aaf4c3cc286.zip |
SnapdraongGallery:Fix black screen
1.Force the surface of the videoView to
be recreated after resume when it's null
2.Process screen off intent only when
screen is in off state.
Change-Id: Ifc2fc5ca5414f3fd8bd753abb1e4e8f7477f6645
CRs-Fixed: 2348871
-rwxr-xr-x | src/com/android/gallery3d/app/MovieActivity.java | 12 | ||||
-rwxr-xr-x[-rw-r--r--] | src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | 11 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 376338863..62ffa753f 100755 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -52,6 +52,7 @@ import android.os.Bundle; import android.os.SystemProperties; import android.provider.MediaStore; import android.provider.OpenableColumns; +import android.view.Display; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -109,7 +110,6 @@ public class MovieActivity extends AbstractPermissionActivity { private boolean mIsHeadsetOn = false; private boolean mVirtualizerSupported = false; private boolean mBassBoostSupported = false; - private boolean mUserPresentReceived = false; static enum Key { global_enabled, bb_strength, virt_strength @@ -746,21 +746,21 @@ public class MovieActivity extends AbstractPermissionActivity { @Override public void onReceive(Context context, Intent intent) { + Display display = getWindowManager().getDefaultDisplay(); if (LOG) { Log.v(TAG, "onReceive(" + intent.getAction() + ") mControlResumed=" + mControlResumed); } - if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) { + if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction()) && + display.getState() == Display.STATE_OFF) { // Only stop video. - if (mControlResumed && mUserPresentReceived) { + if (mControlResumed) { mPlayer.onStop(); - mUserPresentReceived = false; mControlResumed = false; } } else if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())) { - if (!mControlResumed && !mUserPresentReceived) { + if (!mControlResumed) { mPlayer.onResume(); - mUserPresentReceived = true; mControlResumed = true; } } diff --git a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java index 6b5a9bef0..0768e78fc 100644..100755 --- a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java +++ b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java @@ -461,6 +461,17 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr clearVideoInfo(); if (mUri == null || mSurfaceHolder == null || mTargetState == STATE_ERROR) { // not ready for playback just yet, will try again later + if (mSurfaceHolder == null) { + setVisibility(GONE); + getHolder().removeCallback(mSHCallback); + getHolder().addCallback(mSHCallback); + postDelayed(new Runnable() { + @Override + public void run() { + setVisibility(VISIBLE); + } + },500); + } return; } |