summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-05-16 10:54:14 -0700
committerThe Android Automerger <android-build@android.com>2012-05-16 15:52:08 -0700
commit8130925c60b786759e852a6088776c626d8ee0e2 (patch)
tree1030ef5d60024d7c41e728240acf1f85bafa3504
parentfaac4c284d470bc5fa380a37a22272a65931cad7 (diff)
downloadandroid_packages_apps_Gallery2-8130925c60b786759e852a6088776c626d8ee0e2.tar.gz
android_packages_apps_Gallery2-8130925c60b786759e852a6088776c626d8ee0e2.tar.bz2
android_packages_apps_Gallery2-8130925c60b786759e852a6088776c626d8ee0e2.zip
Fix a dead lock while we freeze the screen.
bug: 6504696 Change-Id: If960967142bb0df773ce075bf76f5726c37e1d27
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java1
-rw-r--r--src/com/android/gallery3d/ui/GLRoot.java1
-rw-r--r--src/com/android/gallery3d/ui/GLRootView.java40
3 files changed, 40 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index a46c777fa..2022a6e2d 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -56,7 +56,6 @@ import com.android.gallery3d.ui.GLView;
import com.android.gallery3d.ui.ImportCompleteListener;
import com.android.gallery3d.ui.MenuExecutor;
import com.android.gallery3d.ui.PhotoView;
-import com.android.gallery3d.ui.ScreenNail;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SynchronizedHandler;
import com.android.gallery3d.util.GalleryUtils;
diff --git a/src/com/android/gallery3d/ui/GLRoot.java b/src/com/android/gallery3d/ui/GLRoot.java
index 5ed323a88..f4b7572a7 100644
--- a/src/com/android/gallery3d/ui/GLRoot.java
+++ b/src/com/android/gallery3d/ui/GLRoot.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.ui;
import android.graphics.Matrix;
+
import com.android.gallery3d.anim.CanvasAnimation;
public interface GLRoot {
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index 1f25b9085..73e982509 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -19,12 +19,12 @@ package com.android.gallery3d.ui;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
-import android.graphics.Rect;
import android.opengl.GLSurfaceView;
import android.os.Process;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.SurfaceHolder;
import com.android.gallery3d.anim.CanvasAnimation;
import com.android.gallery3d.common.Utils;
@@ -467,6 +467,7 @@ public class GLRootView extends GLSurfaceView
@Override
public void onPause() {
+ unfreeze();
super.onPause();
if (DEBUG_PROFILE) {
Log.d(TAG, "Stop profiling");
@@ -510,4 +511,41 @@ public class GLRootView extends GLSurfaceView
mFreezeCondition.signalAll();
mRenderLock.unlock();
}
+
+ // We need to unfreeze in the following methods and in onPause().
+ // These methods will wait on GLThread. If we have freezed the GLRootView,
+ // the GLThread will wait on main thread to call unfreeze and cause dead
+ // lock.
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+ unfreeze();
+ super.surfaceChanged(holder, format, w, h);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ unfreeze();
+ super.surfaceCreated(holder);
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ unfreeze();
+ super.surfaceDestroyed(holder);
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ unfreeze();
+ super.onDetachedFromWindow();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ unfreeze();
+ } finally {
+ super.finalize();
+ }
+ }
}