summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSai Kumar Sanagavarapu <ssanagav@codeaurora.org>2015-03-20 11:50:19 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2015-03-20 09:00:13 -0700
commit9fe993574ba1c819ff0a2801aca0fac3210cb09d (patch)
tree689ea9a3f5c6825dd07823755c2d8b7694ff0891 /src
parent40164962c72f9a5032a07fc03fee4f791eb7d62b (diff)
downloadandroid_packages_apps_Snap-9fe993574ba1c819ff0a2801aca0fac3210cb09d.tar.gz
android_packages_apps_Snap-9fe993574ba1c819ff0a2801aca0fac3210cb09d.tar.bz2
android_packages_apps_Snap-9fe993574ba1c819ff0a2801aca0fac3210cb09d.zip
SnapdragonCamera: Handle CAMERA_ERROR_SERVER_DIED message gracefully.
Handle CAMERA_ERROR_SERVER_DIED message from lower layers by finishing the activity and there by closing camera session and app gracefully. In all other error cases, raise exception and kill app as exists already. Change-Id: I86c4caf174356148bd4725329ea13ec82e944b94
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/CameraErrorCallback.java11
-rw-r--r--src/com/android/camera/PhotoModule.java1
-rw-r--r--src/com/android/camera/VideoModule.java2
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java2
4 files changed, 13 insertions, 3 deletions
diff --git a/src/com/android/camera/CameraErrorCallback.java b/src/com/android/camera/CameraErrorCallback.java
index 7029ac427..71fa9cefd 100644
--- a/src/com/android/camera/CameraErrorCallback.java
+++ b/src/com/android/camera/CameraErrorCallback.java
@@ -21,6 +21,11 @@ import android.util.Log;
public class CameraErrorCallback
implements android.hardware.Camera.ErrorCallback {
private static final String TAG = "CameraErrorCallback";
+ public CameraActivity mActivity = null;
+
+ public void setActivity(CameraActivity activity) {
+ mActivity = activity;
+ }
@Override
public void onError(int error, android.hardware.Camera camera) {
@@ -30,7 +35,11 @@ public class CameraErrorCallback
// We are not sure about the current state of the app (in preview or
// snapshot or recording). Closing the app is better than creating a
// new Camera object.
- throw new RuntimeException("Media server died.");
+ if (mActivity != null) {
+ mActivity.finish();
+ } else {
+ throw new RuntimeException("Media server died.");
+ }
}
}
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 3d6481a29..b23a99783 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -2613,6 +2613,7 @@ public class PhotoModule
Log.w(TAG, "startPreview: parameters for preview are not ready.");
return;
}
+ mErrorCallback.setActivity(mActivity);
mCameraDevice.setErrorCallback(mErrorCallback);
// ICS camera frameworks has a bug. Face detection state is not cleared 1589
// after taking a picture. Stop the preview to work around it. The bug
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 51487ca52..ed2fd3aef 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1073,7 +1073,7 @@ public class VideoModule implements CameraModule,
mStartPrevPending = false;
return;
}
-
+ mErrorCallback.setActivity(mActivity);
mCameraDevice.setErrorCallback(mErrorCallback);
if (mPreviewing == true) {
stopPreview();
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index f7432bfb0..c5adde802 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -1033,7 +1033,7 @@ public class WideAnglePanoramaModule
// UI is not ready.
return;
}
-
+ mErrorCallback.setActivity(mActivity);
mCameraDevice.setErrorCallback(mErrorCallback);
// This works around a driver issue. startPreview may fail if