nus-yam/ex-repair huggingface dataset:
Program: 2735
Project: 2735
Buggy source:
@Override protected boolean fitSystemWindows(Rect insets){
  pullChildren();
  final int vis=getWindowSystemUiVisibility();
  final boolean stable=(vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
  boolean changed=applyInsets(mActionBarTop,insets,true,true,false,true);
  if (mActionBarBottom != null) {
    changed|=applyInsets(mActionBarBottom,insets,true,false,true,true);
  }
  int topSpace=0;
  if (stable || mActionBarTop.getVisibility() == VISIBLE) {
    topSpace=mActionBarHeight;
  }
  if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) {
    View tabs=mContainerView.getTabContainer();
    if (tabs != null && (stable || tabs.getVisibility() == VISIBLE)) {
      topSpace+=mActionBarHeight;
    }
  }
  int bottomSpace=0;
  if (mActionView.isSplitActionBar()) {
    if ((mActionBarBottom != null && (stable || mActionBarBottom.getVisibility() == VISIBLE))) {
      bottomSpace=mActionBarHeight;
    }
  }
  boolean res=computeFitSystemWindows(insets,mLocalInsets);
  if (!mOverlayMode && !stable) {
    mLocalInsets.top+=topSpace;
    mLocalInsets.bottom+=bottomSpace;
  }
 else {
    insets.top+=topSpace;
    insets.bottom+=bottomSpace;
  }
  changed|=applyInsets(mContent,mLocalInsets,true,true,true,true);
  if (changed) {
    requestLayout();
  }
  super.fitSystemWindows(insets);
  return true;
}

