diff --git a/frameworks/base/services/core/java/com/android/server/rkdisplay/RkDisplayModes.java b/frameworks/base/services/core/java/com/android/server/rkdisplay/RkDisplayModes.java index c707f27b61f..cf5802336c9 100644 --- a/frameworks/base/services/core/java/com/android/server/rkdisplay/RkDisplayModes.java +++ b/frameworks/base/services/core/java/com/android/server/rkdisplay/RkDisplayModes.java @@ -142,19 +142,20 @@ public class RkDisplayModes { } private String readColorFormatFromNode(){ - FileReader fr=null; - BufferedReader br=null; - String line=""; + FileReader fr = null; + BufferedReader br = null; + String line = ""; + String mode = null; try { fr = new FileReader(HDMI_DBG_STATUS); } catch (FileNotFoundException e) { - Log.e(TAG, "Couldn't find or open file "+HDMI_DBG_STATUS, e); - return null; + Log.e(TAG, "Failed to open file: " + e.getMessage()); + return mode; } - br=new BufferedReader(fr); + br = new BufferedReader(fr); try { - while ((line=br.readLine())!=null) { + while ((line = br.readLine()) != null) { if (line.contains("Color Format:")) { StringBuilder builder = new StringBuilder(); int start = line.indexOf("Format:"); @@ -171,17 +172,17 @@ public class RkDisplayModes { builder.append(STR_YCBCR420).append("-").append(depth).append("bit"); else builder.append(format).append("-").append(depth).append("bit"); - Log.e(TAG, "readColorFormatFromNode :" + builder.toString()); - return builder.toString(); + mode = builder.toString(); + Log.e(TAG, "readColorFormatFromNode :" + mode); + break; } } br.close(); fr.close(); - return null; } catch (IOException e) { - Log.e(TAG, "Couldn't read data from /d/dw-hdmi/status", e); - return null; + Log.e(TAG, "Couldn't read data from " + HDMI_DBG_STATUS, e); } + return mode; } private static boolean readModeWhiteList(String pathname) { @@ -744,10 +745,9 @@ public class RkDisplayModes { if (mColorMode != null) mCurColorMode = mColorMode; if (mCurColorMode == null) - mCurColorMode = "RGB-8bit"; - if (mCurColorMode.equals("")) { + mCurColorMode = "RGB-8bit"; + else if (mCurColorMode.equals("")) mCurColorMode = "Auto"; - } Log.d(TAG, "getCurColorMode =========== " + mCurColorMode); return mCurColorMode; } diff --git a/hardware/rockchip/hw_output/hw_output.cpp b/hardware/rockchip/hw_output/hw_output.cpp index 95d3691c190..c3321471a65 100644 --- a/hardware/rockchip/hw_output/hw_output.cpp +++ b/hardware/rockchip/hw_output/hw_output.cpp @@ -987,9 +987,10 @@ static int hw_output_get_cur_color_mode(struct hw_output_device* dev, int dpy, c mBaseParmeter->get_disp_info(mCurConnector->get_type(), mCurConnector->connector_id(), &dispInfo); int slot = findSuitableInfoSlot(&dispInfo, mCurConnector->get_type(), mCurConnector->connector_id()); if (dispInfo.screen_info[slot].depthc == Automatic && - dispInfo.screen_info[slot].format == output_ycbcr_high_subsampling) + dispInfo.screen_info[slot].format == output_ycbcr_high_subsampling) { sprintf(colorMode, "%s", "Auto"); } + } sprintf(curColorMode, "%s", colorMode); ALOGD("nativeGetCurCorlorMode: colorMode=%s", colorMode);