nus-yam/ex-repair huggingface dataset:
Program: 43376
Project: 43376
Buggy source:
Resources getTopLevelResources(String appDir){
synchronized (mPackages) {
    WeakReference<Resources> wr=mActiveResources.get(appDir);
    Resources r=wr != null ? wr.get() : null;
    if (r != null && r.getAssets().isUpToDate()) {
      return r;
    }
    AssetManager assets=new AssetManager();
    if (assets.addAssetPath(appDir) == 0) {
      return null;
    }
    Configuration config=getConfiguration();
    if (config != null && config.customTheme != null) {
      String resourcePath=config.customTheme.getThemeResourcePath();
      if (resourcePath != null) {
        if (assets.addAssetPath(resourcePath) == 0) {
          Log.e(TAG,"String_Node_Str" + resourcePath);
        }
      }
      PackageInfo pi=getPackageInfo(config.customTheme.getThemePackageName(),0);
      String resDir=pi.getResDir();
      if (assets.addAssetPath(resDir) == 0) {
        Log.e(TAG,"String_Node_Str" + resDir);
      }
    }
    DisplayMetrics metrics=getDisplayMetricsLocked(false);
    r=new Resources(assets,metrics,config);
    mActiveResources.put(appDir,new WeakReference<Resources>(r));
    return r;
  }
}

Fixed version (ground truth):
Resources getTopLevelResources(String appDir){
synchronized (mPackages) {
    WeakReference<Resources> wr=mActiveResources.get(appDir);
    Resources r=wr != null ? wr.get() : null;
    if (r != null && r.getAssets().isUpToDate()) {
      return r;
    }
    AssetManager assets=new AssetManager();
    if (assets.addAssetPath(appDir) == 0) {
      return null;
    }
    Configuration config=getConfiguration();
    if (config != null && config.customTheme != null) {
      String resourcePath=config.customTheme.getThemeResourcePath();
      if (resourcePath != null) {
        if (assets.addAssetPath(resourcePath) == 0) {
          Log.e(TAG,"String_Node_Str" + resourcePath);
        }
      }
      PackageInfo pi=getPackageInfo(config.customTheme.getThemePackageName(),0);
      if (pi != null) {
        String resDir=pi.getResDir();
        if (assets.addAssetPath(resDir) == 0) {
          Log.e(TAG,"String_Node_Str" + resDir);
        }
      }
    }
    DisplayMetrics metrics=getDisplayMetricsLocked(false);
    r=new Resources(assets,metrics,config);
    mActiveResources.put(appDir,new WeakReference<Resources>(r));
    return r;
  }
}
Program: 43377
Project: 43377
Buggy source:
/** 
 * Shows this context menu, allowing the optional original view (and its ancestors) to add items.
 * @param originalView Optional, the original view that triggered thecontext menu.
 * @param token Optional, the window token that should be set on the contextmenu's window.
 * @return If the context menu was shown, the {@link MenuDialogHelper} fordismissing it. Otherwise, null.
 */
