Move setting of 'fp2.cam.any.changed' property outside loop

Camera resolution preferences are wiped if a different camera module is
detected compared to previous boot. init.fp.camera_preference_wipe.sh
reads 'fp2.cam.(main|front).changed' properties and removes resolution
settings for the ones that are changed.

A race occurs because the service to remove resolution settings is
started when 'fp2.cam.any.changed' is set to 1 inside the loop that also
sets 'fp2.cam.(main|front).changed' sequentially. The service may have
been started and run before 'fp2.cam.front.changed' is set if both
sensors have changed.

This change moves setting 'fp2.cam.any.changes' outside of the loop to
prevent this race.

FPIIM-2228

Change-Id: Ie37bab92df263c089c821bccf2da61366a7ff30e
diff --git a/camera_detect/init.fp.camera_detect.sh b/camera_detect/init.fp.camera_detect.sh
index a61d01f..91fcd5e 100644
--- a/camera_detect/init.fp.camera_detect.sh
+++ b/camera_detect/init.fp.camera_detect.sh
@@ -61,7 +61,7 @@
            && [[ -n "${old_sensor}" ]] \
            && [[ "${old_sensor}" != "${new_sensor}" ]] ; then
             setprop "${PROP_PATH}.${pos}.${CHANGED_FRAGMENT}" "1"
-            setprop "${PROP_PATH}.${ANY_FRAGMENT}.${CHANGED_FRAGMENT}" "1"
+            changed_any_sensor=1
         fi
 
         # set new persist value with the new sensor name if it's non-empty
@@ -77,9 +77,9 @@
 function _camera_detect_service() {
     _detect_main_sensor
     _detect_front_sensor
-    # set to 0 by default; will be set to 1 if necessary later
-    setprop "${PROP_PATH}.${ANY_FRAGMENT}.${CHANGED_FRAGMENT}" "0"
-    _detect_and_persist_sensor_change
+    local changed_any_sensor="$(_detect_and_persist_sensor_change)"
+    setprop "${PROP_PATH}.${ANY_FRAGMENT}.${CHANGED_FRAGMENT}" \
+        "${changed_any_sensor}"
 }
 
 _camera_detect_service