Program: 181392
Project: 181392
Buggy source:
/** 
 * Writes a new home time zone to the db. Updates the home time zone in the db asynchronously and updates the local cache. Sending a time zone of  {@link CalendarCache#TIMEZONE_TYPE_AUTO} will cause it to be setto the device's time zone. null or empty tz will be ignored.
 * @param context The calling activity
 * @param timeZone The time zone to set Calendar to, or{@link CalendarCache#TIMEZONE_TYPE_AUTO}
 */
public void setTimeZone(Context context,String timeZone){
  if (TextUtils.isEmpty(timeZone)) {
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str");
    }
    return;
  }
  boolean updatePrefs=false;
synchronized (mTZCallbacks) {
    if (CalendarCache.TIMEZONE_TYPE_AUTO.equals(timeZone)) {
      if (mUseHomeTZ) {
        updatePrefs=true;
      }
      mUseHomeTZ=false;
    }
 else {
      if (!mUseHomeTZ || !TextUtils.equals(mHomeTZ,timeZone)) {
        updatePrefs=true;
      }
      mUseHomeTZ=true;
      mHomeTZ=timeZone;
    }
  }
  if (updatePrefs) {
    SharedPreferences prefs=getSharedPreferences(context,mPrefsName);
    setSharedPreference(prefs,KEY_HOME_TZ_ENABLED,mUseHomeTZ);
    setSharedPreference(prefs,KEY_HOME_TZ,mHomeTZ);
    ContentValues values=new ContentValues();
    if (mHandler == null) {
      mHandler=new AsyncTZHandler(context.getContentResolver());
    }
    mHandler.cancelOperation(mToken);
    if (++mToken == 0) {
      mToken=1;
    }
    String[] selArgs=new String[]{CalendarCache.TIMEZONE_KEY_TYPE};
    values.put(CalendarCache.VALUE,mUseHomeTZ ? CalendarCache.TIMEZONE_TYPE_HOME : CalendarCache.TIMEZONE_TYPE_AUTO);
    mHandler.startUpdate(mToken,null,CalendarCache.URI,values,CalendarCache.WHERE,selArgs);
    if (mUseHomeTZ) {
      selArgs[0]=CalendarCache.TIMEZONE_KEY_INSTANCES;
      values.clear();
      values.put(CalendarCache.VALUE,mHomeTZ);
      mHandler.startUpdate(mToken,null,CalendarCache.URI,values,CalendarCache.WHERE,selArgs);
    }
  }
}

Fixed version (ground truth):
/** 
 * Writes a new home time zone to the db. Updates the home time zone in the db asynchronously and updates the local cache. Sending a time zone of  {@link CalendarCache#TIMEZONE_TYPE_AUTO} will cause it to be setto the device's time zone. null or empty tz will be ignored.
 * @param context The calling activity
 * @param timeZone The time zone to set Calendar to, or{@link CalendarCache#TIMEZONE_TYPE_AUTO}
 */
public void setTimeZone(Context context,String timeZone){
  if (TextUtils.isEmpty(timeZone)) {
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str");
    }
    return;
  }
  boolean updatePrefs=false;
synchronized (mTZCallbacks) {
    if (CalendarCache.TIMEZONE_TYPE_AUTO.equals(timeZone)) {
      if (mUseHomeTZ) {
        updatePrefs=true;
      }
      mUseHomeTZ=false;
    }
 else {
      if (!mUseHomeTZ || !TextUtils.equals(mHomeTZ,timeZone)) {
        updatePrefs=true;
      }
      mUseHomeTZ=true;
      mHomeTZ=timeZone;
    }
  }
  if (updatePrefs) {
    SharedPreferences prefs=getSharedPreferences(context,mPrefsName);
    setSharedPreference(prefs,KEY_HOME_TZ_ENABLED,mUseHomeTZ);
    setSharedPreference(prefs,KEY_HOME_TZ,mHomeTZ);
    ContentValues values=new ContentValues();
    if (mHandler == null) {
      mHandler=new AsyncTZHandler(context.getContentResolver());
    }
    mHandler.cancelOperation(mToken);
    if (++mToken == 0) {
      mToken=1;
    }
    values.put(CalendarCache.VALUE,mUseHomeTZ ? CalendarCache.TIMEZONE_TYPE_HOME : CalendarCache.TIMEZONE_TYPE_AUTO);
    mHandler.startUpdate(mToken,null,CalendarCache.URI,values,CalendarCache.WHERE,TIMEZONE_TYPE_ARGS);
    if (mUseHomeTZ) {
      ContentValues values2=new ContentValues();
      values2.put(CalendarCache.VALUE,mHomeTZ);
      mHandler.startUpdate(mToken,null,CalendarCache.URI,values2,CalendarCache.WHERE,TIMEZONE_INSTANCES_ARGS);
    }
  }
}