Program: 2848
Project: 2848
Buggy source:
/** 
 * Resolve the text alignment.
 * @return true if resolution has been done, false otherwise.
 * @hide
 */
public boolean resolveTextAlignment(){
  mPrivateFlags2&=~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK);
  if (hasRtlSupport()) {
    final int textAlignment=getRawTextAlignment();
switch (textAlignment) {
case TEXT_ALIGNMENT_INHERIT:
      if (!canResolveTextAlignment()) {
        mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
        return false;
      }
    View parent=(View)mParent;
  if (!parent.isTextAlignmentResolved()) {
    mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
    return false;
  }
final int parentResolvedTextAlignment=parent.getTextAlignment();
switch (parentResolvedTextAlignment) {
case TEXT_ALIGNMENT_GRAVITY:
case TEXT_ALIGNMENT_TEXT_START:
case TEXT_ALIGNMENT_TEXT_END:
case TEXT_ALIGNMENT_CENTER:
case TEXT_ALIGNMENT_VIEW_START:
case TEXT_ALIGNMENT_VIEW_END:
mPrivateFlags2|=(parentResolvedTextAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT);
break;
default :
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
}
break;
case TEXT_ALIGNMENT_GRAVITY:
case TEXT_ALIGNMENT_TEXT_START:
case TEXT_ALIGNMENT_TEXT_END:
case TEXT_ALIGNMENT_CENTER:
case TEXT_ALIGNMENT_VIEW_START:
case TEXT_ALIGNMENT_VIEW_END:
mPrivateFlags2|=(textAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT);
break;
default :
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
}
}
 else {
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
}
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED;
return true;
}

Fixed version (ground truth):
/** 
 * Resolve the text alignment.
 * @return true if resolution has been done, false otherwise.
 * @hide
 */
public boolean resolveTextAlignment(){
  mPrivateFlags2&=~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK);
  if (hasRtlSupport()) {
    final int textAlignment=getRawTextAlignment();
switch (textAlignment) {
case TEXT_ALIGNMENT_INHERIT:
      if (!canResolveTextAlignment()) {
        mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
        return false;
      }
    if (!mParent.isTextAlignmentResolved()) {
      mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
      return false;
    }
  final int parentResolvedTextAlignment=mParent.getTextAlignment();
switch (parentResolvedTextAlignment) {
case TEXT_ALIGNMENT_GRAVITY:
case TEXT_ALIGNMENT_TEXT_START:
case TEXT_ALIGNMENT_TEXT_END:
case TEXT_ALIGNMENT_CENTER:
case TEXT_ALIGNMENT_VIEW_START:
case TEXT_ALIGNMENT_VIEW_END:
  mPrivateFlags2|=(parentResolvedTextAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT);
break;
default :
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
}
break;
case TEXT_ALIGNMENT_GRAVITY:
case TEXT_ALIGNMENT_TEXT_START:
case TEXT_ALIGNMENT_TEXT_END:
case TEXT_ALIGNMENT_CENTER:
case TEXT_ALIGNMENT_VIEW_START:
case TEXT_ALIGNMENT_VIEW_END:
mPrivateFlags2|=(textAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT);
break;
default :
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
}
}
 else {
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT;
}
mPrivateFlags2|=PFLAG2_TEXT_ALIGNMENT_RESOLVED;
return true;
}