SnapdragonCamera: Added checkbox stats visualizer

1) Added checkbox in stats visualizer
2) Added AWB information for display

Change-Id: Id51d29b798a5d1f849463d28e03b695384fd3aa4
diff --git a/res/layout/capture_module.xml b/res/layout/capture_module.xml
index 1c012c5..afc1995 100755
--- a/res/layout/capture_module.xml
+++ b/res/layout/capture_module.xml
@@ -72,36 +72,87 @@
             android:visibility="gone"
             android:layout_width="100dip"
             android:layout_height="100dip"
-            android:layout_marginTop="70dip"
+            android:layout_marginTop="520dip"
             android:layout_marginLeft="10dip" />
         <com.android.camera.Camera2GraphView
             android:id="@+id/graph_view_gb"
             android:visibility="gone"
             android:layout_width="100dip"
             android:layout_height="100dip"
-            android:layout_marginTop="70dip"
+            android:layout_marginTop="520dip"
             android:layout_marginLeft="120dip" />
         <com.android.camera.Camera2GraphView
             android:id="@+id/graph_view_b"
             android:visibility="gone"
             android:layout_width="100dip"
             android:layout_height="100dip"
-            android:layout_marginTop="70dip"
+            android:layout_marginTop="520dip"
             android:layout_marginLeft="230dip" />
+        <TextView
+            android:id="@+id/bg_stats_graph_label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="68dip"
+            android:layout_marginLeft="16dip"
+            android:textSize="15sp"
+            android:visibility="gone"
+            android:text="@string/stats_visualizer_bg_label"/>
         <com.android.camera.Camera2BGBitMap
             android:id="@+id/bg_stats_graph"
             android:visibility="gone"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginTop="68dip"
+            android:layout_marginTop="88dip"
             android:layout_marginLeft="16dip" />
+        <TextView
+            android:id="@+id/be_stats_graph_label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="68dip"
+            android:layout_marginLeft="260dip"
+            android:textSize="15sp"
+            android:visibility="gone"
+            android:text="@string/stats_visualizer_be_label"/>
         <com.android.camera.Camera2BEBitMap
             android:id="@+id/be_stats_graph"
             android:visibility="gone"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_marginTop="88dip"
+            android:layout_marginLeft="260dip" />
+        <LinearLayout
+            android:id="@+id/stats_awb_info"
             android:layout_marginTop="68dip"
-            android:layout_marginLeft="16dip" />
+            android:layout_marginLeft="150dip"
+            android:orientation="vertical"
+            android:visibility="gone"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content">
+            <TextView
+                android:id="@+id/stats_awb_r_text"
+                android:textSize="15sp"
+                android:padding="10dp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/stats_awb_g_text"
+                android:textSize="15sp"
+                android:padding="10dp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/stats_awb_b_text"
+                android:textSize="15sp"
+                android:padding="10dp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/stats_awb_cc_text"
+                android:textSize="15sp"
+                android:padding="10dp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"/>
+        </LinearLayout>
         <com.android.camera.DrawAutoHDR2
             android:id="@+id/autohdr_view"
             android:layout_width="200dip"
diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml
index 2916736..6d03c50 100755
--- a/res/values/camera2arrays.xml
+++ b/res/values/camera2arrays.xml
@@ -1190,17 +1190,17 @@
     </string-array>
 
     <string-array name="pref_camera2_stats_visualizer_entries" translatable="false">
-        <item>@string/pref_camera2_stats_visualizer_entry_disable</item>
         <item>@string/pref_camera2_stats_visualizer_entry_bg_stats</item>
         <item>@string/pref_camera2_stats_visualizer_entry_be_stats</item>
         <item>@string/pref_camera2_stats_visualizer_entry_hist_stats</item>
+        <item>@string/pref_camera2_stats_visualizer_entry_awb_info</item>
     </string-array>
 
     <string-array name="pref_camera2_stats_visualizer_entryvalues" translatable="false">
-        <item>@string/pref_camera2_stats_visualizer_entry_value_disable</item>
         <item>@string/pref_camera2_stats_visualizer_entry_value_enable_bg</item>
         <item>@string/pref_camera2_stats_visualizer_entry_value_enable_be</item>
         <item>@string/pref_camera2_stats_visualizer_entry_value_enable_hist</item>