public MenuDialogHelper show(View originalView,IBinder token){
  if (originalView != null) {
    originalView.createContextMenu(this);
  }
  if (getVisibleItems().size() > 0) {
    EventLog.writeEvent(50001,1);
    MenuDialogHelper helper=new MenuDialogHelper(this);
    helper.show(token);
    return helper;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Shows this context menu, allowing the optional original view (and its ancestors) to add items.
 * @param originalView Optional, the original view that triggered thecontext menu.
 * @param token Optional, the window token that should be set on the contextmenu's window.
 * @return If the context menu was shown, the {@link MenuDialogHelper} fordismissing it. Otherwise, null.
 */
public MenuDialogHelper show(View originalView,IBinder token){
  if (originalView != null) {
    originalView.createContextMenu(this);
  }
  if (getVisibleItems().size() > 0) {
    EventLog.writeEvent(50001,1);
    MenuDialogHelper helper=new MenuDialogHelper(this);
    Dialog d=helper.create(token);
    mContext=d.getContext();
    d.show();
    return helper;
  }
  return null;
}
Program: 43378
Project: 43378
Buggy source:
LayoutInflater getInflater(){
  if (mInflater == null) {
    Context wrappedContext=new ContextThemeWrapper(mContext,THEME_RES_FOR_TYPE[mMenuType]);
    mInflater=(LayoutInflater)wrappedContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  return mInflater;
}

Fixed version (ground truth):
LayoutInflater getInflater(){
  if (mInflater == null) {
    Context wrappedContext=new ContextThemeWrapper(getContext(),THEME_RES_FOR_TYPE[mMenuType]);
    mInflater=(LayoutInflater)wrappedContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  return mInflater;
}
Program: 43379
Project: 43379
Buggy source:
/** 
 * Shows menu as a dialog. 
 * @param windowToken Optional token to assign to the window.
 */
public void show(IBinder windowToken){
  final MenuBuilder menu=mMenu;
  mAdapter=menu.getMenuAdapter(MenuBuilder.TYPE_DIALOG);
  final AlertDialog.Builder builder=new AlertDialog.Builder(menu.getContext()).setAdapter(mAdapter,this);
  final View headerView=menu.getHeaderView();
  if (headerView != null) {
    builder.setCustomTitle(headerView);
  }
 else {
    builder.setIcon(menu.getHeaderIcon()).setTitle(menu.getHeaderTitle());
  }
  builder.setOnKeyListener(this);
  builder.setRecycleOnMeasureEnabled(false);
  mDialog=builder.create();
  WindowManager.LayoutParams lp=mDialog.getWindow().getAttributes();
  lp.type=WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
  if (windowToken != null) {
    lp.token=windowToken;
  }
  lp.flags|=WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
  mDialog.show();
}

Fixed version (ground truth):
/** 
 * Shows menu as a dialog. 
 * @param windowToken Optional token to assign to the window.
 */
public void show(IBinder windowToken){
  create(windowToken);
  mDialog.show();
}
Program: 43381
Project: 43381
Buggy source:
/** 
 * @param context Parent.
 * @param theme the theme to apply to this dialog
 * @param callBack How parent is notified.
 * @param hourOfDay The initial hour.
 * @param minute The initial minute.
 * @param is24HourView Whether this is a 24 hour view, or AM/PM.
 */
public TimePickerDialog(Context context,int theme,OnTimeSetListener callBack,int hourOfDay,int minute,boolean is24HourView){
  super(context,theme);
  mCallback=callBack;
  mInitialHourOfDay=hourOfDay;
  mInitialMinute=minute;
  mIs24HourView=is24HourView;
  mDateFormat=DateFormat.getTimeFormat(context);
  mCalendar=Calendar.getInstance();
  updateTitle(mInitialHourOfDay,mInitialMinute);
  setButton(context.getText(R.string.date_time_set),this);
  setButton2(context.getText(R.string.cancel),(OnClickListener)null);
  setIcon(R.drawable.ic_dialog_time);
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.time_picker_dialog,null);
  setView(view);
  mTimePicker=(TimePicker)view.findViewById(R.id.timePicker);
  mTimePicker.setCurrentHour(mInitialHourOfDay);
  mTimePicker.setCurrentMinute(mInitialMinute);
  mTimePicker.setIs24HourView(mIs24HourView);
  mTimePicker.setOnTimeChangedListener(this);
}

Fixed version (ground truth):
/** 
 * @param context Parent.
 * @param theme the theme to apply to this dialog
 * @param callBack How parent is notified.
 * @param hourOfDay The initial hour.
 * @param minute The initial minute.
 * @param is24HourView Whether this is a 24 hour view, or AM/PM.
 */
public TimePickerDialog(Context context,int theme,OnTimeSetListener callBack,int hourOfDay,int minute,boolean is24HourView){
  super(context,theme);
  mCallback=callBack;
  mInitialHourOfDay=hourOfDay;
  mInitialMinute=minute;
  mIs24HourView=is24HourView;
  mDateFormat=DateFormat.getTimeFormat(getContext());
  mCalendar=Calendar.getInstance();
  updateTitle(mInitialHourOfDay,mInitialMinute);
  setButton(context.getText(R.string.date_time_set),this);
  setButton2(context.getText(R.string.cancel),(OnClickListener)null);
  setIcon(R.drawable.ic_dialog_time);
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.time_picker_dialog,null);
  setView(view);
  mTimePicker=(TimePicker)view.findViewById(R.id.timePicker);
  mTimePicker.setCurrentHour(mInitialHourOfDay);
  mTimePicker.setCurrentMinute(mInitialMinute);
  mTimePicker.setIs24HourView(mIs24HourView);
  mTimePicker.setOnTimeChangedListener(this);
}
Program: 43383
Project: 43383
Buggy source:
static void sendCloseSystemWindows(Context context,String reason){
  if (ActivityManagerNative.isSystemReady()) {
    Intent intent=new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    if (reason != null) {
      intent.putExtra(SYSTEM_DIALOG_REASON_KEY,reason);
    }
    context.sendBroadcast(intent);
  }
}

Fixed version (ground truth):
static void sendCloseSystemWindows(Context context,String reason){
  if (ActivityManagerNative.isSystemReady()) {
    try {
      ActivityManagerNative.getDefault().closeSystemDialogs(reason);
    }
 catch (    RemoteException e) {
    }
  }
}
Program: 43384
Project: 43384
Buggy source:
/** 
 * goes to the home screen
 * @return whether it did anything
 */
boolean goHome(){
  if (false) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    mContext.startActivity(mHomeIntent);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
      int result=ActivityManagerNative.getDefault().startActivity(null,mHomeIntent,mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),null,0,null,null,0,true,false);
      if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
        return false;
      }
    }
 catch (    RemoteException ex) {
    }
  }
  sendCloseSystemWindows();
  return true;
}

Fixed version (ground truth):
/** 
 * goes to the home screen
 * @return whether it did anything
 */
boolean goHome(){
  if (false) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    sendCloseSystemWindows();
    mContext.startActivity(mHomeIntent);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
      sendCloseSystemWindows();
      int result=ActivityManagerNative.getDefault().startActivity(null,mHomeIntent,mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),null,0,null,null,0,true,false);
      if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
        return false;
      }
    }
 catch (    RemoteException ex) {
    }
  }
  return true;
}
Program: 43385
Project: 43385
Buggy source:
/** 
 * A home key -> launch home action was detected.  Take the appropriate action given the situation with the keyguard.
 */
void launchHomeFromHotKey(){
  if (mKeyguardMediator.isShowing()) {
  }
 else   if (mKeyguardMediator.isInputRestricted()) {
    mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult(){
      public void onKeyguardExitResult(      boolean success){
        if (success) {
          try {
            ActivityManagerNative.getDefault().stopAppSwitches();
          }
 catch (          RemoteException e) {
          }
          mContext.startActivity(mHomeIntent);
          sendCloseSystemWindows();
        }
      }
    }
);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    mContext.startActivity(mHomeIntent);
    sendCloseSystemWindows();
  }
}