Fixed version (ground truth):
@Override protected boolean fitSystemWindows(Rect insets){
  pullChildren();
  final int vis=getWindowSystemUiVisibility();
  final boolean stable=(vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
  boolean changed=applyInsets(mActionBarTop,insets,true,true,false,true);
  changed|=applyInsets(mActionBarBottom,insets,true,false,true,true);
  mBaseInnerInsets.set(insets);
  computeFitSystemWindows(mBaseInnerInsets,mBaseContentInsets);
  if (!mLastBaseContentInsets.equals(mBaseContentInsets)) {
    changed=true;
    mLastBaseContentInsets.set(mBaseContentInsets);
  }
  if (changed) {
    requestLayout();
  }
  return true;
}
Program: 2736
Project: 2736
Buggy source:
private boolean applyInsets(View view,Rect insets,boolean left,boolean top,boolean bottom,boolean right){
  boolean changed=false;
  FrameLayout.LayoutParams lp=(FrameLayout.LayoutParams)view.getLayoutParams();
  if (left && lp.leftMargin != insets.left) {
    changed=true;
    lp.leftMargin=insets.left;
  }
  if (top && lp.topMargin != insets.top) {
    changed=true;
    lp.topMargin=insets.top;
  }
  if (right && lp.rightMargin != insets.right) {
    changed=true;
    lp.rightMargin=insets.right;
  }
  if (bottom && lp.bottomMargin != insets.bottom) {
    changed=true;
    lp.bottomMargin=insets.bottom;
  }
  return changed;
}

Fixed version (ground truth):
private boolean applyInsets(View view,Rect insets,boolean left,boolean top,boolean bottom,boolean right){
  boolean changed=false;
  LayoutParams lp=(LayoutParams)view.getLayoutParams();
  if (left && lp.leftMargin != insets.left) {
    changed=true;
    lp.leftMargin=insets.left;
  }
  if (top && lp.topMargin != insets.top) {
    changed=true;
    lp.topMargin=insets.top;
  }
  if (right && lp.rightMargin != insets.right) {
    changed=true;
    lp.rightMargin=insets.right;
  }
  if (bottom && lp.bottomMargin != insets.bottom) {
    changed=true;
    lp.bottomMargin=insets.bottom;
  }
  return changed;
}
Program: 2737
Project: 2737
Buggy source:
@Override protected boolean fitSystemWindows(Rect insets){
  pullChildren();
  final int vis=getWindowSystemUiVisibility();
  final boolean stable=(vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
  boolean changed=applyInsets(mActionBarTop,insets,true,true,false,true);
  if (mActionBarBottom != null) {
    changed|=applyInsets(mActionBarBottom,insets,true,false,true,true);
  }
  int topSpace=0;
  if (stable || mActionBarTop.getVisibility() == VISIBLE) {
    topSpace=mActionBarHeight;
  }
  if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) {
    View tabs=mContainerView.getTabContainer();
    if (tabs != null && (stable || tabs.getVisibility() == VISIBLE)) {
      topSpace+=mActionBarHeight;
    }
  }
  int bottomSpace=0;
  if (mActionView.isSplitActionBar()) {
    if ((mActionBarBottom != null && (stable || mActionBarBottom.getVisibility() == VISIBLE))) {
      bottomSpace=mActionBarHeight;
    }
  }
  boolean res=computeFitSystemWindows(insets,mLocalInsets);
  if (!mOverlayMode && !stable) {
    mLocalInsets.top+=topSpace;
    mLocalInsets.bottom+=bottomSpace;
  }
 else {
    insets.top+=topSpace;
    insets.bottom+=bottomSpace;
  }
  changed|=applyInsets(mContent,mLocalInsets,true,true,true,true);
  if (changed) {
    requestLayout();
  }
  super.fitSystemWindows(insets);
  return true;
}

Fixed version (ground truth):
@Override protected boolean fitSystemWindows(Rect insets){
  pullChildren();
  final int vis=getWindowSystemUiVisibility();
  final boolean stable=(vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
  boolean changed=applyInsets(mActionBarTop,insets,true,true,false,true);
  changed|=applyInsets(mActionBarBottom,insets,true,false,true,true);
  mBaseInnerInsets.set(insets);
  computeFitSystemWindows(mBaseInnerInsets,mBaseContentInsets);
  if (!mLastBaseContentInsets.equals(mBaseContentInsets)) {
    changed=true;
    mLastBaseContentInsets.set(mBaseContentInsets);
  }
  if (changed) {
    requestLayout();
  }
  return true;
}
Program: 2738
Project: 2738
Buggy source:
private boolean applyInsets(View view,Rect insets,boolean left,boolean top,boolean bottom,boolean right){
  boolean changed=false;
  FrameLayout.LayoutParams lp=(FrameLayout.LayoutParams)view.getLayoutParams();
  if (left && lp.leftMargin != insets.left) {
    changed=true;
    lp.leftMargin=insets.left;
  }
  if (top && lp.topMargin != insets.top) {
    changed=true;
    lp.topMargin=insets.top;
  }
  if (right && lp.rightMargin != insets.right) {
    changed=true;
    lp.rightMargin=insets.right;
  }
  if (bottom && lp.bottomMargin != insets.bottom) {
    changed=true;
    lp.bottomMargin=insets.bottom;
  }
  return changed;
}

Fixed version (ground truth):
private boolean applyInsets(View view,Rect insets,boolean left,boolean top,boolean bottom,boolean right){
  boolean changed=false;
  LayoutParams lp=(LayoutParams)view.getLayoutParams();
  if (left && lp.leftMargin != insets.left) {
    changed=true;
    lp.leftMargin=insets.left;
  }
  if (top && lp.topMargin != insets.top) {
    changed=true;
    lp.topMargin=insets.top;
  }
  if (right && lp.rightMargin != insets.right) {
    changed=true;
    lp.rightMargin=insets.right;
  }
  if (bottom && lp.bottomMargin != insets.bottom) {
    changed=true;
    lp.bottomMargin=insets.bottom;
  }
  return changed;
}
Program: 2739
Project: 2739
Buggy source:
@Override protected boolean fitSystemWindows(Rect insets){
  pullChildren();
  final int vis=getWindowSystemUiVisibility();
  final boolean stable=(vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
  boolean changed=applyInsets(mActionBarTop,insets,true,true,false,true);
  if (mActionBarBottom != null) {
    changed|=applyInsets(mActionBarBottom,insets,true,false,true,true);
  }
  int topSpace=0;
  if (stable || mActionBarTop.getVisibility() == VISIBLE) {
    topSpace=mActionBarHeight;
  }
  if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) {
    View tabs=mContainerView.getTabContainer();
    if (tabs != null && (stable || tabs.getVisibility() == VISIBLE)) {
      topSpace+=mActionBarHeight;
    }
  }
  int bottomSpace=0;
  if (mActionView.isSplitActionBar()) {
    if ((mActionBarBottom != null && (stable || mActionBarBottom.getVisibility() == VISIBLE))) {
      bottomSpace=mActionBarHeight;
    }
  }
  boolean res=computeFitSystemWindows(insets,mLocalInsets);
  if (!mOverlayMode && !stable) {
    mLocalInsets.top+=topSpace;
    mLocalInsets.bottom+=bottomSpace;
  }
 else {
    insets.top+=topSpace;
    insets.bottom+=bottomSpace;
  }
  changed|=applyInsets(mContent,mLocalInsets,true,true,true,true);
  if (changed) {
    requestLayout();
  }
  super.fitSystemWindows(insets);
  return true;
}

Fixed version (ground truth):
@Override protected boolean fitSystemWindows(Rect insets){
  pullChildren();
  final int vis=getWindowSystemUiVisibility();
  final boolean stable=(vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
  boolean changed=applyInsets(mActionBarTop,insets,true,true,false,true);
  changed|=applyInsets(mActionBarBottom,insets,true,false,true,true);
  mBaseInnerInsets.set(insets);
  computeFitSystemWindows(mBaseInnerInsets,mBaseContentInsets);
  if (!mLastBaseContentInsets.equals(mBaseContentInsets)) {
    changed=true;
    mLastBaseContentInsets.set(mBaseContentInsets);
  }
  if (changed) {
    requestLayout();
  }
  return true;
}
Program: 2740
Project: 2740
Buggy source:
private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,ActivityRecord newActivity){
  boolean forceReset=(newActivity.info.flags & ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0;
  if (ACTIVITY_INACTIVE_RESET_TIME > 0 && taskTop.task.getInactiveDuration() > ACTIVITY_INACTIVE_RESET_TIME) {
    if ((newActivity.info.flags & ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE) == 0) {
      forceReset=true;
    }
  }
  final TaskRecord task=taskTop.task;
  boolean taskFound=false;
  ActivityOptions topOptions=null;
  for (int i=mTaskHistory.size() - 1; i >= 0; --i) {
    final TaskRecord targetTask=mTaskHistory.get(i);
    if (targetTask == task) {
      topOptions=resetTargetTaskIfNeededLocked(task,forceReset);
      taskFound=true;
    }
 else {
      resetAffinityTaskIfNeededLocked(targetTask,task,taskFound,forceReset,taskTop);
    }
  }
  int taskNdx=mTaskHistory.indexOf(task);
  do {
    taskTop=mTaskHistory.get(taskNdx--).getTopActivity();
  }
 while (taskTop == null && taskNdx >= 0);
  if (topOptions != null) {
    if (taskTop != null) {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions);
      taskTop.updateOptionsLocked(topOptions);
    }
 else {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions + "String_Node_Str");
      topOptions.abort();
    }
  }
  return taskTop;
}

Fixed version (ground truth):
private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,ActivityRecord newActivity){
  boolean forceReset=(newActivity.info.flags & ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0;
  if (ACTIVITY_INACTIVE_RESET_TIME > 0 && taskTop.task.getInactiveDuration() > ACTIVITY_INACTIVE_RESET_TIME) {
    if ((newActivity.info.flags & ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE) == 0) {
      forceReset=true;
    }
  }
  final TaskRecord task=taskTop.task;
  boolean taskFound=false;
  ActivityOptions topOptions=null;
  int reparentInsertionPoint=-1;
  for (int i=mTaskHistory.size() - 1; i >= 0; --i) {
    final TaskRecord targetTask=mTaskHistory.get(i);
    if (targetTask == task) {
      topOptions=resetTargetTaskIfNeededLocked(task,forceReset);
      taskFound=true;
    }
 else {
      reparentInsertionPoint=resetAffinityTaskIfNeededLocked(targetTask,task,taskFound,forceReset,reparentInsertionPoint);
    }
  }
  int taskNdx=mTaskHistory.indexOf(task);
  do {
    taskTop=mTaskHistory.get(taskNdx--).getTopActivity();
  }
 while (taskTop == null && taskNdx >= 0);
  if (topOptions != null) {
    if (taskTop != null) {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions);
      taskTop.updateOptionsLocked(topOptions);
    }
 else {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions + "String_Node_Str");
      topOptions.abort();
    }
  }
  return taskTop;
}
Program: 2742
Project: 2742
Buggy source:
void addActivityAtBottom(ActivityRecord r){
  if (!mActivities.remove(r) && r.fullscreen) {
    numFullscreen++;
  }
  mActivities.add(0,r);
}