+        <item>@string/pref_camera2_stats_visualizer_entry_value_enable_awb</item>
     </string-array>
 
     <string-array name="pref_camera2_capture_mfnr_entries" translatable="false">
diff --git a/res/values/qcomarrays.xml b/res/values/qcomarrays.xml
index 379794e..abe1870 100755
--- a/res/values/qcomarrays.xml
+++ b/res/values/qcomarrays.xml
@@ -889,6 +889,10 @@
         <item>@string/pref_camera_bokeh_mpo_entry_value_disable</item>
     </string-array>
 
+    <string-array name="pref_camera2_stats_visualizer_default" translatable="false">
+        <item></item>
+    </string-array>
+
     <string-array name="pref_camera_bokeh_blur_degree_entries" translatable="true">
         <item>0</item>
         <item>10</item>
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index 7d76032..403fc8b 100755
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -1268,15 +1268,17 @@
     <string name="pref_camera_scenemode_entry_deepportrait" translatable="false">Deepportrait</string>
 
     <string name="pref_camera2_stats_visualizer_title" translatable="true">Stats Visualizer</string>
-    <string name="pref_camera2_stats_visualizer_default" translatable="false">0</string>
-    <string name="pref_camera2_stats_visualizer_entry_disable" translatable="false">Disable All</string>
+    <string name="pref_camera2_stats_visualizer_default" translatable="false"></string>
     <string name="pref_camera2_stats_visualizer_entry_bg_stats" translatable="false">BG Stats</string>
     <string name="pref_camera2_stats_visualizer_entry_be_stats" translatable="false">BE Stats</string>
     <string name="pref_camera2_stats_visualizer_entry_hist_stats" translatable="false">Hist Stats</string>
-    <string name="pref_camera2_stats_visualizer_entry_value_disable" translatable="false">0</string>
-    <string name="pref_camera2_stats_visualizer_entry_value_enable_bg" translatable="false">1</string>
-    <string name="pref_camera2_stats_visualizer_entry_value_enable_be" translatable="false">2</string>
-    <string name="pref_camera2_stats_visualizer_entry_value_enable_hist" translatable="false">3</string>
+    <string name="pref_camera2_stats_visualizer_entry_awb_info" translatable="false">AWB Info</string>
+    <string name="pref_camera2_stats_visualizer_entry_value_enable_bg" translatable="false">0</string>
+    <string name="pref_camera2_stats_visualizer_entry_value_enable_be" translatable="false">1</string>
+    <string name="pref_camera2_stats_visualizer_entry_value_enable_hist" translatable="false">2</string>
+    <string name="pref_camera2_stats_visualizer_entry_value_enable_awb" translatable="false">3</string>
+    <string name="stats_visualizer_bg_label">BG GraphView</string>
+    <string name="stats_visualizer_be_label">BE GraphView</string>
 
     <string name="pref_camera2_capture_mfnr_title" translatable="true">Capture MFNR</string>
     <string name="pref_camera2_capture_mfnr_default" translatable="false">0</string>
diff --git a/res/xml/setting_menu_preferences.xml b/res/xml/setting_menu_preferences.xml
index 9daaf31..c8d433a 100755
--- a/res/xml/setting_menu_preferences.xml
+++ b/res/xml/setting_menu_preferences.xml
@@ -465,14 +465,14 @@
             android:layout="@layout/preference"
             android:summary="%s"/>
 
-        <ListPreference
+        <MultiSelectListPreference
             android:key="pref_camera2_stats_visualizer_key"
-            android:defaultValue="@string/pref_camera2_stats_visualizer_default"
+            android:defaultValue="@array/pref_camera2_stats_visualizer_default"
             android:title="@string/pref_camera2_stats_visualizer_title"
             android:entries="@array/pref_camera2_stats_visualizer_entries"
             android:entryValues="@array/pref_camera2_stats_visualizer_entryvalues"
             android:layout="@layout/preference"
-            android:summary="%s"/>
+            android:summary="Choose stats to display"/>
 
         <ListPreference
             android:key="pref_camera2_capture_mfnr_key"
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 3480c76..1df541f 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -90,6 +90,7 @@
 import android.view.View;
 import android.view.ViewTreeObserver;
 import android.view.WindowManager;
+import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.LinearLayout;
 import android.widget.FrameLayout;