Fixed version (ground truth):
/** 
 * A home key -> launch home action was detected.  Take the appropriate action given the situation with the keyguard.
 */
void launchHomeFromHotKey(){
  if (mKeyguardMediator.isShowing()) {
  }
 else   if (mKeyguardMediator.isInputRestricted()) {
    mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult(){
      public void onKeyguardExitResult(      boolean success){
        if (success) {
          try {
            ActivityManagerNative.getDefault().stopAppSwitches();
          }
 catch (          RemoteException e) {
          }
          sendCloseSystemWindows();
          mContext.startActivity(mHomeIntent);
        }
      }
    }
);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    sendCloseSystemWindows();
    mContext.startActivity(mHomeIntent);
  }
}
Program: 43386
Project: 43386
Buggy source:
public void onKeyguardExitResult(boolean success){
  if (success) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    mContext.startActivity(mHomeIntent);
    sendCloseSystemWindows();
  }
}

Fixed version (ground truth):
public void onKeyguardExitResult(boolean success){
  if (success) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    sendCloseSystemWindows();
    mContext.startActivity(mHomeIntent);
  }
}
Program: 43387
Project: 43387
Buggy source:
/** 
 * Performs   {@link AccessibilityService}s delayed notification. The delay is configurable and denotes the period after the last event before notifying the service.
 * @param event The event.
 * @param isDefault True to notify default listeners, not default services.
 */
