Merge "FP2-147: could not open camera when flashlight on" into fp2-dev-v2
diff --git a/src/com/android/camera/util/QuickActivity.java b/src/com/android/camera/util/QuickActivity.java
index 039d8fc..dd88a0c 100644
--- a/src/com/android/camera/util/QuickActivity.java
+++ b/src/com/android/camera/util/QuickActivity.java
@@ -90,12 +90,24 @@
         logLifecycle("onNewIntent", false);
     }
 
+    protected void stopFlashLight() {
+        try {
+            Intent intent = new Intent("org.codeaurora.snapcam.action.CLOSE_FLASHLIGHT");
+            intent.putExtra("camera_led", true);
+            sendBroadcast(intent);
+            Thread.sleep(500);
+        } catch (Exception e) {
+            // do nothing
+        }
+    }
+
     @Override
     protected final void onCreate(Bundle bundle) {
         logLifecycle("onCreate", true);
         Log.v(TAG, "Intent Action = " + getIntent().getAction());
         super.onCreate(bundle);
 
+        stopFlashLight();
         mMainHandler = new Handler(getMainLooper());
 
         onCreateTasks(bundle);
@@ -116,6 +128,7 @@
     @Override
     protected final void onResume() {
         logLifecycle("onResume", true);
+        stopFlashLight();
         mMainHandler.removeCallbacks(mOnResumeTasks);
         if (delayOnResumeOnStart() && !mCanceledResumeTasks) {
             mMainHandler.postDelayed(mOnResumeTasks, ON_RESUME_DELAY_MILLIS);