@@ -392,6 +393,8 @@
     private Camera2GraphView mGraphViewR,mGraphViewGB,mGraphViewB;
     private Camera2BGBitMap    bgstats_view;
     private Camera2BEBitMap    bestats_view;
+    private TextView mBgStatsLabel;
+    private TextView mBeStatsLabel;
     private DrawAutoHDR2 mDrawAutoHDR2;
     public boolean mAutoHdrEnable;
     /*HDR Test*/
@@ -545,6 +548,9 @@
     public static int be_g_statsdata[] = new int[BESTATS_DATA];
     public static int be_b_statsdata[] = new int[BESTATS_DATA];
 
+    // AWB Info
+    public static String[] awbinfo_data = new String[4];
+
     private static final int SELFIE_FLASH_DURATION = 680;
     private static final int SESSION_CONFIGURE_TIMEOUT_MS = 3000;
 
@@ -759,7 +765,7 @@
                                        CaptureRequest request,
                                        TotalCaptureResult result) {
             int id = (int) result.getRequest().getTag();
-            int r, g, b, index;
+
 
             if (id == getMainCameraId()) {
                 updateFocusStateChange(result);
@@ -771,101 +777,134 @@
                     updateFaceView(faces, null);
                 }
             }
-            if (SettingsManager.getInstance().isStatsVisualizerSupport() == 3) {
-                int[] histogramStats = result.get(CaptureModule.histogramStats);
-                if (histogramStats != null && mHiston) {
-                    /*The first element in the array stores max hist value . Stats data begin
-                    from second value*/
-                    synchronized (statsdata) {
-                        System.arraycopy(histogramStats, 0, statsdata, 0, STATS_DATA);
-                    }
-                    updateGraghView();
-                }
-            }
-
-            // BG stats display
-            if (SettingsManager.getInstance().isStatsVisualizerSupport() == 1) {
-                int[] bgRStats = null;
-                int[] bgGStats = null;
-                int[] bgBStats = null;
-                try{
-                    bgRStats = result.get(CaptureModule.bgRStats);
-                    bgGStats = result.get(CaptureModule.bgGStats);
-                    bgBStats = result.get(CaptureModule.bgBStats);
-                } catch (IllegalArgumentException e) {
-                    e.printStackTrace();
-                }
-                if (bgRStats != null && bgGStats != null && bgBStats != null && mBGStatson) {
-                    synchronized (bg_r_statsdata) {
-                        System.arraycopy(bgRStats, 0, bg_r_statsdata, 0, BGSTATS_DATA);
-                        System.arraycopy(bgGStats, 0, bg_g_statsdata, 0, BGSTATS_DATA);
-                        System.arraycopy(bgBStats, 0, bg_b_statsdata, 0, BGSTATS_DATA);
-
-                        for (int el = 0; el < 3072; el++)
-                        {
-                            r = bg_r_statsdata[el] >> 6;
-                            g = bg_g_statsdata[el] >> 6;
-                            b = bg_b_statsdata[el] >> 6;
-
-                            for (int hi = 0; hi < 10; hi++)
-                            {
-                                for (int wi = 0; wi < 10; wi++)
-                                {
-                                    index               = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi;
-                                    bg_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b);
-                                }
-                            }
-                        }
-                    }
-                    updateBGStatsView();
-                }
-            }
-
-            // BE stats display
-            if (SettingsManager.getInstance().isStatsVisualizerSupport() == 2) {
-                int[] beRStats = null;
-                int[] beGStats = null;
-                int[] beBStats = null;
-                try{
-                    beRStats = result.get(CaptureModule.beRStats);
-                    beGStats = result.get(CaptureModule.beGStats);
-                    beBStats = result.get(CaptureModule.beBStats);
-                }catch (IllegalArgumentException e) {
-                    e.printStackTrace();
-                }
-
-                if (beRStats != null && beGStats != null && beBStats != null && mBEStatson) {
-                    synchronized (be_r_statsdata) {
-                        System.arraycopy(beRStats, 0, be_r_statsdata, 0, BESTATS_DATA);
-                        System.arraycopy(beGStats, 0, be_g_statsdata, 0, BESTATS_DATA);
-                        System.arraycopy(beBStats, 0, be_b_statsdata, 0, BESTATS_DATA);
-
-                        for (int el = 0; el < 3072; el++)
-                        {
-                            r = be_r_statsdata[el] >> 6;
-                            g = be_g_statsdata[el] >> 6;
-                            b = be_b_statsdata[el] >> 6;
-
-                            for (int hi = 0; hi < 10; hi++)
-                            {
-                                for (int wi = 0; wi < 10; wi++)
-                                {
-                                    index               = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi;
-                                    be_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b);
-                                }
-                            }
-                        }
-                    }
-                    updateBEStatsView();
-                }
-            }
 
             detectHDRMode(result, id);
             processCaptureResult(result);
             mPostProcessor.onMetaAvailable(result);