private void notifyAccessibilityServicesDelayedLocked(AccessibilityEvent event,boolean isDefault){
  for (int i=0, count=mServices.size(); i < count; i++) {
    Service service=mServices.get(i);
    if (service.mIsDefault == isDefault) {
      if (canDispathEventLocked(service,event,mHandledFeedbackTypes)) {
        mHandledFeedbackTypes|=service.mFeedbackType;
        notifyAccessibilityServiceDelayedLocked(service,event);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Performs   {@link AccessibilityService}s delayed notification. The delay is configurable and denotes the period after the last event before notifying the service.
 * @param event The event.
 * @param isDefault True to notify default listeners, not default services.
 */
private void notifyAccessibilityServicesDelayedLocked(AccessibilityEvent event,boolean isDefault){
  try {
    for (int i=0, count=mServices.size(); i < count; i++) {
      Service service=mServices.get(i);
      if (service.mIsDefault == isDefault) {
        if (canDispathEventLocked(service,event,mHandledFeedbackTypes)) {
          mHandledFeedbackTypes|=service.mFeedbackType;
          notifyAccessibilityServiceDelayedLocked(service,event);
        }
      }
    }
  }
 catch (  IndexOutOfBoundsException oobe) {
    return;
  }
}
Program: 43388
Project: 43388
Buggy source:
@Override protected void onBindView(View view){
  super.onBindView(view);
  SeekBar seekbar=(SeekBar)view.findViewById(com.android.internal.R.id.seekbar_preference);
  if (seekbar != null) {
    seekbar.setProgress(mProgress);
    if (mThumb != null)     seekbar.setThumb(mThumb);
    if (mThumbOffset > 0)     seekbar.setThumbOffset(mThumbOffset);
    if (mMinWidth > 0)     seekbar.setMinimumWidth(mMinWidth);
    if (mMax > 0)     seekbar.setMax(mMax);
    seekbar.setOnSeekBarChangeListener(this);
  }
}

Fixed version (ground truth):
@Override protected void onBindView(View view){
  super.onBindView(view);
  SeekBar seekbar=(SeekBar)view.findViewById(com.android.internal.R.id.seekbar_preference);
  if (seekbar != null) {
    if (mMax > 0)     seekbar.setMax(mMax);
    if (mThumb != null)     seekbar.setThumb(mThumb);
    if (mThumbOffset > 0)     seekbar.setThumbOffset(mThumbOffset);
    if (mMinWidth > 0)     seekbar.setMinimumWidth(mMinWidth);
    if (mProgress > 0)     seekbar.setProgress(mProgress);
    seekbar.setOnSeekBarChangeListener(this);
  }
}
Program: 43389
Project: 43389
Buggy source:
/** 
 * Checks whether the speakerphone is on or off.
 * @return true if speakerphone is on, false if it's off
 */
public boolean isSpeakerphoneOn(){
  if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_SPEAKER) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Checks whether the speakerphone is on or off.
 * @return true if speakerphone is on, false if it's off
 */
public boolean isSpeakerphoneOn(){
  IAudioService service=getService();
  try {
    return service.isSpeakerphoneOn();
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    return false;
  }
}
Program: 43390
Project: 43390
Buggy source:
/** 
 * Request use of Bluetooth SCO headset for communications.
 * @param on set <var>true</var> to use bluetooth SCO for communications;<var>false</var> to not use bluetooth SCO for communications
 */
public void setBluetoothScoOn(boolean on){
  if (on) {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_BT_SCO);
  }
 else {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_NONE);
  }
}

Fixed version (ground truth):
/** 
 * Request use of Bluetooth SCO headset for communications.
 * @param on set <var>true</var> to use bluetooth SCO for communications;<var>false</var> to not use bluetooth SCO for communications
 */
public void setBluetoothScoOn(boolean on){
  IAudioService service=getService();
  try {
    service.setBluetoothScoOn(on);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 43391
Project: 43391
Buggy source:
/** 
 * Sets the speakerphone on or off.
 * @param on set <var>true</var> to turn on speakerphone;<var>false</var> to turn it off
 */
public void setSpeakerphoneOn(boolean on){
  if (on) {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_SPEAKER);
  }
 else {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_NONE);
  }
}

Fixed version (ground truth):
/** 
 * Sets the speakerphone on or off.
 * @param on set <var>true</var> to turn on speakerphone;<var>false</var> to turn it off
 */
public void setSpeakerphoneOn(boolean on){
  IAudioService service=getService();
  try {
    service.setSpeakerphoneOn(on);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 43392
Project: 43392
Buggy source:
/** 
 * Checks whether communications use Bluetooth SCO.
 * @return true if SCO is used for communications;false if otherwise
 */
public boolean isBluetoothScoOn(){
  if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Checks whether communications use Bluetooth SCO.
 * @return true if SCO is used for communications;false if otherwise
 */
public boolean isBluetoothScoOn(){
  IAudioService service=getService();
  try {
    return service.isBluetoothScoOn();
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    return false;
  }
}
Program: 43393
Project: 43393
Buggy source:
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMediaServerOk=true;
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.SINK_STATE_CHANGED_ACTION);
  intentFilter.addAction(BluetoothIntent.HEADSET_AUDIO_STATE_CHANGED_ACTION);
  context.registerReceiver(mReceiver,intentFilter);
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mMode=AudioSystem.MODE_NORMAL;
  mHeadsetState=0;
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMediaServerOk=true;
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.SINK_STATE_CHANGED_ACTION);
  intentFilter.addAction(BluetoothIntent.HEADSET_AUDIO_STATE_CHANGED_ACTION);
  context.registerReceiver(mReceiver,intentFilter);
}
Program: 43395
Project: 43395
Buggy source:
@Override public void handleMessage(Message msg){
  int baseMsgWhat=getMsgBase(msg.what);
switch (baseMsgWhat) {
case MSG_SET_SYSTEM_VOLUME:
    setSystemVolume((VolumeStreamState)msg.obj);
  break;
case MSG_PERSIST_VOLUME:
persistVolume((VolumeStreamState)msg.obj);
break;
case MSG_PERSIST_RINGER_MODE:
persistRingerMode();
break;
case MSG_PERSIST_VIBRATE_SETTING:
persistVibrateSetting();
break;
case MSG_MEDIA_SERVER_DIED:
Log.e(TAG,"String_Node_Str");
mMediaServerOk=false;
AudioSystem.getMode();
break;
case MSG_MEDIA_SERVER_STARTED:
Log.e(TAG,"String_Node_Str");
int numStreamTypes=AudioSystem.getNumStreamTypes();
for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
int index;
VolumeStreamState streamState=mStreamStates[streamType];
if (streamState.muteCount() == 0) {
index=streamState.mIndex;
}
 else {
index=0;
}
setStreamVolumeIndex(streamType,index);
}
setRingerMode(mRingerMode);
mMediaServerOk=true;
break;
case MSG_PLAY_SOUND_EFFECT:
playSoundEffect(msg.arg1,msg.arg2);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  int baseMsgWhat=getMsgBase(msg.what);
switch (baseMsgWhat) {
case MSG_SET_SYSTEM_VOLUME:
    setSystemVolume((VolumeStreamState)msg.obj);
  break;
case MSG_PERSIST_VOLUME:
persistVolume((VolumeStreamState)msg.obj);
break;
case MSG_PERSIST_RINGER_MODE:
persistRingerMode();
break;
case MSG_PERSIST_VIBRATE_SETTING:
persistVibrateSetting();
break;
case MSG_MEDIA_SERVER_DIED:
Log.e(TAG,"String_Node_Str");
mMediaServerOk=false;
AudioSystem.isMusicActive();
break;
case MSG_MEDIA_SERVER_STARTED:
Log.e(TAG,"String_Node_Str");
Set set=mConnectedDevices.entrySet();
Iterator i=set.iterator();
while (i.hasNext()) {
Map.Entry device=(Map.Entry)i.next();
AudioSystem.setDeviceConnectionState(((Integer)device.getKey()).intValue(),AudioSystem.DEVICE_STATE_AVAILABLE,(String)device.getValue());
}
AudioSystem.setPhoneState(mMode);
AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,mForcedUseForComm);
int numStreamTypes=AudioSystem.getNumStreamTypes();
for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
int index;
VolumeStreamState streamState=mStreamStates[streamType];
AudioSystem.initStreamVolume(streamType,0,(streamState.mIndexMax + 5) / 10);
if (streamState.muteCount() == 0) {
index=streamState.mIndex;
}
 else {
index=0;
}
setStreamVolumeIndex(streamType,index);
}
setRingerModeInt(getRingerMode(),false);
mMediaServerOk=true;
break;
case MSG_PLAY_SOUND_EFFECT:
playSoundEffect(msg.arg1,msg.arg2);
break;
}
}
Program: 43397
Project: 43397
Buggy source:
static void sendCloseSystemWindows(Context context,String reason){
  if (ActivityManagerNative.isSystemReady()) {
    Intent intent=new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    if (reason != null) {
      intent.putExtra(SYSTEM_DIALOG_REASON_KEY,reason);
    }
    context.sendBroadcast(intent);
  }
}

Fixed version (ground truth):
static void sendCloseSystemWindows(Context context,String reason){
  if (ActivityManagerNative.isSystemReady()) {
    try {
      ActivityManagerNative.getDefault().closeSystemDialogs(reason);
    }
 catch (    RemoteException e) {
    }
  }
}
Program: 43398
Project: 43398
Buggy source:
/** 
 * goes to the home screen
 * @return whether it did anything
 */
