# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
CUSTOMIZATION_RW_COMPATIBLE_CHECK="updater_custom_rw_compatible_check"

updater_custom_main() {
  debug_msg "Customization for $TARGET_PLATFORM loaded."
}

updater_custom_rw_compatible_check() {
  # Returns $FLAGS_FALSE if not compatible (i.e., need incompatible_mode)
  local mp_fwid="Google_Lumpy.2.111.0"

  if [ "$FLAGS_update_main" = "$FLAGS_TRUE" ]; then
    if cros_version_greater_than "$mp_fwid" "$RO_FWID"; then
      alert "Upgrading from non-MP firmware."
      return $FLAGS_FALSE
    fi

    # Force upgrade for systems from/to H2C firmware.
    if [ "${FWID%%.*}" != "${TARGET_FWID%%.*}" ]; then
      alert "One-shot incompatible firmware change."
      return $FLAGS_FALSE
    fi
  fi

  if [ "$FLAGS_update_ec" = "$FLAGS_TRUE" ]; then
    case "$ECID" in
      00WQA00[1-5]* )
        # All EC magic number has changed since 006.
        # See https://chrome-internal-review.googlesource.com/7476
        alert "Upgrading from incompatible EC."
        return $FLAGS_FALSE
        ;;

      * )
        true
        ;;
    esac
  fi
}