Fixed version (ground truth):
void addActivityAtBottom(ActivityRecord r){
  addActivityAtIndex(0,r);
}
Program: 2743
Project: 2743
Buggy source:
private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,ActivityRecord newActivity){
  boolean forceReset=(newActivity.info.flags & ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0;
  if (ACTIVITY_INACTIVE_RESET_TIME > 0 && taskTop.task.getInactiveDuration() > ACTIVITY_INACTIVE_RESET_TIME) {
    if ((newActivity.info.flags & ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE) == 0) {
      forceReset=true;
    }
  }
  final TaskRecord task=taskTop.task;
  boolean taskFound=false;
  ActivityOptions topOptions=null;
  for (int i=mTaskHistory.size() - 1; i >= 0; --i) {
    final TaskRecord targetTask=mTaskHistory.get(i);
    if (targetTask == task) {
      topOptions=resetTargetTaskIfNeededLocked(task,forceReset);
      taskFound=true;
    }
 else {
      resetAffinityTaskIfNeededLocked(targetTask,task,taskFound,forceReset,taskTop);
    }
  }
  int taskNdx=mTaskHistory.indexOf(task);
  do {
    taskTop=mTaskHistory.get(taskNdx--).getTopActivity();
  }
 while (taskTop == null && taskNdx >= 0);
  if (topOptions != null) {
    if (taskTop != null) {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions);
      taskTop.updateOptionsLocked(topOptions);
    }
 else {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions + "String_Node_Str");
      topOptions.abort();
    }
  }
  return taskTop;
}

Fixed version (ground truth):
private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,ActivityRecord newActivity){
  boolean forceReset=(newActivity.info.flags & ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0;
  if (ACTIVITY_INACTIVE_RESET_TIME > 0 && taskTop.task.getInactiveDuration() > ACTIVITY_INACTIVE_RESET_TIME) {
    if ((newActivity.info.flags & ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE) == 0) {
      forceReset=true;
    }
  }
  final TaskRecord task=taskTop.task;
  boolean taskFound=false;
  ActivityOptions topOptions=null;
  int reparentInsertionPoint=-1;
  for (int i=mTaskHistory.size() - 1; i >= 0; --i) {
    final TaskRecord targetTask=mTaskHistory.get(i);
    if (targetTask == task) {
      topOptions=resetTargetTaskIfNeededLocked(task,forceReset);
      taskFound=true;
    }
 else {
      reparentInsertionPoint=resetAffinityTaskIfNeededLocked(targetTask,task,taskFound,forceReset,reparentInsertionPoint);
    }
  }
  int taskNdx=mTaskHistory.indexOf(task);
  do {
    taskTop=mTaskHistory.get(taskNdx--).getTopActivity();
  }
 while (taskTop == null && taskNdx >= 0);
  if (topOptions != null) {
    if (taskTop != null) {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions);
      taskTop.updateOptionsLocked(topOptions);
    }
 else {
      if (VALIDATE_TASK_REPLACE)       Slog.w(TAG,"String_Node_Str" + topOptions + "String_Node_Str");
      topOptions.abort();
    }
  }
  return taskTop;
}
Program: 2745
Project: 2745
Buggy source:
void addActivityAtBottom(ActivityRecord r){
  if (!mActivities.remove(r) && r.fullscreen) {
    numFullscreen++;
  }
  mActivities.add(0,r);
}

Fixed version (ground truth):
void addActivityAtBottom(ActivityRecord r){
  addActivityAtIndex(0,r);
}
Program: 2749
Project: 2749
Buggy source:
/** 
 * Handle a request by the system to show the soft input area.
 */