+            String stats_visualizer = mSettingsManager.getValue(
+                    SettingsManager.KEY_STATS_VISUALIZER_VALUE);
+            if (stats_visualizer != null) {
+                updateStatsView(stats_visualizer,result);
+            }
         }
     };
 
+    private void updateStatsView(String stats_visualizer,CaptureResult result) {
+        int r, g, b, index;
+        if (stats_visualizer.contains("2")) {
+            int[] histogramStats = result.get(CaptureModule.histogramStats);
+            if (histogramStats != null && mHiston) {
+                    /*The first element in the array stores max hist value . Stats data begin
+                    from second value*/
+                synchronized (statsdata) {
+                    System.arraycopy(histogramStats, 0, statsdata, 0, STATS_DATA);
+                }
+                updateGraghView();
+            }
+        }
+
+        // BG stats display
+        if (stats_visualizer.contains("0")) {
+            int[] bgRStats = null;
+            int[] bgGStats = null;
+            int[] bgBStats = null;
+            try{
+                bgRStats = result.get(CaptureModule.bgRStats);
+                bgGStats = result.get(CaptureModule.bgGStats);
+                bgBStats = result.get(CaptureModule.bgBStats);
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            }
+            if (bgRStats != null && bgGStats != null && bgBStats != null && mBGStatson) {
+                synchronized (bg_r_statsdata) {
+                    System.arraycopy(bgRStats, 0, bg_r_statsdata, 0, BGSTATS_DATA);
+                    System.arraycopy(bgGStats, 0, bg_g_statsdata, 0, BGSTATS_DATA);
+                    System.arraycopy(bgBStats, 0, bg_b_statsdata, 0, BGSTATS_DATA);
+
+                    for (int el = 0; el < 3072; el++)
+                    {
+                        r = bg_r_statsdata[el] >> 6;
+                        g = bg_g_statsdata[el] >> 6;
+                        b = bg_b_statsdata[el] >> 6;
+
+                        for (int hi = 0; hi < 10; hi++)
+                        {
+                            for (int wi = 0; wi < 10; wi++)
+                            {
+                                index               = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi;
+                                bg_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b);
+                            }
+                        }
+                    }
+                }
+                updateBGStatsView();
+            }
+        }
+
+        // BE stats display
+        if (stats_visualizer.contains("1")) {
+            int[] beRStats = null;
+            int[] beGStats = null;
+            int[] beBStats = null;
+            try{
+                beRStats = result.get(CaptureModule.beRStats);
+                beGStats = result.get(CaptureModule.beGStats);
+                beBStats = result.get(CaptureModule.beBStats);
+            }catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            }
+
+            if (beRStats != null && beGStats != null && beBStats != null && mBEStatson) {
+                synchronized (be_r_statsdata) {
+                    System.arraycopy(beRStats, 0, be_r_statsdata, 0, BESTATS_DATA);
+                    System.arraycopy(beGStats, 0, be_g_statsdata, 0, BESTATS_DATA);
+                    System.arraycopy(beBStats, 0, be_b_statsdata, 0, BESTATS_DATA);
+
+                    for (int el = 0; el < 3072; el++)
+                    {
+                        r = be_r_statsdata[el] >> 6;
+                        g = be_g_statsdata[el] >> 6;
+                        b = be_b_statsdata[el] >> 6;
+
+                        for (int hi = 0; hi < 10; hi++)
+                        {
+                            for (int wi = 0; wi < 10; wi++)
+                            {
+                                index               = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi;
+                                be_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b);
+                            }
+                        }
+                    }
+                }
+                updateBEStatsView();
+            }
+        }
+
+        // AWB Info display
+        if (stats_visualizer.contains("3")) {
+            try{
+                awbinfo_data[0] = Float.toString(mRGain);
+                awbinfo_data[1] = Float.toString(mGGain);
+                awbinfo_data[2] = Float.toString(mBGain);
+                awbinfo_data[3] = Float.toString(mCctAWB);
+                synchronized (awbinfo_data) {
+                    mActivity.runOnUiThread(new Runnable() {
+                        @Override
+                        public void run() {
+                            mUI.updateAWBInfoVisibility(View.VISIBLE);
+                            mUI.updateAwbInfoText(awbinfo_data);
+                        }
+                    });
+                }
+            } catch (IllegalArgumentException | NullPointerException e) {
+                e.printStackTrace();
+            }
+        } else {
+            mUI.updateAWBInfoVisibility(View.GONE);
+        }
+    }
+
+
     private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
 
         @Override
