Program: 198103
Project: 198103
Buggy source:
static TaskRecord restoreFromXml(XmlPullParser in,ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException {
  Intent intent=null;
  Intent affinityIntent=null;
  ArrayList<ActivityRecord> activities=new ArrayList<ActivityRecord>();
  ComponentName realActivity=null;
  ComponentName origActivity=null;
  String affinity=null;
  boolean rootHasReset=false;
  boolean autoRemoveRecents=false;
  boolean askedCompatMode=false;
  int taskType=ActivityRecord.APPLICATION_ACTIVITY_TYPE;
  int userId=0;
  String lastDescription=null;
  long firstActiveTime=-1;
  long lastActiveTime=-1;
  long lastTimeOnTop=0;
  boolean neverRelinquishIdentity=true;
  int taskId=-1;
  final int outerDepth=in.getDepth();
  ActivityManager.TaskDescription taskDescription=new ActivityManager.TaskDescription();
  int taskAffiliation=-1;
  int taskAffiliationColor=0;
  int prevTaskId=-1;
  int nextTaskId=-1;
  int callingUid=-1;
  String callingPackage="String_Node_Str";
  for (int attrNdx=in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) {
    final String attrName=in.getAttributeName(attrNdx);
    final String attrValue=in.getAttributeValue(attrNdx);
    if (TaskPersister.DEBUG)     Slog.d(TaskPersister.TAG,"String_Node_Str" + attrName + "String_Node_Str"+ attrValue);
    if (ATTR_TASKID.equals(attrName)) {
      taskId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_REALACTIVITY.equals(attrName)) {
      realActivity=ComponentName.unflattenFromString(attrValue);
    }
 else     if (ATTR_ORIGACTIVITY.equals(attrName)) {
      origActivity=ComponentName.unflattenFromString(attrValue);
    }
 else     if (ATTR_AFFINITY.equals(attrName)) {
      affinity=attrValue;
    }
 else     if (ATTR_ROOTHASRESET.equals(attrName)) {
      rootHasReset=Boolean.valueOf(attrValue);
    }
 else     if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
      autoRemoveRecents=Boolean.valueOf(attrValue);
    }
 else     if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
      askedCompatMode=Boolean.valueOf(attrValue);
    }
 else     if (ATTR_USERID.equals(attrName)) {
      userId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_TASKTYPE.equals(attrName)) {
      taskType=Integer.valueOf(attrValue);
    }
 else     if (ATTR_FIRSTACTIVETIME.equals(attrName)) {
      firstActiveTime=Long.valueOf(attrValue);
    }
 else     if (ATTR_LASTACTIVETIME.equals(attrName)) {
      lastActiveTime=Long.valueOf(attrValue);
    }
 else     if (ATTR_LASTDESCRIPTION.equals(attrName)) {
      lastDescription=attrValue;
    }
 else     if (ATTR_LASTTIMEMOVED.equals(attrName)) {
      lastTimeOnTop=Long.valueOf(attrValue);
    }
 else     if (ATTR_NEVERRELINQUISH.equals(attrName)) {
      neverRelinquishIdentity=Boolean.valueOf(attrValue);
    }
 else     if (readTaskDescriptionAttribute(taskDescription,attrName,attrValue)) {
    }
 else     if (ATTR_TASK_AFFILIATION.equals(attrName)) {
      taskAffiliation=Integer.valueOf(attrValue);
    }
 else     if (ATTR_PREV_AFFILIATION.equals(attrName)) {
      prevTaskId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_NEXT_AFFILIATION.equals(attrName)) {
      nextTaskId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_TASK_AFFILIATION_COLOR.equals(attrName)) {
      taskAffiliationColor=Integer.valueOf(attrValue);
    }
 else     if (ATTR_CALLING_UID.equals(attrName)) {
      callingUid=Integer.valueOf(attrValue);
    }
 else     if (ATTR_CALLING_PACKAGE.equals(attrName)) {
      callingPackage=attrValue;
    }
 else {
      Slog.w(TAG,"String_Node_Str" + attrName);
    }
  }
  int event;
  while (((event=in.next()) != XmlPullParser.END_DOCUMENT) && (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
    if (event == XmlPullParser.START_TAG) {
      final String name=in.getName();
      if (TaskPersister.DEBUG)       Slog.d(TaskPersister.TAG,"String_Node_Str" + name);
      if (TAG_AFFINITYINTENT.equals(name)) {
        affinityIntent=Intent.restoreFromXml(in);
      }
 else       if (TAG_INTENT.equals(name)) {
        intent=Intent.restoreFromXml(in);
      }
 else       if (TAG_ACTIVITY.equals(name)) {
        ActivityRecord activity=ActivityRecord.restoreFromXml(in,taskId,stackSupervisor);
        if (TaskPersister.DEBUG)         Slog.d(TaskPersister.TAG,"String_Node_Str" + activity);
        if (activity != null) {
          activities.add(activity);
        }
      }
 else {
        Slog.e(TAG,"String_Node_Str" + name);
        XmlUtils.skipCurrentTag(in);
      }
    }
  }
  if (lastActiveTime >= 0) {
    taskDescription.setIcon(TaskPersister.restoreImage(createLastTaskDescriptionIconFilename(taskId,lastActiveTime)));
  }
  final TaskRecord task=new TaskRecord(stackSupervisor.mService,taskId,intent,affinityIntent,affinity,realActivity,origActivity,rootHasReset,autoRemoveRecents,askedCompatMode,taskType,userId,lastDescription,activities,firstActiveTime,lastActiveTime,lastTimeOnTop,neverRelinquishIdentity,taskDescription,taskAffiliation,prevTaskId,nextTaskId,taskAffiliationColor,callingUid,callingPackage);
  for (int activityNdx=activities.size() - 1; activityNdx >= 0; --activityNdx) {
    activities.get(activityNdx).task=task;
  }
  if (ActivityManagerService.DEBUG_RECENTS)   Slog.d(TAG,"String_Node_Str" + task);
  return task;
}