public void showSoftInput(int flags,ResultReceiver resultReceiver){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  boolean wasVis=isInputViewShown();
  mShowInputFlags=0;
  if (onShowInputRequested(flags,false)) {
    showWindow(true);
  }
  boolean showing=onEvaluateInputViewShown();
  mImm.setImeWindowStatus(mToken,IME_ACTIVE | (showing ? IME_VISIBLE : 0),mBackDisposition);
  if (resultReceiver != null) {
    resultReceiver.send(wasVis != isInputViewShown() ? InputMethodManager.RESULT_SHOWN : (wasVis ? InputMethodManager.RESULT_UNCHANGED_SHOWN : InputMethodManager.RESULT_UNCHANGED_HIDDEN),null);
  }
}

Fixed version (ground truth):
/** 
 * Handle a request by the system to show the soft input area.
 */
public void showSoftInput(int flags,ResultReceiver resultReceiver){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  boolean wasVis=isInputViewShown();
  mShowInputFlags=0;
  if (onShowInputRequested(flags,false)) {
    showWindow(true);
  }
  boolean showing=isInputViewShown();
  mImm.setImeWindowStatus(mToken,IME_ACTIVE | (showing ? IME_VISIBLE : 0),mBackDisposition);
  if (resultReceiver != null) {
    resultReceiver.send(wasVis != isInputViewShown() ? InputMethodManager.RESULT_SHOWN : (wasVis ? InputMethodManager.RESULT_UNCHANGED_SHOWN : InputMethodManager.RESULT_UNCHANGED_HIDDEN),null);
  }
}
Program: 2751
Project: 2751
Buggy source:
/** 
 * copy constructor 
 */
public WifiP2pDevice(WifiP2pDevice source){
  if (source != null) {
    deviceName=source.deviceName;
    deviceAddress=source.deviceAddress;
    primaryDeviceType=source.primaryDeviceType;
    secondaryDeviceType=source.secondaryDeviceType;
    wpsConfigMethodsSupported=source.wpsConfigMethodsSupported;
    deviceCapability=source.deviceCapability;
    groupCapability=source.groupCapability;
    status=source.status;
    wfdInfo=source.wfdInfo;
  }
}

Fixed version (ground truth):
/** 
 * copy constructor 
 */
public WifiP2pDevice(WifiP2pDevice source){
  if (source != null) {
    deviceName=source.deviceName;
    deviceAddress=source.deviceAddress;
    primaryDeviceType=source.primaryDeviceType;
    secondaryDeviceType=source.secondaryDeviceType;
    wpsConfigMethodsSupported=source.wpsConfigMethodsSupported;
    deviceCapability=source.deviceCapability;
    groupCapability=source.groupCapability;
    status=source.status;
    wfdInfo=new WifiP2pWfdInfo(source.wfdInfo);
  }
}
Program: 2752
Project: 2752
Buggy source:
/** 
 * @hide 
 */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices){
  for (  WifiP2pDevice device : devices) {
    if (device.deviceAddress != null) {
      mDevices.put(device.deviceAddress,device);
    }
  }
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices){
  for (  WifiP2pDevice device : devices) {
    if (device.deviceAddress != null) {
      mDevices.put(device.deviceAddress,new WifiP2pDevice(device));
    }
  }
}
Program: 2753
Project: 2753
Buggy source:
private void sendPeersChangedBroadcast(){
  final Intent intent=new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
  intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST,mPeers);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  mContext.sendBroadcastAsUser(intent,UserHandle.ALL);
}

Fixed version (ground truth):
private void sendPeersChangedBroadcast(){
  final Intent intent=new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
  intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST,new WifiP2pDeviceList(mPeers));
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  mContext.sendBroadcastAsUser(intent,UserHandle.ALL);
}
Program: 2754
Project: 2754
Buggy source:
/** 
 * copy constructor 
 */
public WifiP2pDevice(WifiP2pDevice source){
  if (source != null) {
    deviceName=source.deviceName;
    deviceAddress=source.deviceAddress;
    primaryDeviceType=source.primaryDeviceType;
    secondaryDeviceType=source.secondaryDeviceType;
    wpsConfigMethodsSupported=source.wpsConfigMethodsSupported;
    deviceCapability=source.deviceCapability;
    groupCapability=source.groupCapability;
    status=source.status;
    wfdInfo=source.wfdInfo;
  }
}

Fixed version (ground truth):
/** 
 * copy constructor 
 */
public WifiP2pDevice(WifiP2pDevice source){
  if (source != null) {
    deviceName=source.deviceName;
    deviceAddress=source.deviceAddress;
    primaryDeviceType=source.primaryDeviceType;
    secondaryDeviceType=source.secondaryDeviceType;
    wpsConfigMethodsSupported=source.wpsConfigMethodsSupported;
    deviceCapability=source.deviceCapability;
    groupCapability=source.groupCapability;
    status=source.status;
    wfdInfo=new WifiP2pWfdInfo(source.wfdInfo);
  }
}
Program: 2755
Project: 2755
Buggy source:
/** 
 * @hide 
 */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices){
  for (  WifiP2pDevice device : devices) {
    if (device.deviceAddress != null) {
      mDevices.put(device.deviceAddress,device);
    }
  }
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices){
  for (  WifiP2pDevice device : devices) {
    if (device.deviceAddress != null) {
      mDevices.put(device.deviceAddress,new WifiP2pDevice(device));
    }
  }
}
Program: 2756
Project: 2756
Buggy source:
private void sendPeersChangedBroadcast(){
  final Intent intent=new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
  intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST,mPeers);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  mContext.sendBroadcastAsUser(intent,UserHandle.ALL);
}

Fixed version (ground truth):
private void sendPeersChangedBroadcast(){
  final Intent intent=new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
  intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST,new WifiP2pDeviceList(mPeers));
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  mContext.sendBroadcastAsUser(intent,UserHandle.ALL);
}
Program: 2757
Project: 2757
Buggy source:
/** 
 * copy constructor 
 */