@@ -1230,6 +1269,8 @@
         mGraphViewB = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_b);
         bgstats_view = (Camera2BGBitMap) mRootView.findViewById(R.id.bg_stats_graph);
         bestats_view = (Camera2BEBitMap) mRootView.findViewById(R.id.be_stats_graph);
+        mBgStatsLabel = (TextView) mRootView.findViewById(R.id.bg_stats_graph_label);
+        mBeStatsLabel = (TextView) mRootView.findViewById(R.id.be_stats_graph_label);
         mDrawAutoHDR2 = (DrawAutoHDR2 )mRootView.findViewById(R.id.autohdr_view);
         mGraphViewR.setDataSection(0,256);
         mGraphViewGB.setDataSection(256,512);
@@ -5374,7 +5415,7 @@
     private void applyHistogram(CaptureRequest.Builder request) {
         String value = mSettingsManager.getValue(SettingsManager.KEY_STATS_VISUALIZER_VALUE);
         if (value != null ) {
-            if (value.equals("3")) {
+            if (value.contains("2")) {
                 final byte enable = 1;
                 request.set(CaptureModule.histMode, enable);
                 mHiston = true;
@@ -5390,7 +5431,7 @@
     private void applyBGStats(CaptureRequest.Builder request) {
         String value = mSettingsManager.getValue(SettingsManager.KEY_STATS_VISUALIZER_VALUE);
         if (value != null ) {
-            if (value.equals("1")){
+            if (value.contains("0")){
                 final byte enable = 1;
                 try{
                     request.set(CaptureModule.bgStatsMode, enable);
@@ -5412,7 +5453,7 @@
     private void applyBEStats(CaptureRequest.Builder request) {
         String value = mSettingsManager.getValue(SettingsManager.KEY_STATS_VISUALIZER_VALUE);
         if (value != null ) {
-            if (value.equals("2")){
+            if (value.contains("1")){
                 final byte enable = 1;
                 try{
                     request.set(CaptureModule.beStatsMode, enable);
@@ -5501,6 +5542,7 @@
             public void run() {
                 if(bgstats_view != null) {
                     bgstats_view.setVisibility(visibility);
+                    mBgStatsLabel.setVisibility(visibility);
                 }
             }
         });
@@ -5522,6 +5564,7 @@
             public void run() {
                 if(bestats_view != null) {
                     bestats_view.setVisibility(visibility);
+                    mBeStatsLabel.setVisibility(visibility);
                 }
             }
         });
@@ -6925,11 +6968,11 @@
     private Paint   mPaint = new Paint();
     private Paint   mPaintRect = new Paint();
     private Canvas  mCanvas = new Canvas();
-    private float   mScale = (float)3;
+    private Paint   mTextPaint = new Paint();
     private int   mWidth;
     private int   mHeight;
     private CaptureModule mCaptureModule;
-    private static final String TAG = "BGGraphView";
+    private static final String TAG = "BG GraphView";
 
 
     public Camera2BGBitMap(Context context, AttributeSet attrs) {
@@ -6986,7 +7029,7 @@
     private int  mWidth;
     private int  mHeight;
     private CaptureModule mCaptureModule;
-    private static final String TAG = "BGGraphView";
+    private static final String TAG = "BE GraphView";
 
 
     public Camera2BEBitMap(Context context, AttributeSet attrs) {
@@ -7019,7 +7062,6 @@
         if (mBitmap != null) {
             final Canvas cavas = mCanvas;
             cavas.drawColor(0xFFAAAAAA);
-
             synchronized(CaptureModule.be_statsdata){
             mBitmap.setPixels(CaptureModule.be_statsdata, 0, 48*10, 0, 0, 48*10, 64*10);
             }
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index 39b2d34..57ef697 100755
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -108,6 +108,7 @@
     private static final int ANIMATION_DURATION = 300;
     private static final int CLICK_THRESHOLD = 200;
     private static final int AUTOMATIC_MODE = 0;
+    private static final String[] AWB_INFO_TITLE = {" R gain "," G gain "," B gain "," CCT "};
     private CameraActivity mActivity;
     private View mRootView;
     private View mPreviewCover;
@@ -232,6 +233,12 @@
     private int mDownSampleFactor = 4;
     private DecodeImageForReview mDecodeTaskForReview = null;
 
+    private View mStatsAwbInfo;
+    private TextView mStatsAwbRText;
+    private TextView mStatsAwbGText;
+    private TextView mStatsAwbBText;
+    private TextView mStatsAwbCcText;
+
     int mPreviewWidth;
     int mPreviewHeight;
     private boolean mIsVideoUI = false;
@@ -416,6 +423,12 @@
         mPauseButton = (PauseButton) mRootView.findViewById(R.id.video_pause);
         mPauseButton.setOnPauseButtonListener(this);
 
+        mStatsAwbInfo = mRootView.findViewById(R.id.stats_awb_info);
+        mStatsAwbRText = mRootView.findViewById(R.id.stats_awb_r_text);
+        mStatsAwbGText = mRootView.findViewById(R.id.stats_awb_g_text);
+        mStatsAwbBText = mRootView.findViewById(R.id.stats_awb_b_text);
+        mStatsAwbCcText = mRootView.findViewById(R.id.stats_awb_cc_text);
+
         mMuteButton = (RotateImageView)mRootView.findViewById(R.id.mute_button);
         mMuteButton.setVisibility(View.VISIBLE);
         setMuteButtonResource(!mModule.isAudioMute());
@@ -583,6 +596,25 @@
         }
     }
 
+    public void updateAwbInfoText(String[] info) {
+        if (info == null || info.length <4)
+            return;
+        mStatsAwbRText.setText(AWB_INFO_TITLE[0]+info[0]);
+        mStatsAwbGText.setText(AWB_INFO_TITLE[1]+info[1]);
+        mStatsAwbBText.setText(AWB_INFO_TITLE[2]+info[2]);
+        mStatsAwbCcText.setText(AWB_INFO_TITLE[3]+info[3]);
+    }
+
+    public void updateAWBInfoVisibility(int visibility) {
+        mActivity.runOnUiThread(new Runnable() {
+            public void run() {
+                if(mStatsAwbInfo != null) {
+                    mStatsAwbInfo.setVisibility(visibility);
+                }
+            }
+        });
+    }
+
     private int getCurrentIntentMode() {
         return mModule.getCurrentIntentMode();
     }
diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java
old mode 100644
new mode 100755
index ae37356..033ae4b
--- a/src/com/android/camera/ListPreference.java
+++ b/src/com/android/camera/ListPreference.java
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import android.content.Context;
 import android.content.SharedPreferences;
@@ -160,6 +161,15 @@
         persistStringValue(value);
     }
 
+    public void setFromMultiValues(Set<String> set) {
+        String value = "";
+        for (String str : set) {
+            value = value + str +";";
+        }
+        mValue = value;
+        persistStringValue(value);
+    }
+
     public void setValueIndex(int index) {
         setValue(mEntryValues[index].toString());
     }
diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java
index 330733d..2264989 100755
--- a/src/com/android/camera/SettingsActivity.java
+++ b/src/com/android/camera/SettingsActivity.java
@@ -38,6 +38,7 @@
 import android.graphics.ImageFormat;
 import android.os.Bundle;
 import android.preference.ListPreference;
+import android.preference.MultiSelectListPreference;
 import android.preference.Preference;
 import android.preference.PreferenceCategory;
 import android.preference.PreferenceGroup;
@@ -59,6 +60,7 @@
 import com.android.camera.util.CameraUtil;
 import com.android.camera.ui.RotateTextToast;
 
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -88,6 +90,9 @@
             } else if (p instanceof ListPreference){
                 value = ((ListPreference) p).getValue();
                 mSettingsManager.setValue(key, value);
+            } else if (p instanceof MultiSelectListPreference) {
+                Set<String> valueSet = ((MultiSelectListPreference)p).getValues();
+                mSettingsManager.setValue(key,valueSet);
             }
             if (key.equals(SettingsManager.KEY_VIDEO_QUALITY)) {
                 updatePreference(SettingsManager.KEY_VIDEO_HIGH_FRAME_RATE);
@@ -648,9 +653,9 @@
         updatePreference(SettingsManager.KEY_VIDEO_ENCODER);
         updatePreference(SettingsManager.KEY_ZOOM);
         updatePreference(SettingsManager.KEY_SWITCH_CAMERA);
+        updateMultiPreference(SettingsManager.KEY_STATS_VISUALIZER_VALUE);
         updatePictureSizePreferenceButton();
         updateVideoHDRPreference();
-        updateStatsVisualizerPreference();
 
         Map<String, SettingsManager.Values> map = mSettingsManager.getValuesMap();
         Set<Map.Entry<String, SettingsManager.Values>> set = map.entrySet();
@@ -704,14 +709,6 @@
         }
     }
 
-    private void updateStatsVisualizerPreference() {
-        ListPreference pref = (ListPreference)findPreference(SettingsManager.KEY_STATS_VISUALIZER_VALUE);
-        if (pref == null) {
-            return;
-        }
-        pref.setEnabled(true);
-    }
-
     private void updateVideoHDRPreference() {
         ListPreference pref = (ListPreference)findPreference(SettingsManager.KEY_VIDEO_HDR_VALUE);
         if (pref == null) {
@@ -760,6 +757,25 @@
         }
     }
 
+    private void updateMultiPreference(String key) {
+        MultiSelectListPreference pref = (MultiSelectListPreference) findPreference(key);
+        if (pref != null) {
+            if (mSettingsManager.getEntries(key) != null) {
+                pref.setEntries(mSettingsManager.getEntries(key));
+                pref.setEntryValues(mSettingsManager.getEntryValues(key));
+                String values = mSettingsManager.getValue(key);
+                if (values != null) {
+                    Set<String> valueSet = new HashSet<String>();
+                    String[] splitValues = values.split(";");
+                    for (String str : splitValues) {
+                        valueSet.add(str);
+                    }
+                    pref.setValues(valueSet);
+                }
+            }
+        }
+    }
+
     private boolean isOn(String value) {
         return value.equals("on") || value.equals("enable");
     }
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index f71c79c..0c0dac7 100755
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -643,6 +643,17 @@
         }
     }
 
+    public boolean setValue(String key, Set<String> set) {
+        ListPreference pref = mPreferenceGroup.findPreference(key);
+        if (pref != null) {
+            pref.setFromMultiValues(set);
+            updateMapAndNotify(pref);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     public void setValueIndex(String key, int index) {
         ListPreference pref = mPreferenceGroup.findPreference(key);
         if (pref != null) {
@@ -813,13 +824,6 @@
             }
         }
 
-        if (stats_visualizer != null) {
-            if (filterUnsupportedOptions(stats_visualizer,
-                    getSupportedStatsVisualizerAvailableModes(cameraId))) {
-                mFilteredKeys.add(stats_visualizer.getKey());
-            }
-        }
-
         if (hdr != null){
             if (filterUnsupportedOptions(hdr,
                     getSupportedHdrAvailableModes(cameraId))) {
@@ -1726,21 +1730,6 @@
         return  modes;
     }
 
-    public List<String> getSupportedStatsVisualizerAvailableModes(int cameraId) {
-        int[] statsVisualizerAvailableModes = {0, 1, 2, 3};
-        /*
-        0 - disable stats
-        1 - enable BG stats
-        2 - enable BE stats
-        3 - enable Hist stats
-        */
-        List<String> modes = new ArrayList<>();
-        for (int i : statsVisualizerAvailableModes) {
-            modes.add(""+i);
-        }
-        return  modes;
-    }
-
     public List<String> getSupportedHdrAvailableModes(int cameraId) {
         String[] data = {"enable","disable"};
         List<String> modes = new ArrayList<>();
@@ -1759,17 +1748,6 @@
         return profile;
     }
 
-    public int isStatsVisualizerSupport(){
-        String value = getValue(KEY_STATS_VISUALIZER_VALUE);
-        int num_val;
-        if (value == null) {
-            num_val = -1;
-            return num_val;
-        }
-        num_val = Integer.parseInt(value);
-        return num_val;
-    }
-
 
 
     public boolean isCamera2HDRSupport(){