diff options
author | Angus Kong <shkong@google.com> | 2013-09-16 14:25:35 -0700 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2013-09-17 14:50:53 -0700 |
commit | 4f795b878843e59810ec1dca05b7cdb37b5614c5 (patch) | |
tree | 24f810cea8691c797a69a1595c931de44cc4c5f0 /src/com/android/camera/util | |
parent | 5bee41c6d727c730c7b10fba886862284a489257 (diff) | |
download | android_packages_apps_Snap-4f795b878843e59810ec1dca05b7cdb37b5614c5.tar.gz android_packages_apps_Snap-4f795b878843e59810ec1dca05b7cdb37b5614c5.tar.bz2 android_packages_apps_Snap-4f795b878843e59810ec1dca05b7cdb37b5614c5.zip |
Show dialog when camera device is not connected.
bug:10726516
Change-Id: I3d3433d0b2eced54027b19910473fd55135d0e1c
Diffstat (limited to 'src/com/android/camera/util')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index ca0109ab3..adaaaa776 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -48,6 +48,7 @@ import android.hardware.Camera.Size; import android.location.Location; import android.net.Uri; import android.os.Build; +import android.os.Handler; import android.os.ParcelFileDescriptor; import android.telephony.TelephonyManager; import android.util.DisplayMetrics; @@ -337,21 +338,20 @@ public class CameraUtil { } public static CameraManager.CameraProxy openCamera( - Activity activity, int cameraId) - throws CameraHardwareException, CameraDisabledException { - throwIfCameraDisabled(activity); - + Activity activity, final int cameraId, + Handler handler, final CameraManager.CameraOpenErrorCallback cb) { try { - return CameraHolder.instance().open(cameraId); - } catch (CameraHardwareException e) { - // In eng build, we throw the exception so that test tool - // can detect it and report it - if ("eng".equals(Build.TYPE)) { - throw new RuntimeException("openCamera failed", e); - } else { - throw e; - } + throwIfCameraDisabled(activity); + return CameraHolder.instance().open(handler, cameraId, cb); + } catch (CameraDisabledException ex) { + handler.post(new Runnable() { + @Override + public void run() { + cb.onCameraDisabled(cameraId); + } + }); } + return null; } public static void showErrorAndFinish(final Activity activity, int msgId) { |