public WifiP2pDevice(WifiP2pDevice source){
  if (source != null) {
    deviceName=source.deviceName;
    deviceAddress=source.deviceAddress;
    primaryDeviceType=source.primaryDeviceType;
    secondaryDeviceType=source.secondaryDeviceType;
    wpsConfigMethodsSupported=source.wpsConfigMethodsSupported;
    deviceCapability=source.deviceCapability;
    groupCapability=source.groupCapability;
    status=source.status;
    wfdInfo=source.wfdInfo;
  }
}

Fixed version (ground truth):
/** 
 * copy constructor 
 */
public WifiP2pDevice(WifiP2pDevice source){
  if (source != null) {
    deviceName=source.deviceName;
    deviceAddress=source.deviceAddress;
    primaryDeviceType=source.primaryDeviceType;
    secondaryDeviceType=source.secondaryDeviceType;
    wpsConfigMethodsSupported=source.wpsConfigMethodsSupported;
    deviceCapability=source.deviceCapability;
    groupCapability=source.groupCapability;
    status=source.status;
    wfdInfo=new WifiP2pWfdInfo(source.wfdInfo);
  }
}
Program: 2758
Project: 2758
Buggy source:
/** 
 * @hide 
 */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices){
  for (  WifiP2pDevice device : devices) {
    if (device.deviceAddress != null) {
      mDevices.put(device.deviceAddress,device);
    }
  }
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices){
  for (  WifiP2pDevice device : devices) {
    if (device.deviceAddress != null) {
      mDevices.put(device.deviceAddress,new WifiP2pDevice(device));
    }
  }
}
Program: 2759
Project: 2759
Buggy source:
private void sendPeersChangedBroadcast(){
  final Intent intent=new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
  intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST,mPeers);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  mContext.sendBroadcastAsUser(intent,UserHandle.ALL);
}

Fixed version (ground truth):
private void sendPeersChangedBroadcast(){
  final Intent intent=new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
  intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST,new WifiP2pDeviceList(mPeers));
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  mContext.sendBroadcastAsUser(intent,UserHandle.ALL);
}
Program: 2760
Project: 2760
Buggy source:
public void validateAppTokens(List<TaskGroup> tasks){
synchronized (mWindowMap) {
    int t=tasks.size() - 1;
    if (t < 0) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    TaskGroup task=tasks.get(0);
    int taskId=task.taskId;
    DisplayContent displayContent=mTaskIdToDisplayContents.get(taskId);
    if (displayContent == null) {
      Slog.w(TAG,"String_Node_Str" + taskId);
      return;
    }
    boolean mismatch=false;
    AppTokenIterator iterator=displayContent.getTmpAppIterator(REVERSE_ITERATOR);
    for (; t >= 0 && !mismatch; --t) {
      task=tasks.get(t);
      List<IApplicationToken> tokens=task.tokens;
      int v=task.tokens.size() - 1;
      DisplayContent lastDisplayContent=displayContent;
      displayContent=mTaskIdToDisplayContents.get(taskId);
      if (displayContent != lastDisplayContent) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
      while (v >= 0) {
        AppWindowToken atoken=iterator.next();
        if (atoken.removed) {
          continue;
        }
        if (tokens.get(v) != atoken.token) {
          mismatch=true;
          break;
        }
        v--;
      }
    }
    if (mismatch || iterator.hasNext()) {
      Slog.w(TAG,"String_Node_Str" + tasks);
      Slog.w(TAG,"String_Node_Str" + iterator);
    }
  }
}

Fixed version (ground truth):
public void validateAppTokens(List<TaskGroup> tasks){
synchronized (mWindowMap) {
    int t=tasks.size() - 1;
    if (t < 0) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    TaskGroup task=tasks.get(0);
    int taskId=task.taskId;
    DisplayContent displayContent=mTaskIdToDisplayContents.get(taskId);
    if (displayContent == null) {
      Slog.w(TAG,"String_Node_Str" + taskId);
      return;
    }
    boolean mismatch=false;
    AppTokenIterator iterator=displayContent.getTmpAppIterator(REVERSE_ITERATOR);
    for (; t >= 0 && !mismatch; --t) {
      task=tasks.get(t);
      List<IApplicationToken> tokens=task.tokens;
      int v=task.tokens.size() - 1;
      DisplayContent lastDisplayContent=displayContent;
      displayContent=mTaskIdToDisplayContents.get(taskId);
      if (displayContent != lastDisplayContent) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
      while (v >= 0) {
        if (!iterator.hasNext()) {
          mismatch=true;
          break;
        }
        AppWindowToken atoken=iterator.next();
        if (atoken.removed) {
          continue;
        }
        if (tokens.get(v) != atoken.token) {
          mismatch=true;
          break;
        }
        v--;
      }
    }
    if (mismatch || iterator.hasNext()) {
      Slog.w(TAG,"String_Node_Str" + tasks);
      Slog.w(TAG,"String_Node_Str" + iterator);
    }
  }
}
Program: 2761
Project: 2761
Buggy source:
public void validateAppTokens(List<TaskGroup> tasks){
synchronized (mWindowMap) {
    int t=tasks.size() - 1;
    if (t < 0) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    TaskGroup task=tasks.get(0);
    int taskId=task.taskId;
    DisplayContent displayContent=mTaskIdToDisplayContents.get(taskId);
    if (displayContent == null) {
      Slog.w(TAG,"String_Node_Str" + taskId);
      return;
    }
    boolean mismatch=false;
    AppTokenIterator iterator=displayContent.getTmpAppIterator(REVERSE_ITERATOR);
    for (; t >= 0 && !mismatch; --t) {
      task=tasks.get(t);
      List<IApplicationToken> tokens=task.tokens;
      int v=task.tokens.size() - 1;
      DisplayContent lastDisplayContent=displayContent;
      displayContent=mTaskIdToDisplayContents.get(taskId);
      if (displayContent != lastDisplayContent) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
      while (v >= 0) {
        AppWindowToken atoken=iterator.next();
        if (atoken.removed) {
          continue;
        }
        if (tokens.get(v) != atoken.token) {
          mismatch=true;
          break;
        }
        v--;
      }
    }
    if (mismatch || iterator.hasNext()) {
      Slog.w(TAG,"String_Node_Str" + tasks);
      Slog.w(TAG,"String_Node_Str" + iterator);
    }
  }
}

