@Override
        public List<String> getNonIndexableKeys(Context context) {
          CmHardwareManager cmHardwareManager =
              (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);

          ArrayList<String> result = new ArrayList<String>();
          if (!cmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) {
            result.add(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE);
          }
          if (!cmHardwareManager.isSupported(FEATURE_COLOR_ENHANCEMENT)) {
            result.add(KEY_LIVE_DISPLAY_COLOR_ENHANCE);
          }
          if (!cmHardwareManager.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) {
            result.add(KEY_LIVE_DISPLAY_LOW_POWER);
          }
          if (!isPostProcessingSupported(context)) {
            result.add(KEY_SCREEN_COLOR_SETTINGS);
          } else {
            result.add(KEY_DISPLAY_COLOR);
          }
          if (!cmHardwareManager.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
            result.add(KEY_DISPLAY_GAMMA);
          }
          return result;
        }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Activity activity = getActivity();
    final ContentResolver resolver = activity.getContentResolver();
    final Resources res = getResources();

    mDefaultDayTemperature =
        res.getInteger(com.android.internal.R.integer.config_dayColorTemperature);
    mDefaultNightTemperature =
        res.getInteger(com.android.internal.R.integer.config_nightColorTemperature);

    mCmHardwareManager = (CmHardwareManager) activity.getSystemService(Context.CMHW_SERVICE);

    addPreferencesFromResource(R.xml.livedisplay);

    PreferenceCategory liveDisplayPrefs =
        (PreferenceCategory) findPreference(KEY_CATEGORY_LIVE_DISPLAY);
    PreferenceCategory calibrationPrefs =
        (PreferenceCategory) findPreference(KEY_CATEGORY_CALIBRATION);

    int displayMode =
        Settings.System.getIntForUser(
            resolver, Settings.System.DISPLAY_TEMPERATURE_MODE, 0, UserHandle.USER_CURRENT);
    mLiveDisplay = (ListPreference) findPreference(KEY_LIVE_DISPLAY);
    mLiveDisplay.setValue(String.valueOf(displayMode));

    mModeEntries = res.getStringArray(com.android.internal.R.array.live_display_entries);
    mModeValues = res.getStringArray(com.android.internal.R.array.live_display_values);
    mModeSummaries = res.getStringArray(com.android.internal.R.array.live_display_summaries);

    // Remove outdoor mode from lists if there is no support
    if (!mCmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) {
      int idx = ArrayUtils.indexOf(mModeValues, String.valueOf(MODE_OUTDOOR));
      String[] entriesTemp = new String[mModeEntries.length - 1];
      String[] valuesTemp = new String[mModeValues.length - 1];
      String[] summariesTemp = new String[mModeSummaries.length - 1];
      int j = 0;
      for (int i = 0; i < mModeEntries.length; i++) {
        if (i == idx) {
          continue;
        }
        entriesTemp[j] = mModeEntries[i];
        valuesTemp[j] = mModeValues[i];
        summariesTemp[j] = mModeSummaries[i];
        j++;
      }
      mModeEntries = entriesTemp;
      mModeValues = valuesTemp;
      mModeSummaries = summariesTemp;
    }

    mLiveDisplay.setEntries(mModeEntries);
    mLiveDisplay.setEntryValues(mModeValues);
    mLiveDisplay.setOnPreferenceChangeListener(this);

    mDisplayTemperature = (DisplayTemperature) findPreference(KEY_LIVE_DISPLAY_TEMPERATURE);

    mLowPower = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_LOW_POWER);
    if (liveDisplayPrefs != null
        && mLowPower != null
        && !mCmHardwareManager.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) {
      liveDisplayPrefs.removePreference(mLowPower);
      mLowPower = null;
    }

    mOutdoorMode = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE);
    if (liveDisplayPrefs != null
        && mOutdoorMode != null
        && !mCmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) {
      liveDisplayPrefs.removePreference(mOutdoorMode);
      mOutdoorMode = null;
    }

    mColorEnhancement = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_COLOR_ENHANCE);
    if (liveDisplayPrefs != null
        && mColorEnhancement != null
        && !mCmHardwareManager.isSupported(FEATURE_COLOR_ENHANCEMENT)) {
      liveDisplayPrefs.removePreference(mColorEnhancement);
      mColorEnhancement = null;
    }

    if (calibrationPrefs != null
        && !mCmHardwareManager.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
      Preference gammaPref = findPreference(KEY_DISPLAY_GAMMA);
      if (gammaPref != null) {
        calibrationPrefs.removePreference(gammaPref);
      }
    }

    mScreenColorSettings = (PreferenceScreen) findPreference(KEY_SCREEN_COLOR_SETTINGS);
    if (calibrationPrefs != null) {
      if (!isPostProcessingSupported(getActivity()) && mScreenColorSettings != null) {
        calibrationPrefs.removePreference(mScreenColorSettings);
      } else if ("user".equals(Build.TYPE)) {
        // Remove simple RGB controls if HSIC controls are available
        Preference displayColor = findPreference(KEY_DISPLAY_COLOR);
        if (displayColor != null) {
          calibrationPrefs.removePreference(displayColor);
        }
      }
    }
  }