public void programThresholds(ThermalSensor s) {
   if (s == null) return;
   int zoneState = getZoneState();
   if (zoneState == ThermalManager.THERMAL_STATE_OFF) return;
   int lowerTripPoint = ThermalUtils.getLowerThresholdTemp(zoneState, getZoneTempThreshold());
   int upperTripPoint = ThermalUtils.getUpperThresholdTemp(zoneState, getZoneTempThreshold());
   if (lowerTripPoint != ThermalManager.INVALID_TEMP
       && upperTripPoint != ThermalManager.INVALID_TEMP) {
     if (ThermalUtils.writeSysfs(s.getSensorLowTempPath(), lowerTripPoint) == -1) {
       Log.i(
           TAG,
           "error while programming lower trip point:"
               + lowerTripPoint
               + "for sensor:"
               + s.getSensorName());
     }
     if (ThermalUtils.writeSysfs(s.getSensorHighTempPath(), upperTripPoint) == -1) {
       Log.i(
           TAG,
           "error while programming upper trip point:"
               + upperTripPoint
               + "for sensor:"
               + s.getSensorName());
     }
   }
 }
  /** Method to update Zone Temperature and Zone Thermal State */
  public boolean updateZoneParams() {
    int newZoneState;
    int prevZoneState = mCurrThermalState;

    if (!updateZoneTemp()) {
      return false;
    }

    newZoneState = ThermalUtils.calculateThermalState(mZoneTemp, mZoneTempThresholds);
    if (newZoneState == prevZoneState) {
      return false;
    }

    if (newZoneState == ThermalManager.THERMAL_STATE_OFF) {
      setZoneState(newZoneState);
      return true;
    }

    int threshold = ThermalUtils.getLowerThresholdTemp(prevZoneState, mZoneTempThresholds);
    // For Interrupt based zones, HW (should) takes care of the debounce.
    if (!isUEventSupported()) {
      if (newZoneState < prevZoneState && getZoneTemp() > (threshold - getDBInterval())) {
        Log.i(
            TAG,
            " THERMAL_LOW_EVENT for zone:" + getZoneName() + " rejected due to debounce interval");
        return false;
      }
    }

    setZoneState(newZoneState);
    setEventType(
        newZoneState > prevZoneState
            ? ThermalManager.THERMAL_HIGH_EVENT
            : ThermalManager.THERMAL_LOW_EVENT);
    return true;
  }