Log camera exception via UsageStatistics.

Change-Id: I2b80338dd489ece87d94e20a303c5e43e972c3b0
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index d05248a..f7ca9ee 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -538,8 +538,9 @@
 
     @Override
     public void onCameraDisabled(int cameraId) {
-        UsageStatistics.instance().cameraFailure(eventprotos.CameraFailure.FailureReason.SECURITY,
-                null);
+        UsageStatistics.instance().cameraFailure(
+                eventprotos.CameraFailure.FailureReason.SECURITY, null,
+                UsageStatistics.NONE, UsageStatistics.NONE);
         Log.w(TAG, "Camera disabled: " + cameraId);
         CameraUtil.showErrorAndFinish(this, R.string.camera_disabled);
     }
@@ -547,7 +548,8 @@
     @Override
     public void onDeviceOpenFailure(int cameraId, String info) {
         UsageStatistics.instance().cameraFailure(
-                eventprotos.CameraFailure.FailureReason.OPEN_FAILURE, info);
+                eventprotos.CameraFailure.FailureReason.OPEN_FAILURE, info,
+                UsageStatistics.NONE, UsageStatistics.NONE);
         Log.w(TAG, "Camera open failure: " + info);
         CameraUtil.showErrorAndFinish(this, R.string.cannot_connect_camera);
     }
@@ -561,7 +563,8 @@
     @Override
     public void onReconnectionFailure(CameraAgent mgr, String info) {
         UsageStatistics.instance().cameraFailure(
-                eventprotos.CameraFailure.FailureReason.RECONNECT_FAILURE, null);
+                eventprotos.CameraFailure.FailureReason.RECONNECT_FAILURE, null,
+                UsageStatistics.NONE, UsageStatistics.NONE);
         Log.w(TAG, "Camera reconnection failure:" + info);
         CameraUtil.showErrorAndFinish(this, R.string.cannot_connect_camera);
     }
@@ -1325,13 +1328,20 @@
                     Log.e(TAG, "Camera error callback. error=" + errorCode);
                 }
                 @Override
-                public void onCameraException(RuntimeException ex) {
+                public void onCameraException(
+                        RuntimeException ex, String commandHistory, int action, int state) {
                     Log.e(TAG, "Camera Exception", ex);
+                    UsageStatistics.instance().cameraFailure(
+                            eventprotos.CameraFailure.FailureReason.API_RUNTIME_EXCEPTION,
+                            commandHistory, action, state);
                     onFatalError();
                 }
                 @Override
                 public void onDispatchThreadException(RuntimeException ex) {
                     Log.e(TAG, "DispatchThread Exception", ex);
+                    UsageStatistics.instance().cameraFailure(
+                            eventprotos.CameraFailure.FailureReason.API_TIMEOUT,
+                            null, UsageStatistics.NONE, UsageStatistics.NONE);
                     onFatalError();
                 }
                 private void onFatalError() {
diff --git a/src_pd/com/android/camera/util/UsageStatistics.java b/src_pd/com/android/camera/util/UsageStatistics.java
index d68dec9..6c208de 100644
--- a/src_pd/com/android/camera/util/UsageStatistics.java
+++ b/src_pd/com/android/camera/util/UsageStatistics.java
@@ -26,6 +26,7 @@
 
 public class UsageStatistics {
     public static final long VIEW_TIMEOUT_MILLIS = 0;
+    public static final int NONE = -1;
 
     private static UsageStatistics sInstance;
 
@@ -66,7 +67,7 @@
                                       Boolean volumeButtonShutter) {
     }
 
-    public void cameraFailure(int cause, String info) {
+    public void cameraFailure(int cause, String info, int agentAction, int agentState) {
     }
 
     public void changeScreen(int newScreen, Integer interactionCause) {