Fixed version (ground truth):
static TaskRecord restoreFromXml(XmlPullParser in,ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException {
  Intent intent=null;
  Intent affinityIntent=null;
  ArrayList<ActivityRecord> activities=new ArrayList<ActivityRecord>();
  ComponentName realActivity=null;
  ComponentName origActivity=null;
  String affinity=null;
  boolean rootHasReset=false;
  boolean autoRemoveRecents=false;
  boolean askedCompatMode=false;
  int taskType=ActivityRecord.APPLICATION_ACTIVITY_TYPE;
  int userId=0;
  int effectiveUid=-1;
  String lastDescription=null;
  long firstActiveTime=-1;
  long lastActiveTime=-1;
  long lastTimeOnTop=0;
  boolean neverRelinquishIdentity=true;
  int taskId=-1;
  final int outerDepth=in.getDepth();
  ActivityManager.TaskDescription taskDescription=new ActivityManager.TaskDescription();
  int taskAffiliation=-1;
  int taskAffiliationColor=0;
  int prevTaskId=-1;
  int nextTaskId=-1;
  int callingUid=-1;
  String callingPackage="String_Node_Str";
  for (int attrNdx=in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) {
    final String attrName=in.getAttributeName(attrNdx);
    final String attrValue=in.getAttributeValue(attrNdx);
    if (TaskPersister.DEBUG)     Slog.d(TaskPersister.TAG,"String_Node_Str" + attrName + "String_Node_Str"+ attrValue);
    if (ATTR_TASKID.equals(attrName)) {
      taskId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_REALACTIVITY.equals(attrName)) {
      realActivity=ComponentName.unflattenFromString(attrValue);
    }
 else     if (ATTR_ORIGACTIVITY.equals(attrName)) {
      origActivity=ComponentName.unflattenFromString(attrValue);
    }
 else     if (ATTR_AFFINITY.equals(attrName)) {
      affinity=attrValue;
    }
 else     if (ATTR_ROOTHASRESET.equals(attrName)) {
      rootHasReset=Boolean.valueOf(attrValue);
    }
 else     if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
      autoRemoveRecents=Boolean.valueOf(attrValue);
    }
 else     if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
      askedCompatMode=Boolean.valueOf(attrValue);
    }
 else     if (ATTR_USERID.equals(attrName)) {
      userId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_EFFECTIVE_UID.equals(attrName)) {
      effectiveUid=Integer.valueOf(attrValue);
    }
 else     if (ATTR_TASKTYPE.equals(attrName)) {
      taskType=Integer.valueOf(attrValue);
    }
 else     if (ATTR_FIRSTACTIVETIME.equals(attrName)) {
      firstActiveTime=Long.valueOf(attrValue);
    }
 else     if (ATTR_LASTACTIVETIME.equals(attrName)) {
      lastActiveTime=Long.valueOf(attrValue);
    }
 else     if (ATTR_LASTDESCRIPTION.equals(attrName)) {
      lastDescription=attrValue;
    }
 else     if (ATTR_LASTTIMEMOVED.equals(attrName)) {
      lastTimeOnTop=Long.valueOf(attrValue);
    }
 else     if (ATTR_NEVERRELINQUISH.equals(attrName)) {
      neverRelinquishIdentity=Boolean.valueOf(attrValue);
    }
 else     if (readTaskDescriptionAttribute(taskDescription,attrName,attrValue)) {
    }
 else     if (ATTR_TASK_AFFILIATION.equals(attrName)) {
      taskAffiliation=Integer.valueOf(attrValue);
    }
 else     if (ATTR_PREV_AFFILIATION.equals(attrName)) {
      prevTaskId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_NEXT_AFFILIATION.equals(attrName)) {
      nextTaskId=Integer.valueOf(attrValue);
    }
 else     if (ATTR_TASK_AFFILIATION_COLOR.equals(attrName)) {
      taskAffiliationColor=Integer.valueOf(attrValue);
    }
 else     if (ATTR_CALLING_UID.equals(attrName)) {
      callingUid=Integer.valueOf(attrValue);
    }
 else     if (ATTR_CALLING_PACKAGE.equals(attrName)) {
      callingPackage=attrValue;
    }
 else {
      Slog.w(TAG,"String_Node_Str" + attrName);
    }
  }
  int event;
  while (((event=in.next()) != XmlPullParser.END_DOCUMENT) && (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
    if (event == XmlPullParser.START_TAG) {
      final String name=in.getName();
      if (TaskPersister.DEBUG)       Slog.d(TaskPersister.TAG,"String_Node_Str" + name);
      if (TAG_AFFINITYINTENT.equals(name)) {
        affinityIntent=Intent.restoreFromXml(in);
      }
 else       if (TAG_INTENT.equals(name)) {
        intent=Intent.restoreFromXml(in);
      }
 else       if (TAG_ACTIVITY.equals(name)) {
        ActivityRecord activity=ActivityRecord.restoreFromXml(in,taskId,stackSupervisor);
        if (TaskPersister.DEBUG)         Slog.d(TaskPersister.TAG,"String_Node_Str" + activity);
        if (activity != null) {
          activities.add(activity);
        }
      }
 else {
        Slog.e(TAG,"String_Node_Str" + name);
        XmlUtils.skipCurrentTag(in);
      }
    }
  }
  if (lastActiveTime >= 0) {
    taskDescription.setIcon(TaskPersister.restoreImage(createLastTaskDescriptionIconFilename(taskId,lastActiveTime)));
  }
  if (effectiveUid <= 0) {
    Intent checkIntent=intent != null ? intent : affinityIntent;
    effectiveUid=0;
    if (checkIntent != null) {
      IPackageManager pm=AppGlobals.getPackageManager();
      try {
        ApplicationInfo ai=pm.getApplicationInfo(checkIntent.getComponent().getPackageName(),PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS,userId);
        if (ai != null) {
          effectiveUid=ai.uid;
        }
      }
 catch (      RemoteException e) {
      }
    }
    Slog.w(TAG,"String_Node_Str" + taskId + "String_Node_Str"+ checkIntent+ "String_Node_Str"+ effectiveUid);
  }
  final TaskRecord task=new TaskRecord(stackSupervisor.mService,taskId,intent,affinityIntent,affinity,realActivity,origActivity,rootHasReset,autoRemoveRecents,askedCompatMode,taskType,userId,effectiveUid,lastDescription,activities,firstActiveTime,lastActiveTime,lastTimeOnTop,neverRelinquishIdentity,taskDescription,taskAffiliation,prevTaskId,nextTaskId,taskAffiliationColor,callingUid,callingPackage);
  for (int activityNdx=activities.size() - 1; activityNdx >= 0; --activityNdx) {
    activities.get(activityNdx).task=task;
  }
  if (ActivityManagerService.DEBUG_RECENTS)   Slog.d(TAG,"String_Node_Str" + task);
  return task;
}