Program: 181008
Project: 181008
Buggy source:
public void handleMessage(Message msg){
  boolean status;
  long size;
  String formattedSize;
  ApplicationInfo info;
  Bundle data;
  String pkgName=null;
  AppInfo appInfo;
  data=msg.getData();
  if (data != null) {
    pkgName=data.getString(ATTR_PKG_NAME);
  }
switch (msg.what) {
case INIT_PKG_INFO:
    if (localLOGV)     Log.i(TAG,"String_Node_Str" + mJustCreated);
  List<ApplicationInfo> newList=null;
if (!mJustCreated) {
  newList=getInstalledApps(FILTER_APPS_ALL);
  updateAppList(newList);
}
initAppList(newList,mFilterApps);
mHandler.sendEmptyMessage(NEXT_LOAD_STEP);
break;
case COMPUTE_BULK_SIZE:
if (localLOGV) Log.i(TAG,"String_Node_Str");
String[] pkgs=data.getStringArray(ATTR_PKGS);
long[] sizes=data.getLongArray(ATTR_STATS);
String[] formatted=data.getStringArray(ATTR_SIZE_STRS);
if (pkgs == null || sizes == null || formatted == null) {
Log.w(TAG,"String_Node_Str");
break;
}
mAppInfoAdapter.bulkUpdateSizes(pkgs,sizes,formatted);
break;
case COMPUTE_END:
mComputeSizes=true;
mFirst=true;
mHandler.sendEmptyMessage(NEXT_LOAD_STEP);
break;
case REMOVE_PKG:
if (localLOGV) Log.i(TAG,"String_Node_Str");
if (pkgName == null) {
Log.w(TAG,"String_Node_Str");
break;
}
if (!mComputeSizes) {
Boolean currB=mAddRemoveMap.get(pkgName);
if (currB == null || (currB.equals(Boolean.TRUE))) {
mAddRemoveMap.put(pkgName,Boolean.FALSE);
}
break;
}
List<String> pkgList=new ArrayList<String>();
pkgList.add(pkgName);
mAppInfoAdapter.removeFromList(pkgList);
break;
case REORDER_LIST:
if (localLOGV) Log.i(TAG,"String_Node_Str");
int menuOption=msg.arg1;
if ((menuOption == SORT_ORDER_ALPHA) || (menuOption == SORT_ORDER_SIZE)) {
if (menuOption != mSortOrder) {
mSortOrder=menuOption;
if (localLOGV) Log.i(TAG,"String_Node_Str" + mSortOrder);
mAppInfoAdapter.sortList(mSortOrder);
}
}
 else if (menuOption != mFilterApps) {
mFilterApps=menuOption;
boolean ret=mAppInfoAdapter.resetAppList(mFilterApps);
if (!ret) {
mFilterApps=FILTER_APPS_ALL;
mHandler.sendEmptyMessage(INIT_PKG_INFO);
sendMessageToHandler(REORDER_LIST,menuOption);
}
}
break;
case ADD_PKG_START:
if (localLOGV) Log.i(TAG,"String_Node_Str");
if (pkgName == null) {
Log.w(TAG,"String_Node_Str");
break;
}
if (!mComputeSizes || !mLoadLabels) {
Boolean currB=mAddRemoveMap.get(pkgName);
if (currB == null || (currB.equals(Boolean.FALSE))) {
mAddRemoveMap.put(pkgName,Boolean.TRUE);
}
break;
}
try {
info=mPm.getApplicationInfo(pkgName,0);
}
 catch (NameNotFoundException e) {
Log.w(TAG,"String_Node_Str" + pkgName);
break;
}
mObserver.invokeGetSizeInfo(pkgName);
break;
case ADD_PKG_DONE:
if (localLOGV) Log.i(TAG,"String_Node_Str");
if (pkgName == null) {
Log.w(TAG,"String_Node_Str");
break;
}
status=data.getBoolean(ATTR_GET_SIZE_STATUS);
if (status) {
size=data.getLong(ATTR_PKG_STATS);
formattedSize=data.getString(ATTR_PKG_SIZE_STR);
int idx=mAppInfoAdapter.getIndex(pkgName);
if (idx == -1) {
mAppInfoAdapter.addToList(pkgName,size,formattedSize);
}
 else {
mAppInfoAdapter.updatePackage(pkgName,size,formattedSize);
}
}
break;
case REFRESH_LABELS:
Map<String,CharSequence> labelMap=(Map<String,CharSequence>)msg.obj;
if (labelMap != null) {
mAppInfoAdapter.bulkUpdateLabels(labelMap);
}
break;
case REFRESH_ICONS:
Map<String,Drawable> iconMap=(Map<String,Drawable>)msg.obj;
if (iconMap != null) {
mAppInfoAdapter.bulkUpdateIcons(iconMap);
}
break;
case REFRESH_DONE:
mLoadLabels=true;
mHandler.sendEmptyMessage(NEXT_LOAD_STEP);
break;
case NEXT_LOAD_STEP:
if (!mCache.isEmpty() && mSetListViewLater) {
if (localLOGV) Log.i(TAG,"String_Node_Str");
initListView();
mSetListViewLater=false;
mFirst=true;
}
if (mComputeSizes && mLoadLabels) {
doneLoadingData();
Set<String> keys=mAddRemoveMap.keySet();
for (String key : keys) {
if (mAddRemoveMap.get(key) == Boolean.TRUE) {
updatePackageList(Intent.ACTION_PACKAGE_ADDED,key);
}
 else {
updatePackageList(Intent.ACTION_PACKAGE_REMOVED,key);
}
}
mAddRemoveMap.clear();
}
 else if (!mComputeSizes && !mLoadLabels) {
if (mSizesFirst) {
initComputeSizes();
}
 else {
initResourceThread();
}
}
 else {
if (mSetListViewLater) {
if (localLOGV) Log.i(TAG,"String_Node_Str");
initListView();
mSetListViewLater=false;
}
if (!mComputeSizes) {
initComputeSizes();
}
 else if (!mLoadLabels) {
initResourceThread();
}
}
break;
default :
break;
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
  boolean status;
  long size;
  String formattedSize;
  ApplicationInfo info;
  Bundle data;
  String pkgName=null;
  AppInfo appInfo;
  data=msg.getData();
  if (data != null) {
    pkgName=data.getString(ATTR_PKG_NAME);
  }
switch (msg.what) {
case INIT_PKG_INFO:
    if (localLOGV)     Log.i(TAG,"String_Node_Str" + mJustCreated);
  List<ApplicationInfo> newList=null;
if (!mJustCreated) {
  if (localLOGV)   Log.i(TAG,"String_Node_Str");
  newList=getInstalledApps(FILTER_APPS_ALL);
  updateAppList(newList);
}
initAppList(newList,mFilterApps);
mHandler.sendEmptyMessage(NEXT_LOAD_STEP);
break;
case COMPUTE_BULK_SIZE:
if (localLOGV) Log.i(TAG,"String_Node_Str");
String[] pkgs=data.getStringArray(ATTR_PKGS);
long[] sizes=data.getLongArray(ATTR_STATS);
String[] formatted=data.getStringArray(ATTR_SIZE_STRS);
if (pkgs == null || sizes == null || formatted == null) {
Log.w(TAG,"String_Node_Str");
break;
}
mAppInfoAdapter.bulkUpdateSizes(pkgs,sizes,formatted);
break;
case COMPUTE_END:
mComputeSizes=true;
mFirst=true;
mHandler.sendEmptyMessage(NEXT_LOAD_STEP);
break;
case REMOVE_PKG:
if (localLOGV) Log.i(TAG,"String_Node_Str");
if (pkgName == null) {
Log.w(TAG,"String_Node_Str");
break;
}
if (!mComputeSizes) {
Boolean currB=mAddRemoveMap.get(pkgName);
if (currB == null || (currB.equals(Boolean.TRUE))) {
mAddRemoveMap.put(pkgName,Boolean.FALSE);
}
break;
}
List<String> pkgList=new ArrayList<String>();
pkgList.add(pkgName);
mAppInfoAdapter.removeFromList(pkgList);
break;
case REORDER_LIST:
if (localLOGV) Log.i(TAG,"String_Node_Str");
int menuOption=msg.arg1;
if ((menuOption == SORT_ORDER_ALPHA) || (menuOption == SORT_ORDER_SIZE)) {
if (menuOption != mSortOrder) {
mSortOrder=menuOption;
if (localLOGV) Log.i(TAG,"String_Node_Str" + mSortOrder);
mAppInfoAdapter.sortList(mSortOrder);
}
}
 else if (menuOption != mFilterApps) {
mFilterApps=menuOption;
boolean ret=mAppInfoAdapter.resetAppList(mFilterApps);
if (!ret) {
mFilterApps=FILTER_APPS_ALL;
mHandler.sendEmptyMessage(INIT_PKG_INFO);
sendMessageToHandler(REORDER_LIST,menuOption);
}
}
break;
case ADD_PKG_START:
if (localLOGV) Log.i(TAG,"String_Node_Str");
if (pkgName == null) {
Log.w(TAG,"String_Node_Str");
break;
}
if (!mComputeSizes || !mLoadLabels) {
Boolean currB=mAddRemoveMap.get(pkgName);
if (currB == null || (currB.equals(Boolean.FALSE))) {
mAddRemoveMap.put(pkgName,Boolean.TRUE);
}
break;
}
try {
info=mPm.getApplicationInfo(pkgName,0);
}
 catch (NameNotFoundException e) {
Log.w(TAG,"String_Node_Str" + pkgName);
break;
}
mObserver.invokeGetSizeInfo(pkgName);
break;
case ADD_PKG_DONE:
if (localLOGV) Log.i(TAG,"String_Node_Str");
if (pkgName == null) {
Log.w(TAG,"String_Node_Str");
break;
}
status=data.getBoolean(ATTR_GET_SIZE_STATUS);
if (status) {
size=data.getLong(ATTR_PKG_STATS);
formattedSize=data.getString(ATTR_PKG_SIZE_STR);
if (!mAppInfoAdapter.isInstalled(pkgName)) {
mAppInfoAdapter.addToList(pkgName,size,formattedSize);
}
 else {
mAppInfoAdapter.updatePackage(pkgName,size,formattedSize);
}
}
break;
case REFRESH_LABELS:
Map<String,CharSequence> labelMap=(Map<String,CharSequence>)msg.obj;
if (labelMap != null) {
mAppInfoAdapter.bulkUpdateLabels(labelMap);
}
break;
case REFRESH_ICONS:
Map<String,Drawable> iconMap=(Map<String,Drawable>)msg.obj;
if (iconMap != null) {
mAppInfoAdapter.bulkUpdateIcons(iconMap);
}
break;
case REFRESH_DONE:
mLoadLabels=true;
mHandler.sendEmptyMessage(NEXT_LOAD_STEP);
break;
case NEXT_LOAD_STEP:
if (!mCache.isEmpty() && mSetListViewLater) {
if (localLOGV) Log.i(TAG,"String_Node_Str");
initListView();
mSetListViewLater=false;
mFirst=true;
}
if (mComputeSizes && mLoadLabels) {
doneLoadingData();
Set<String> keys=mAddRemoveMap.keySet();
for (String key : keys) {
if (mAddRemoveMap.get(key) == Boolean.TRUE) {
updatePackageList(Intent.ACTION_PACKAGE_ADDED,key);
}
 else {
updatePackageList(Intent.ACTION_PACKAGE_REMOVED,key);
}
}
mAddRemoveMap.clear();
}
 else if (!mComputeSizes && !mLoadLabels) {
if (mSizesFirst) {
initComputeSizes();
}
 else {
initResourceThread();
}
}
 else {
if (mSetListViewLater) {
if (localLOGV) Log.i(TAG,"String_Node_Str");
initListView();
mSetListViewLater=false;
}
if (!mComputeSizes) {
initComputeSizes();
}
 else if (!mLoadLabels) {
initResourceThread();
}
}
break;
default :
break;
}
}