boolean goHome(){
  if (false) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    mContext.startActivity(mHomeIntent);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
      int result=ActivityManagerNative.getDefault().startActivity(null,mHomeIntent,mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),null,0,null,null,0,true,false);
      if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
        return false;
      }
    }
 catch (    RemoteException ex) {
    }
  }
  sendCloseSystemWindows();
  return true;
}

Fixed version (ground truth):
/** 
 * goes to the home screen
 * @return whether it did anything
 */
boolean goHome(){
  if (false) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    sendCloseSystemWindows();
    mContext.startActivity(mHomeIntent);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
      sendCloseSystemWindows();
      int result=ActivityManagerNative.getDefault().startActivity(null,mHomeIntent,mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),null,0,null,null,0,true,false);
      if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
        return false;
      }
    }
 catch (    RemoteException ex) {
    }
  }
  return true;
}
Program: 43399
Project: 43399
Buggy source:
/** 
 * A home key -> launch home action was detected.  Take the appropriate action given the situation with the keyguard.
 */
void launchHomeFromHotKey(){
  if (mKeyguardMediator.isShowing()) {
  }
 else   if (mKeyguardMediator.isInputRestricted()) {
    mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult(){
      public void onKeyguardExitResult(      boolean success){
        if (success) {
          try {
            ActivityManagerNative.getDefault().stopAppSwitches();
          }
 catch (          RemoteException e) {
          }
          mContext.startActivity(mHomeIntent);
          sendCloseSystemWindows();
        }
      }
    }
);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    mContext.startActivity(mHomeIntent);
    sendCloseSystemWindows();
  }
}

Fixed version (ground truth):
/** 
 * A home key -> launch home action was detected.  Take the appropriate action given the situation with the keyguard.
 */
void launchHomeFromHotKey(){
  if (mKeyguardMediator.isShowing()) {
  }
 else   if (mKeyguardMediator.isInputRestricted()) {
    mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult(){
      public void onKeyguardExitResult(      boolean success){
        if (success) {
          try {
            ActivityManagerNative.getDefault().stopAppSwitches();
          }
 catch (          RemoteException e) {
          }
          sendCloseSystemWindows();
          mContext.startActivity(mHomeIntent);
        }
      }
    }
);
  }
 else {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    sendCloseSystemWindows();
    mContext.startActivity(mHomeIntent);
  }
}
Program: 43400
Project: 43400
Buggy source:
public void onKeyguardExitResult(boolean success){
  if (success) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    mContext.startActivity(mHomeIntent);
    sendCloseSystemWindows();
  }
}

Fixed version (ground truth):
public void onKeyguardExitResult(boolean success){
  if (success) {
    try {
      ActivityManagerNative.getDefault().stopAppSwitches();
    }
 catch (    RemoteException e) {
    }
    sendCloseSystemWindows();
    mContext.startActivity(mHomeIntent);
  }
}
Program: 43403
Project: 43403
Buggy source:
final void handleConfigurationChanged(Configuration config){
synchronized (mRelaunchingActivities) {
    if (mPendingConfiguration != null) {
      config=mPendingConfiguration;
      mPendingConfiguration=null;
    }
  }
  ArrayList<ComponentCallbacks> callbacks=new ArrayList<ComponentCallbacks>();
synchronized (mPackages) {
    if (mConfiguration == null) {
      mConfiguration=new Configuration();
    }
    mConfiguration.updateFrom(config);
    DisplayMetrics dm=getDisplayMetricsLocked(true);
    if (config.locale != null) {
      Locale.setDefault(config.locale);
    }
    Resources.updateSystemConfiguration(config,null);
    ApplicationContext.ApplicationPackageManager.configurationChanged();
{
      Iterator<WeakReference<Resources>> it=mActiveResources.values().iterator();
      while (it.hasNext()) {
        WeakReference<Resources> v=it.next();
        Resources r=v.get();
        if (r != null) {
          r.updateConfiguration(config,dm);
        }
 else {
          it.remove();
        }
      }
    }
    callbacks=collectComponentCallbacksLocked(false,config);
  }
  final int N=callbacks.size();
  for (int i=0; i < N; i++) {
    performConfigurationChanged(callbacks.get(i),config);
  }
}

Fixed version (ground truth):
final void handleConfigurationChanged(Configuration config){
synchronized (mRelaunchingActivities) {
    if (mPendingConfiguration != null) {
      config=mPendingConfiguration;
      mPendingConfiguration=null;
    }
  }
  ArrayList<ComponentCallbacks> callbacks=new ArrayList<ComponentCallbacks>();
synchronized (mPackages) {
    if (mConfiguration == null) {
      mConfiguration=new Configuration();
    }
    mConfiguration.updateFrom(config);
    DisplayMetrics dm=getDisplayMetricsLocked(true);
    if (config.locale != null) {
      Locale.setDefault(config.locale);
    }
    Resources.updateSystemConfiguration(config,dm);
    ApplicationContext.ApplicationPackageManager.configurationChanged();
{
      Iterator<WeakReference<Resources>> it=mActiveResources.values().iterator();
      while (it.hasNext()) {
        WeakReference<Resources> v=it.next();
        Resources r=v.get();
        if (r != null) {
          r.updateConfiguration(config,dm);
        }
 else {
          it.remove();
        }
      }
    }
    callbacks=collectComponentCallbacksLocked(false,config);
  }
  final int N=callbacks.size();
  for (int i=0; i < N; i++) {
    performConfigurationChanged(callbacks.get(i),config);
  }
}
Program: 43407
Project: 43407
Buggy source:
private Object responseCdmaCallWaiting(Parcel p){
  CdmaCallWaitingNotification notification=new CdmaCallWaitingNotification();
  notification.number=p.readString();
  notification.numberPresentation=p.readInt();
  notification.name=p.readString();
  notification.namePresentation=notification.numberPresentation;
  notification.isPresent=p.readInt();
  notification.signalType=p.readInt();
  notification.alertPitch=p.readInt();
  notification.signal=p.readInt();
  return notification;
}

