Program: 80577
Project: 80577
Buggy source:
static void updateAppWidget(Context context,AppWidgetManager appWidgetManager,int appWidgetId,Bundle options){
  Tools.HangarLog("String_Node_Str");
  prefs=new PrefsGet(context.getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE));
  SharedPreferences mPrefs=prefs.prefsGet();
  int statsLayout;
  int itemHeight;
  if (mPrefs.getBoolean(Settings.DIVIDER_PREFERENCE,Settings.DIVIDER_DEFAULT)) {
    statsLayout=R.layout.stats_widget;
    itemHeight=36;
  }
 else {
    statsLayout=R.layout.stats_widget_no_dividers;
    itemHeight=35;
  }
  boolean appsNoByWidgetSize=mPrefs.getBoolean(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE,Settings.APPS_BY_WIDGET_SIZE_DEFAULT);
  int appsNo;
  int appsNoLs;
  Tools.HangarLog("String_Node_Str" + options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT));
  Tools.HangarLog("String_Node_Str" + options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT));
  appsNo=(int)Math.floor((options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) - 14) / itemHeight);
  appsNoLs=(int)Math.floor((options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT) - 14) / itemHeight);
  if (appsNoByWidgetSize && appsNo > 0) {
    Tools.HangarLog("String_Node_Str" + appsNo);
  }
 else {
    appsNo=Integer.parseInt(mPrefs.getString(Settings.STATS_WIDGET_APPSNO_PREFERENCE,Integer.toString(Settings.STATS_WIDGET_APPSNO_DEFAULT)));
  }
  if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    if (appsNoByWidgetSize && appsNoLs > 0) {
      appsNo=appsNoLs;
      Tools.HangarLog("String_Node_Str" + appsNo);
    }
 else {
      appsNo=Integer.parseInt(mPrefs.getString(Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE,Integer.toString(Settings.STATS_WIDGET_APPSNO_LS_DEFAULT)));
    }
    Tools.HangarLog("String_Node_Str");
  }
  int getColor=mPrefs.getInt(Settings.BACKGROUND_COLOR_PREFERENCE,Settings.BACKGROUND_COLOR_DEFAULT);
  RemoteViews views=new RemoteViews(context.getPackageName(),statsLayout);
  int mGravity=Integer.parseInt(mPrefs.getString(Settings.ALIGNMENT_PREFERENCE,Integer.toString(Settings.ALIGNMENT_DEFAULT)));
  views.setInt(R.id.taskRoot,"String_Node_Str",mGravity);
  views.removeAllViews(R.id.taskRoot);
  PackageManager pkgm=context.getPackageManager();
  String packageName=context.getPackageName();
  Intent intent;
  if (db == null) {
    db=new TasksDataSource(context);
    db.open();
  }
  int highestSeconds=db.getHighestSeconds();
  List<TasksModel> tasks=db.getAllTasks();
  Collections.sort(tasks,new Tools.TasksModelComparator("String_Node_Str"));
  int count=0;
  for (  TasksModel task : tasks) {
    RemoteViews row=new RemoteViews(context.getPackageName(),R.layout.stats_widget_row);
    int topPadding=0;
    int bottomPadding=0;
    if (count == 0)     topPadding=Tools.dpToPx(context,6);
    if (count == (appsNo - 1))     bottomPadding=Tools.dpToPx(context,6);
    row.setViewPadding(R.id.appCont,0,topPadding,0,bottomPadding);
    int clickID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int iconID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int labelID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int imgID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int statsID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    if (task.getBlacklisted()) {
      continue;
    }
    if (count >= appsNo) {
      Tools.HangarLog("String_Node_Str" + count + "String_Node_Str"+ appsNo);
      break;
    }
    Drawable taskIcon;
    try {
      ApplicationInfo appInfo=pkgm.getApplicationInfo(task.getPackageName(),0);
      taskIcon=appInfo.loadIcon(pkgm);
    }
 catch (    Exception e) {
      continue;
    }
    count++;
    Bitmap bmpIcon=((BitmapDrawable)taskIcon).getBitmap();
    row.setImageViewBitmap(iconID,bmpIcon);
    row.setTextViewText(labelID,task.getName());
    float secondsRatio=(float)task.getSeconds() / highestSeconds;
    int barColor;
    int secondsColor=(Math.round(secondsRatio * 100));
    if (secondsColor >= 80) {
      barColor=0xFF34B5E2;
    }
 else     if (secondsColor >= 60) {
      barColor=0xFFAA66CC;
    }
 else     if (secondsColor >= 40) {
      barColor=0xFF74C353;
    }
 else     if (secondsColor >= 20) {
      barColor=0xFFFFBB33;
    }
 else {
      barColor=0xFFFF4444;
    }
    int[] colors=new int[]{barColor,Tools.dpToPx(context,secondsColor - 1),0x00000000,Tools.dpToPx(mContext,100 - secondsColor)};
    Tools.HangarLog("String_Node_Str" + colors[0] + "String_Node_Str"+ colors[1]+ "String_Node_Str"+ colors[2]+ "String_Node_Str"+ colors[3]);
    Drawable sd=new BarDrawable(colors);
    Bitmap bmpIcon2=drawableToBitmap(sd);
    row.setImageViewBitmap(imgID,bmpIcon2);
    int[] statsTime=new Settings().splitToComponentTimes(task.getSeconds());
    String statsString=((statsTime[0] > 0) ? statsTime[0] + "String_Node_Str" : "String_Node_Str") + ((statsTime[1] > 0) ? statsTime[1] + "String_Node_Str" : "String_Node_Str") + ((statsTime[2] > 0) ? statsTime[2] + "String_Node_Str" : "String_Node_Str");
    row.setTextViewText(statsID,statsString);
    try {
      intent=pkgm.getLaunchIntentForPackage(task.getPackageName());
      if (intent == null) {
        count--;
        throw new PackageManager.NameNotFoundException();
      }
      intent.addCategory(Intent.CATEGORY_LAUNCHER);
      intent.setAction("String_Node_Str" + (count));
      PendingIntent activity=PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);
      row.setOnClickPendingIntent(clickID,activity);
    }
 catch (    PackageManager.NameNotFoundException e) {
    }
    row.setInt(R.id.appCont,"String_Node_Str",getColor);
    views.addView(R.id.taskRoot,row);
  }
  appWidgetManager.updateAppWidget(appWidgetId,views);
}