Fixed version (ground truth):
public void validateAppTokens(List<TaskGroup> tasks){
synchronized (mWindowMap) {
    int t=tasks.size() - 1;
    if (t < 0) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    TaskGroup task=tasks.get(0);
    int taskId=task.taskId;
    DisplayContent displayContent=mTaskIdToDisplayContents.get(taskId);
    if (displayContent == null) {
      Slog.w(TAG,"String_Node_Str" + taskId);
      return;
    }
    boolean mismatch=false;
    AppTokenIterator iterator=displayContent.getTmpAppIterator(REVERSE_ITERATOR);
    for (; t >= 0 && !mismatch; --t) {
      task=tasks.get(t);
      List<IApplicationToken> tokens=task.tokens;
      int v=task.tokens.size() - 1;
      DisplayContent lastDisplayContent=displayContent;
      displayContent=mTaskIdToDisplayContents.get(taskId);
      if (displayContent != lastDisplayContent) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
      while (v >= 0) {
        if (!iterator.hasNext()) {
          mismatch=true;
          break;
        }
        AppWindowToken atoken=iterator.next();
        if (atoken.removed) {
          continue;
        }
        if (tokens.get(v) != atoken.token) {
          mismatch=true;
          break;
        }
        v--;
      }
    }
    if (mismatch || iterator.hasNext()) {
      Slog.w(TAG,"String_Node_Str" + tasks);
      Slog.w(TAG,"String_Node_Str" + iterator);
    }
  }
}
Program: 2762
Project: 2762
Buggy source:
public void validateAppTokens(List<TaskGroup> tasks){
synchronized (mWindowMap) {
    int t=tasks.size() - 1;
    if (t < 0) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    TaskGroup task=tasks.get(0);
    int taskId=task.taskId;
    DisplayContent displayContent=mTaskIdToDisplayContents.get(taskId);
    if (displayContent == null) {
      Slog.w(TAG,"String_Node_Str" + taskId);
      return;
    }
    boolean mismatch=false;
    AppTokenIterator iterator=displayContent.getTmpAppIterator(REVERSE_ITERATOR);
    for (; t >= 0 && !mismatch; --t) {
      task=tasks.get(t);
      List<IApplicationToken> tokens=task.tokens;
      int v=task.tokens.size() - 1;
      DisplayContent lastDisplayContent=displayContent;
      displayContent=mTaskIdToDisplayContents.get(taskId);
      if (displayContent != lastDisplayContent) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
      while (v >= 0) {
        AppWindowToken atoken=iterator.next();
        if (atoken.removed) {
          continue;
        }
        if (tokens.get(v) != atoken.token) {
          mismatch=true;
          break;
        }
        v--;
      }
    }
    if (mismatch || iterator.hasNext()) {
      Slog.w(TAG,"String_Node_Str" + tasks);
      Slog.w(TAG,"String_Node_Str" + iterator);
    }
  }
}

Fixed version (ground truth):
public void validateAppTokens(List<TaskGroup> tasks){
synchronized (mWindowMap) {
    int t=tasks.size() - 1;
    if (t < 0) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    TaskGroup task=tasks.get(0);
    int taskId=task.taskId;
    DisplayContent displayContent=mTaskIdToDisplayContents.get(taskId);
    if (displayContent == null) {
      Slog.w(TAG,"String_Node_Str" + taskId);
      return;
    }
    boolean mismatch=false;
    AppTokenIterator iterator=displayContent.getTmpAppIterator(REVERSE_ITERATOR);
    for (; t >= 0 && !mismatch; --t) {
      task=tasks.get(t);
      List<IApplicationToken> tokens=task.tokens;
      int v=task.tokens.size() - 1;
      DisplayContent lastDisplayContent=displayContent;
      displayContent=mTaskIdToDisplayContents.get(taskId);
      if (displayContent != lastDisplayContent) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
      while (v >= 0) {
        if (!iterator.hasNext()) {
          mismatch=true;
          break;
        }
        AppWindowToken atoken=iterator.next();
        if (atoken.removed) {
          continue;
        }
        if (tokens.get(v) != atoken.token) {
          mismatch=true;
          break;
        }
        v--;
      }
    }
    if (mismatch || iterator.hasNext()) {
      Slog.w(TAG,"String_Node_Str" + tasks);
      Slog.w(TAG,"String_Node_Str" + iterator);
    }
  }
}
Program: 2763
Project: 2763
Buggy source:
/** 
 * Return the uid of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned integer is supplied by the system, so that an application can not spoof its uid.
 * @return The uid of the PendingIntent, or -1 if there isnone associated with it.
 */