Fixed version (ground truth):
private Object responseCdmaCallWaiting(Parcel p){
  CdmaCallWaitingNotification notification=new CdmaCallWaitingNotification();
  notification.number=p.readString();
  notification.numberPresentation=notification.presentationFromCLIP(p.readInt());
  notification.name=p.readString();
  notification.namePresentation=notification.numberPresentation;
  notification.isPresent=p.readInt();
  notification.signalType=p.readInt();
  notification.alertPitch=p.readInt();
  notification.signal=p.readInt();
  return notification;
}
Program: 43409
Project: 43409
Buggy source:
/** 
 * Create a new MotionEvent, copying from an existing one.
 */
static public MotionEvent obtain(MotionEvent o){
  MotionEvent ev=obtain();
  ev.mDeviceId=o.mDeviceId;
  ev.mEdgeFlags=o.mEdgeFlags;
  ev.mDownTime=o.mDownTime;
  ev.mEventTimeNano=o.mEventTimeNano;
  ev.mAction=o.mAction;
  ev.mNumPointers=o.mNumPointers;
  ev.mRawX=o.mRawX;
  ev.mRawY=o.mRawY;
  ev.mMetaState=o.mMetaState;
  ev.mXPrecision=o.mXPrecision;
  ev.mYPrecision=o.mYPrecision;
  final int NT=ev.mNumSamples=o.mNumSamples;
  if (ev.mTimeSamples.length < NT) {
    System.arraycopy(o.mTimeSamples,0,ev.mTimeSamples,0,NT);
  }
 else {
    ev.mTimeSamples=(long[])o.mTimeSamples.clone();
  }
  final int NS=(ev.mNumPointers=o.mNumPointers) * NT;
  if (ev.mStateSamples.length < NS) {
    System.arraycopy(o.mStateSamples,0,ev.mStateSamples,0,NS);
  }
 else {
    ev.mStateSamples=(int[])o.mStateSamples.clone();
  }
  final int ND=NS * NUM_SAMPLE_DATA;
  if (ev.mDataSamples.length < ND) {
    System.arraycopy(o.mDataSamples,0,ev.mDataSamples,0,ND);
  }
 else {
    ev.mDataSamples=(float[])o.mDataSamples.clone();
  }
  return ev;
}

Fixed version (ground truth):
/** 
 * Create a new MotionEvent, copying from an existing one.
 */
static public MotionEvent obtain(MotionEvent o){
  MotionEvent ev=obtain();
  ev.mDeviceId=o.mDeviceId;
  ev.mEdgeFlags=o.mEdgeFlags;
  ev.mDownTime=o.mDownTime;
  ev.mEventTimeNano=o.mEventTimeNano;
  ev.mAction=o.mAction;
  ev.mNumPointers=o.mNumPointers;
  ev.mRawX=o.mRawX;
  ev.mRawY=o.mRawY;
  ev.mMetaState=o.mMetaState;
  ev.mXPrecision=o.mXPrecision;
  ev.mYPrecision=o.mYPrecision;
  final int NT=ev.mNumSamples=o.mNumSamples;
  if (ev.mTimeSamples.length >= NT) {
    System.arraycopy(o.mTimeSamples,0,ev.mTimeSamples,0,NT);
  }
 else {
    ev.mTimeSamples=(long[])o.mTimeSamples.clone();
  }
  final int NS=(ev.mNumPointers=o.mNumPointers) * NT;
  if (ev.mStateSamples.length < NS) {
    System.arraycopy(o.mStateSamples,0,ev.mStateSamples,0,NS);
  }
 else {
    ev.mStateSamples=(int[])o.mStateSamples.clone();
  }
  final int ND=NS * NUM_SAMPLE_DATA;
  if (ev.mDataSamples.length < ND) {
    System.arraycopy(o.mDataSamples,0,ev.mDataSamples,0,ND);
  }
 else {
    ev.mDataSamples=(float[])o.mDataSamples.clone();
  }
  return ev;
}
Program: 43410
Project: 43410
Buggy source:
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.TTS_ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(1000,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        result=sNativeSynth.stop();
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.TTS_SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}

Fixed version (ground truth):
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.TTS_ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        result=sNativeSynth.stop();
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.TTS_SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}
Program: 43413
Project: 43413
Buggy source:
/** 
 * Recycles an event if it can be safely recycled. The condition is that no not notified service is interested in the event.
 * @param event The event.
 */
private void tryRecycleLocked(AccessibilityEvent event){
  int eventType=event.getEventType();
  List<Service> services=mServices;
  for (int i=0, count=services.size(); i < count; i++) {
    Service service=services.get(i);
    if (service.mPendingEvents.get(eventType) == event) {
      return;
    }
  }
  event.recycle();
}

Fixed version (ground truth):
/** 
 * Recycles an event if it can be safely recycled. The condition is that no not notified service is interested in the event.
 * @param event The event.
 */
