Program: 198151
Project: 198151
Buggy source:
/** 
 * Sets the original intent, _without_ updating the calling uid or package. 
 */
private void setIntent(Intent _intent,ActivityInfo info){
  if (intent == null) {
    mNeverRelinquishIdentity=(info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) == 0;
  }
 else   if (mNeverRelinquishIdentity) {
    return;
  }
  affinity=info.taskAffinity;
  stringName=null;
  if (info.targetActivity == null) {
    if (_intent != null) {
      if (_intent.getSelector() != null || _intent.getSourceBounds() != null) {
        _intent=new Intent(_intent);
        _intent.setSelector(null);
        _intent.setSourceBounds(null);
      }
    }
    if (ActivityManagerService.DEBUG_TASKS)     Slog.v(ActivityManagerService.TAG,"String_Node_Str" + this + "String_Node_Str"+ _intent);
    intent=_intent;
    realActivity=_intent != null ? _intent.getComponent() : null;
    origActivity=null;
  }
 else {
    ComponentName targetComponent=new ComponentName(info.packageName,info.targetActivity);
    if (_intent != null) {
      Intent targetIntent=new Intent(_intent);
      targetIntent.setComponent(targetComponent);
      targetIntent.setSelector(null);
      targetIntent.setSourceBounds(null);
      if (ActivityManagerService.DEBUG_TASKS)       Slog.v(ActivityManagerService.TAG,"String_Node_Str" + this + "String_Node_Str"+ targetIntent);
      intent=targetIntent;
      realActivity=targetComponent;
      origActivity=_intent.getComponent();
    }
 else {
      intent=null;
      realActivity=targetComponent;
      origActivity=new ComponentName(info.packageName,info.name);
    }
  }
  if (intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0) {
    rootWasReset=true;
  }
  userId=UserHandle.getUserId(info.applicationInfo.uid);
  creatorUid=info.applicationInfo.uid;
  if ((info.flags & ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS) != 0) {
    autoRemoveRecents=true;
  }
 else   if ((intent.getFlags() & (Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS)) == Intent.FLAG_ACTIVITY_NEW_DOCUMENT) {
    if (info.documentLaunchMode != ActivityInfo.DOCUMENT_LAUNCH_NONE) {
      autoRemoveRecents=false;
    }
 else {
      autoRemoveRecents=true;
    }
  }
 else {
    autoRemoveRecents=false;
  }
}

Fixed version (ground truth):
/** 
 * Sets the original intent, _without_ updating the calling uid or package. 
 */
private void setIntent(Intent _intent,ActivityInfo info){
  if (intent == null) {
    mNeverRelinquishIdentity=(info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) == 0;
  }
 else   if (mNeverRelinquishIdentity) {
    return;
  }
  affinity=info.taskAffinity;
  effectiveUid=info.applicationInfo.uid;
  stringName=null;
  if (info.targetActivity == null) {
    if (_intent != null) {
      if (_intent.getSelector() != null || _intent.getSourceBounds() != null) {
        _intent=new Intent(_intent);
        _intent.setSelector(null);
        _intent.setSourceBounds(null);
      }
    }
    if (ActivityManagerService.DEBUG_TASKS)     Slog.v(ActivityManagerService.TAG,"String_Node_Str" + this + "String_Node_Str"+ _intent);
    intent=_intent;
    realActivity=_intent != null ? _intent.getComponent() : null;
    origActivity=null;
  }
 else {
    ComponentName targetComponent=new ComponentName(info.packageName,info.targetActivity);
    if (_intent != null) {
      Intent targetIntent=new Intent(_intent);
      targetIntent.setComponent(targetComponent);
      targetIntent.setSelector(null);
      targetIntent.setSourceBounds(null);
      if (ActivityManagerService.DEBUG_TASKS)       Slog.v(ActivityManagerService.TAG,"String_Node_Str" + this + "String_Node_Str"+ targetIntent);
      intent=targetIntent;
      realActivity=targetComponent;
      origActivity=_intent.getComponent();
    }
 else {
      intent=null;
      realActivity=targetComponent;
      origActivity=new ComponentName(info.packageName,info.name);
    }
  }
  if (intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0) {
    rootWasReset=true;
  }
  userId=UserHandle.getUserId(info.applicationInfo.uid);
  if ((info.flags & ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS) != 0) {
    autoRemoveRecents=true;
  }
 else   if ((intent.getFlags() & (Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS)) == Intent.FLAG_ACTIVITY_NEW_DOCUMENT) {
    if (info.documentLaunchMode != ActivityInfo.DOCUMENT_LAUNCH_NONE) {
      autoRemoveRecents=false;
    }
 else {
      autoRemoveRecents=true;
    }
  }
 else {
    autoRemoveRecents=false;
  }
}