public int getCreatorUid(){
  try {
    return ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Return the uid of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned integer is supplied by the system, so that an application can not spoof its uid. <p class="note">Be careful about how you use this.  All this tells you is who created the PendingIntent.  It does <strong>not</strong> tell you who handed the PendingIntent to you: that is, PendingIntent objects are intended to be passed between applications, so the PendingIntent you receive from an application could actually be one it received from another application, meaning the result you get here will identify the original application.  Because of this, you should only use this information to identify who you expect to be interacting with through a   {@link #send} call, not who gave you the PendingIntent.</p>
 * @return The uid of the PendingIntent, or -1 if there isnone associated with it.
 */
public int getCreatorUid(){
  try {
    return ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return -1;
  }
}
Program: 2765
Project: 2765
Buggy source:
/** 
 * Retrieve a PendingIntent that will perform a broadcast, like calling  {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
 * @param context The Context in which this PendingIntent should performthe broadcast.
 * @param requestCode Private request code for the sender (currentlynot used).
 * @param intent The Intent to be broadcast.
 * @param flags May be {@link #FLAG_ONE_SHOT},   {@link #FLAG_NO_CREATE},  {@link #FLAG_CANCEL_CURRENT},   {@link #FLAG_UPDATE_CURRENT}, or any of the flags as supported by  {@link Intent#fillIn Intent.fillIn()} to control which unspecified partsof the intent that can be supplied when the actual send happens.
 * @return Returns an existing or new PendingIntent matching the givenparameters.  May return null only if  {@link #FLAG_NO_CREATE} has beensupplied.
 */
public static PendingIntent getBroadcast(Context context,int requestCode,Intent intent,int flags){
  return getBroadcastAsUser(context,requestCode,intent,flags,new UserHandle(UserHandle.myUserId()));
}

Fixed version (ground truth):
/** 
 * Retrieve a PendingIntent that will perform a broadcast, like calling  {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. <p class="note">For security reasons, the   {@link android.content.Intent}you supply here should almost always be an <em>explicit intent</em>, that is specify an explicit component to be delivered to through  {@link Intent#setClass(android.content.Context,Class)} Intent.setClass</p>
 * @param context The Context in which this PendingIntent should performthe broadcast.
 * @param requestCode Private request code for the sender (currentlynot used).
 * @param intent The Intent to be broadcast.
 * @param flags May be {@link #FLAG_ONE_SHOT},   {@link #FLAG_NO_CREATE},  {@link #FLAG_CANCEL_CURRENT},   {@link #FLAG_UPDATE_CURRENT}, or any of the flags as supported by  {@link Intent#fillIn Intent.fillIn()} to control which unspecified partsof the intent that can be supplied when the actual send happens.
 * @return Returns an existing or new PendingIntent matching the givenparameters.  May return null only if  {@link #FLAG_NO_CREATE} has beensupplied.
 */
public static PendingIntent getBroadcast(Context context,int requestCode,Intent intent,int flags){
  return getBroadcastAsUser(context,requestCode,intent,flags,new UserHandle(UserHandle.myUserId()));
}
Program: 2768
Project: 2768
Buggy source:
/** 
 * Return the package name of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned string is supplied by the system, so that an application can not spoof its package.
 * @return The package name of the PendingIntent, or null if there isnone associated with it.
 */
public String getCreatorPackage(){
  try {
    return ActivityManagerNative.getDefault().getPackageForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the package name of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned string is supplied by the system, so that an application can not spoof its package. <p class="note">Be careful about how you use this.  All this tells you is who created the PendingIntent.  It does <strong>not</strong> tell you who handed the PendingIntent to you: that is, PendingIntent objects are intended to be passed between applications, so the PendingIntent you receive from an application could actually be one it received from another application, meaning the result you get here will identify the original application.  Because of this, you should only use this information to identify who you expect to be interacting with through a   {@link #send} call, not who gave you the PendingIntent.</p>
 * @return The package name of the PendingIntent, or null if there isnone associated with it.
 */
public String getCreatorPackage(){
  try {
    return ActivityManagerNative.getDefault().getPackageForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return null;
  }
}
Program: 2769
Project: 2769
Buggy source:
/** 
 * Return the user handle of the application that created this PendingIntent, that is the user under which you will actually be sending the Intent.  The returned UserHandle is supplied by the system, so that an application can not spoof its user.  See  {@link android.os.Process#myUserHandle() Process.myUserHandle()} formore explanation of user handles.
 * @return The user handle of the PendingIntent, or null if there isnone associated with it.
 */
public UserHandle getCreatorUserHandle(){
  try {
    int uid=ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
    return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
  }
 catch (  RemoteException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the user handle of the application that created this PendingIntent, that is the user under which you will actually be sending the Intent.  The returned UserHandle is supplied by the system, so that an application can not spoof its user.  See  {@link android.os.Process#myUserHandle() Process.myUserHandle()} formore explanation of user handles. <p class="note">Be careful about how you use this.  All this tells you is who created the PendingIntent.  It does <strong>not</strong> tell you who handed the PendingIntent to you: that is, PendingIntent objects are intended to be passed between applications, so the PendingIntent you receive from an application could actually be one it received from another application, meaning the result you get here will identify the original application.  Because of this, you should only use this information to identify who you expect to be interacting with through a  {@link #send} call, not who gave you the PendingIntent.</p>
 * @return The user handle of the PendingIntent, or null if there isnone associated with it.
 */
public UserHandle getCreatorUserHandle(){
  try {
    int uid=ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
    return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
  }
 catch (  RemoteException e) {
    return null;
  }
}
Program: 2773
Project: 2773
Buggy source:
/** 
 * Return the uid of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned integer is supplied by the system, so that an application can not spoof its uid.
 * @return The uid of the PendingIntent, or -1 if there isnone associated with it.
 */
public int getCreatorUid(){
  try {
    return ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Return the uid of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned integer is supplied by the system, so that an application can not spoof its uid. <p class="note">Be careful about how you use this.  All this tells you is who created the PendingIntent.  It does <strong>not</strong> tell you who handed the PendingIntent to you: that is, PendingIntent objects are intended to be passed between applications, so the PendingIntent you receive from an application could actually be one it received from another application, meaning the result you get here will identify the original application.  Because of this, you should only use this information to identify who you expect to be interacting with through a   {@link #send} call, not who gave you the PendingIntent.</p>
 * @return The uid of the PendingIntent, or -1 if there isnone associated with it.
 */
public int getCreatorUid(){
  try {
    return ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return -1;
  }
}
Program: 2775
Project: 2775
Buggy source:
/** 
 * Retrieve a PendingIntent that will perform a broadcast, like calling  {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
 * @param context The Context in which this PendingIntent should performthe broadcast.
 * @param requestCode Private request code for the sender (currentlynot used).
 * @param intent The Intent to be broadcast.
 * @param flags May be {@link #FLAG_ONE_SHOT},   {@link #FLAG_NO_CREATE},  {@link #FLAG_CANCEL_CURRENT},   {@link #FLAG_UPDATE_CURRENT}, or any of the flags as supported by  {@link Intent#fillIn Intent.fillIn()} to control which unspecified partsof the intent that can be supplied when the actual send happens.
 * @return Returns an existing or new PendingIntent matching the givenparameters.  May return null only if  {@link #FLAG_NO_CREATE} has beensupplied.
 */
public static PendingIntent getBroadcast(Context context,int requestCode,Intent intent,int flags){
  return getBroadcastAsUser(context,requestCode,intent,flags,new UserHandle(UserHandle.myUserId()));
}

Fixed version (ground truth):
/** 
 * Retrieve a PendingIntent that will perform a broadcast, like calling  {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. <p class="note">For security reasons, the   {@link android.content.Intent}you supply here should almost always be an <em>explicit intent</em>, that is specify an explicit component to be delivered to through  {@link Intent#setClass(android.content.Context,Class)} Intent.setClass</p>
 * @param context The Context in which this PendingIntent should performthe broadcast.
 * @param requestCode Private request code for the sender (currentlynot used).
 * @param intent The Intent to be broadcast.
 * @param flags May be {@link #FLAG_ONE_SHOT},   {@link #FLAG_NO_CREATE},  {@link #FLAG_CANCEL_CURRENT},   {@link #FLAG_UPDATE_CURRENT}, or any of the flags as supported by  {@link Intent#fillIn Intent.fillIn()} to control which unspecified partsof the intent that can be supplied when the actual send happens.
 * @return Returns an existing or new PendingIntent matching the givenparameters.  May return null only if  {@link #FLAG_NO_CREATE} has beensupplied.
 */
public static PendingIntent getBroadcast(Context context,int requestCode,Intent intent,int flags){
  return getBroadcastAsUser(context,requestCode,intent,flags,new UserHandle(UserHandle.myUserId()));
}
Program: 2778
Project: 2778
Buggy source:
/** 
 * Return the package name of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned string is supplied by the system, so that an application can not spoof its package.
 * @return The package name of the PendingIntent, or null if there isnone associated with it.
 */
public String getCreatorPackage(){
  try {
    return ActivityManagerNative.getDefault().getPackageForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the package name of the application that created this PendingIntent, that is the identity under which you will actually be sending the Intent.  The returned string is supplied by the system, so that an application can not spoof its package. <p class="note">Be careful about how you use this.  All this tells you is who created the PendingIntent.  It does <strong>not</strong> tell you who handed the PendingIntent to you: that is, PendingIntent objects are intended to be passed between applications, so the PendingIntent you receive from an application could actually be one it received from another application, meaning the result you get here will identify the original application.  Because of this, you should only use this information to identify who you expect to be interacting with through a   {@link #send} call, not who gave you the PendingIntent.</p>
 * @return The package name of the PendingIntent, or null if there isnone associated with it.
 */
public String getCreatorPackage(){
  try {
    return ActivityManagerNative.getDefault().getPackageForIntentSender(mTarget);
  }
 catch (  RemoteException e) {
    return null;
  }
}
Program: 2779
Project: 2779
Buggy source:
/** 
 * Return the user handle of the application that created this PendingIntent, that is the user under which you will actually be sending the Intent.  The returned UserHandle is supplied by the system, so that an application can not spoof its user.  See  {@link android.os.Process#myUserHandle() Process.myUserHandle()} formore explanation of user handles.
 * @return The user handle of the PendingIntent, or null if there isnone associated with it.
 */
public UserHandle getCreatorUserHandle(){
  try {
    int uid=ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
    return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
  }
 catch (  RemoteException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the user handle of the application that created this PendingIntent, that is the user under which you will actually be sending the Intent.  The returned UserHandle is supplied by the system, so that an application can not spoof its user.  See  {@link android.os.Process#myUserHandle() Process.myUserHandle()} formore explanation of user handles. <p class="note">Be careful about how you use this.  All this tells you is who created the PendingIntent.  It does <strong>not</strong> tell you who handed the PendingIntent to you: that is, PendingIntent objects are intended to be passed between applications, so the PendingIntent you receive from an application could actually be one it received from another application, meaning the result you get here will identify the original application.  Because of this, you should only use this information to identify who you expect to be interacting with through a  {@link #send} call, not who gave you the PendingIntent.</p>
 * @return The user handle of the PendingIntent, or null if there isnone associated with it.
 */
public UserHandle getCreatorUserHandle(){
  try {
    int uid=ActivityManagerNative.getDefault().getUidForIntentSender(mTarget);
    return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null;
  }
 catch (  RemoteException e) {
    return null;
  }
}