private void tryRecycleLocked(AccessibilityEvent event){
  if (event == null) {
    return;
  }
  int eventType=event.getEventType();
  List<Service> services=mServices;
  for (int i=0, count=services.size(); i < count; i++) {
    Service service=services.get(i);
    if (service.mPendingEvents.get(eventType) == event) {
      return;
    }
  }
  event.recycle();
}
Program: 43414
Project: 43414
Buggy source:
/** 
 * Request the device MDN / H_SID / H_NID / MIN. "response" is const char  [0] is MDN if CDMA subscription is available [1] is H_SID (Home SID) if CDMA subscription is available [2] is H_NID (Home NID) if CDMA subscription is available [3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
 */
public void getCDMASubscription(Message response);

Fixed version (ground truth):
/** 
 * Request the device MDN / H_SID / H_NID / MIN. "response" is const char  [0] is MDN if CDMA subscription is available [1] is H_SID (Home SID) in hexadecimal if CDMA subscription is available [2] is H_NID (Home NID) in hexadecimal if CDMA subscription is available [3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
 */
public void getCDMASubscription(Message response);
Program: 43416
Project: 43416
Buggy source:
/** 
 * @return Whether music is being played right now.
 */
boolean isMusicActive(){
  final IAudioService audio=getAudioInterface();
  if (audio == null) {
    Log.w(TAG,"String_Node_Str");
    return false;
  }
  try {
    return audio.isMusicActive();
  }
 catch (  RemoteException e) {
    Log.w(TAG,"String_Node_Str" + e);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * @return Whether music is being played right now.
 */
boolean isMusicActive(){
  final AudioManager am=(AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
  if (am == null) {
    Log.w(TAG,"String_Node_Str");
    return false;
  }
  return am.isMusicActive();
}
Program: 43418
Project: 43418
Buggy source:
private void assertParse() throws Exception {
  mParcel.writeInt(kToken);
  mParcel.setDataPosition(0);
  assertTrue(mMetadata.parse(mParcel));
  assertEquals(kToken,mParcel.readInt());
}

Fixed version (ground truth):
private void assertParse() throws Exception {
  mParcel.setDataPosition(0);
  assertTrue(mMetadata.parse(mParcel));
}
Program: 43419
Project: 43419
Buggy source:
void acceptCall() throws CallStateException {
  if (ringingCall.getState() == CdmaCall.State.INCOMING) {
    Log.i("String_Node_Str","String_Node_Str");
    setMute(false);
    cm.acceptCall(obtainCompleteMessage());
  }
 else   if (ringingCall.getState() == CdmaCall.State.WAITING) {
    CdmaConnection cwConn=(CdmaConnection)(ringingCall.getLatestConnection());
    cwConn.updateParent(ringingCall,foregroundCall);
    cwConn.onConnectedInOrOut();
    switchWaitingOrHoldingAndActive();
  }
 else {
    throw new CallStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
void acceptCall() throws CallStateException {
  if (ringingCall.getState() == CdmaCall.State.INCOMING) {
    Log.i("String_Node_Str","String_Node_Str");
    setMute(false);
    cm.acceptCall(obtainCompleteMessage());
  }
 else   if (ringingCall.getState() == CdmaCall.State.WAITING) {
    CdmaConnection cwConn=(CdmaConnection)(ringingCall.getLatestConnection());
    cwConn.updateParent(ringingCall,foregroundCall);
    cwConn.onConnectedInOrOut();
    updatePhoneState();
    switchWaitingOrHoldingAndActive();
  }
 else {
    throw new CallStateException("String_Node_Str");
  }
}
Program: 43421
Project: 43421
Buggy source:
private void handleCallWaitingInfo(CdmaCallWaitingNotification cw){
  if (foregroundCall.connections.size() > 1) {
    foregroundCall.setGeneric(true);
  }
  ringingCall.setGeneric(false);
  new CdmaConnection(phone.getContext(),cw,this,ringingCall);
  notifyCallWaitingInfo(cw);
}

Fixed version (ground truth):
private void handleCallWaitingInfo(CdmaCallWaitingNotification cw){
  if (foregroundCall.connections.size() > 1) {
    foregroundCall.setGeneric(true);
  }
  ringingCall.setGeneric(false);
  new CdmaConnection(phone.getContext(),cw,this,ringingCall);
  updatePhoneState();
  notifyCallWaitingInfo(cw);
}
Program: 43422
Project: 43422
Buggy source:
private void persistVolume(VolumeStreamState streamState){
  System.putInt(mContentResolver,streamState.mVolumeIndexSettingName,streamState.mIndex);
  System.putInt(mContentResolver,streamState.mLastAudibleVolumeIndexSettingName,streamState.mLastAudibleIndex);
}

Fixed version (ground truth):
private void persistVolume(VolumeStreamState streamState){
  if (streamState.mStreamType != AudioManager.STREAM_BLUETOOTH_SCO) {
    System.putInt(mContentResolver,streamState.mVolumeIndexSettingName,streamState.mIndex);
    System.putInt(mContentResolver,streamState.mLastAudibleVolumeIndexSettingName,streamState.mLastAudibleIndex);
  }
}
Program: 43423
Project: 43423
Buggy source:
public ConfigurationInfo getDeviceConfigurationInfo(){
  ConfigurationInfo config=new ConfigurationInfo();
synchronized (this) {
    config.reqTouchScreen=mConfiguration.touchscreen;
    config.reqKeyboardType=mConfiguration.keyboard;
    config.reqNavigation=mConfiguration.navigation;
    if (mConfiguration.navigation != Configuration.NAVIGATION_NONAV) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV;
    }
    if (mConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD;
    }
  }
  return config;
}

Fixed version (ground truth):
public ConfigurationInfo getDeviceConfigurationInfo(){
  ConfigurationInfo config=new ConfigurationInfo();
synchronized (this) {
    config.reqTouchScreen=mConfiguration.touchscreen;
    config.reqKeyboardType=mConfiguration.keyboard;
    config.reqNavigation=mConfiguration.navigation;
    if (mConfiguration.navigation == Configuration.NAVIGATION_DPAD || mConfiguration.navigation == Configuration.NAVIGATION_TRACKBALL) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV;
    }
    if (mConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED && mConfiguration.keyboard != Configuration.KEYBOARD_NOKEYS) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD;
    }
  }
  return config;
}
Program: 43424
Project: 43424
Buggy source:
public ConfigurationInfo getDeviceConfigurationInfo(){
  ConfigurationInfo config=new ConfigurationInfo();
synchronized (this) {
    config.reqTouchScreen=mConfiguration.touchscreen;
    config.reqKeyboardType=mConfiguration.keyboard;
    config.reqNavigation=mConfiguration.navigation;
    if (mConfiguration.navigation != Configuration.NAVIGATION_NONAV) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV;
    }
    if (mConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD;
    }
  }
  return config;
}

Fixed version (ground truth):
public ConfigurationInfo getDeviceConfigurationInfo(){
  ConfigurationInfo config=new ConfigurationInfo();
synchronized (this) {
    config.reqTouchScreen=mConfiguration.touchscreen;
    config.reqKeyboardType=mConfiguration.keyboard;
    config.reqNavigation=mConfiguration.navigation;
    if (mConfiguration.navigation == Configuration.NAVIGATION_DPAD || mConfiguration.navigation == Configuration.NAVIGATION_TRACKBALL) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV;
    }
    if (mConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED && mConfiguration.keyboard != Configuration.KEYBOARD_NOKEYS) {
      config.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD;
    }
  }
  return config;
}
Program: 43427
Project: 43427
Buggy source:
/** 
 * Converts the byte array provided to a unicode string.
 * @param b the byte array to convert to a string
 * @param includesNull determine if the byte string provided contains theUNICODE null character at the end or not; if it does, it will be removed
 * @return a Unicode string
 * @throws IllegalArgumentException if the byte array has an odd length
 */