Fixed version (ground truth):
static void updateAppWidget(Context context,AppWidgetManager appWidgetManager,int appWidgetId,Bundle options){
  Tools.HangarLog("String_Node_Str");
  prefs=new PrefsGet(context.getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE));
  SharedPreferences mPrefs=prefs.prefsGet();
  int statsLayout;
  int itemHeight;
  if (mPrefs.getBoolean(Settings.DIVIDER_PREFERENCE,Settings.DIVIDER_DEFAULT)) {
    statsLayout=R.layout.stats_widget;
    itemHeight=36;
  }
 else {
    statsLayout=R.layout.stats_widget_no_dividers;
    itemHeight=35;
  }
  boolean appsNoByWidgetSize=mPrefs.getBoolean(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE,Settings.APPS_BY_WIDGET_SIZE_DEFAULT);
  int appsNo;
  int appsNoLs;
  Tools.HangarLog("String_Node_Str" + options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT));
  Tools.HangarLog("String_Node_Str" + options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT));
  appsNo=(int)Math.floor((options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) - 14) / itemHeight);
  appsNoLs=(int)Math.floor((options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT) - 14) / itemHeight);
  if (appsNoByWidgetSize && appsNo > 0) {
    Tools.HangarLog("String_Node_Str" + appsNo);
  }
 else {
    appsNo=Integer.parseInt(mPrefs.getString(Settings.STATS_WIDGET_APPSNO_PREFERENCE,Integer.toString(Settings.STATS_WIDGET_APPSNO_DEFAULT)));
  }
  if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    if (appsNoByWidgetSize && appsNoLs > 0) {
      appsNo=appsNoLs;
      Tools.HangarLog("String_Node_Str" + appsNo);
    }
 else {
      appsNo=Integer.parseInt(mPrefs.getString(Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE,Integer.toString(Settings.STATS_WIDGET_APPSNO_LS_DEFAULT)));
    }
    Tools.HangarLog("String_Node_Str");
  }
  int getColor=mPrefs.getInt(Settings.BACKGROUND_COLOR_PREFERENCE,Settings.BACKGROUND_COLOR_DEFAULT);
  RemoteViews views=new RemoteViews(context.getPackageName(),statsLayout);
  int mGravity=Integer.parseInt(mPrefs.getString(Settings.ALIGNMENT_PREFERENCE,Integer.toString(Settings.ALIGNMENT_DEFAULT)));
  views.setInt(R.id.taskRoot,"String_Node_Str",mGravity);
  views.removeAllViews(R.id.taskRoot);
  PackageManager pkgm=context.getPackageManager();
  String packageName=context.getPackageName();
  Intent intent;
  if (db == null) {
    db=new TasksDataSource(context);
    db.open();
  }
  int highestSeconds=db.getHighestSeconds();
  List<TasksModel> tasks=db.getAllTasks();
  Collections.sort(tasks,new Tools.TasksModelComparator("String_Node_Str"));
  int count=0;
  for (  TasksModel task : tasks) {
    RemoteViews row=new RemoteViews(context.getPackageName(),R.layout.stats_widget_row);
    int topPadding=0;
    int bottomPadding=0;
    if (count == 0)     topPadding=Tools.dpToPx(context,6);
    if (count == (appsNo - 1))     bottomPadding=Tools.dpToPx(context,6);
    row.setViewPadding(R.id.appCont,0,topPadding,0,bottomPadding);
    int clickID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int iconID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int labelID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int imgID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    int statsID=context.getResources().getIdentifier("String_Node_Str","String_Node_Str",packageName);
    if (task.getBlacklisted()) {
      continue;
    }
    if (count >= appsNo) {
      Tools.HangarLog("String_Node_Str" + count + "String_Node_Str"+ appsNo);
      break;
    }
    Drawable taskIcon;
    try {
      ApplicationInfo appInfo=pkgm.getApplicationInfo(task.getPackageName(),0);
      taskIcon=appInfo.loadIcon(pkgm);
    }
 catch (    Exception e) {
      continue;
    }
    count++;
    Bitmap bmpIcon=((BitmapDrawable)taskIcon).getBitmap();
    row.setImageViewBitmap(iconID,bmpIcon);
    row.setTextViewText(labelID,task.getName());
    float secondsRatio=(float)task.getSeconds() / highestSeconds;
    int barColor;
    int secondsColor=(Math.round(secondsRatio * 100));
    if (secondsColor >= 80) {
      barColor=0xFF34B5E2;
    }
 else     if (secondsColor >= 60) {
      barColor=0xFFAA66CC;
    }
 else     if (secondsColor >= 40) {
      barColor=0xFF74C353;
    }
 else     if (secondsColor >= 20) {
      barColor=0xFFFFBB33;
    }
 else {
      barColor=0xFFFF4444;
    }
    int[] colors=new int[]{barColor,Tools.dpToPx(context,secondsColor - 1),0x00000000,Tools.dpToPx(mContext,100 - secondsColor)};
    Drawable sd=new BarDrawable(colors);
    Bitmap bmpIcon2=drawableToBitmap(sd);
    row.setImageViewBitmap(imgID,bmpIcon2);
    int[] statsTime=new Settings().splitToComponentTimes(task.getSeconds());
    String statsString=((statsTime[0] > 0) ? statsTime[0] + "String_Node_Str" : "String_Node_Str") + ((statsTime[1] > 0) ? statsTime[1] + "String_Node_Str" : "String_Node_Str") + ((statsTime[2] > 0) ? statsTime[2] + "String_Node_Str" : "String_Node_Str");
    row.setTextViewText(statsID,statsString);
    try {
      intent=pkgm.getLaunchIntentForPackage(task.getPackageName());
      if (intent == null) {
        count--;
        throw new PackageManager.NameNotFoundException();
      }
      intent.addCategory(Intent.CATEGORY_LAUNCHER);
      intent.setAction("String_Node_Str" + (count));
      PendingIntent activity=PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);
      row.setOnClickPendingIntent(clickID,activity);
    }
 catch (    PackageManager.NameNotFoundException e) {
    }
    row.setInt(R.id.appCont,"String_Node_Str",getColor);
    views.addView(R.id.taskRoot,row);
  }
  appWidgetManager.updateAppWidget(appWidgetId,views);
}