public static String convertToUnicode(byte[] b,boolean includesNull){
  if (b == null) {
    return null;
  }
  int arrayLength=b.length;
  if (!((arrayLength % 2) == 0)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  arrayLength=(arrayLength >> 1);
  if (includesNull) {
    arrayLength-=1;
  }
  char[] c=new char[arrayLength];
  for (int i=0; i < arrayLength; i++) {
    int upper=b[2 * i];
    int lower=b[(2 * i) + 1];
    if (upper < 0) {
      upper+=256;
    }
    if (lower < 0) {
      lower+=256;
    }
    c[i]=(char)((upper << 8) | lower);
  }
  return new String(c);
}

Fixed version (ground truth):
/** 
 * Converts the byte array provided to a unicode string.
 * @param b the byte array to convert to a string
 * @param includesNull determine if the byte string provided contains theUNICODE null character at the end or not; if it does, it will be removed
 * @return a Unicode string
 * @throws IllegalArgumentException if the byte array has an odd length
 */
public static String convertToUnicode(byte[] b,boolean includesNull){
  if (b == null || b.length == 0) {
    return null;
  }
  int arrayLength=b.length;
  if (!((arrayLength % 2) == 0)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  arrayLength=(arrayLength >> 1);
  if (includesNull) {
    arrayLength-=1;
  }
  char[] c=new char[arrayLength];
  for (int i=0; i < arrayLength; i++) {
    int upper=b[2 * i];
    int lower=b[(2 * i) + 1];
    if (upper < 0) {
      upper+=256;
    }
    if (lower < 0) {
      lower+=256;
    }
    c[i]=(char)((upper << 8) | lower);
  }
  return new String(c);
}
Program: 43428
Project: 43428
Buggy source:
public void onCompletion(MediaPlayer arg0){
  String callingApp=mCurrentSpeechItem.mCallingApp;
  ArrayList<String> params=mCurrentSpeechItem.mParams;
  String utteranceId="String_Node_Str";
  if (params != null) {
    for (int i=0; i < params.size() - 1; i=i + 2) {
      String param=params.get(i);
      if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)) {
        utteranceId=params.get(i + 1);
      }
    }
  }
  if (utteranceId.length() > 0) {
    dispatchUtteranceCompletedCallback(utteranceId,callingApp);
  }
  mCurrentSpeechItem=null;
  processSpeechQueue();
}

Fixed version (ground truth):
public void onCompletion(MediaPlayer arg0){
  String callingApp=mCurrentSpeechItem.mCallingApp;
  ArrayList<String> params=mCurrentSpeechItem.mParams;
  String utteranceId="String_Node_Str";
  if (params != null) {
    for (int i=0; i < params.size() - 1; i=i + 2) {
      String param=params.get(i);
      if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)) {
        utteranceId=params.get(i + 1);
      }
    }
  }
  if (utteranceId.length() > 0) {
    dispatchUtteranceCompletedCallback(utteranceId,callingApp);
  }
  processSpeechQueue();
}