Program: 199827
Project: 199827
Buggy source:
boolean bindWallpaperComponentLocked(ComponentName componentName,boolean force,boolean fromUser,WallpaperData wallpaper,IRemoteCallback reply){
  if (DEBUG)   Slog.v(TAG,"String_Node_Str" + componentName);
  if (!force) {
    if (wallpaper.connection != null) {
      if (wallpaper.wallpaperComponent == null) {
        if (componentName == null) {
          if (DEBUG)           Slog.v(TAG,"String_Node_Str");
          return true;
        }
      }
 else       if (wallpaper.wallpaperComponent.equals(componentName)) {
        if (DEBUG)         Slog.v(TAG,"String_Node_Str");
        return true;
      }
    }
  }
  try {
    if (componentName == null) {
      String defaultComponent=mContext.getString(com.android.internal.R.string.default_wallpaper_component);
      if (defaultComponent != null) {
        componentName=ComponentName.unflattenFromString(defaultComponent);
        if (DEBUG)         Slog.v(TAG,"String_Node_Str" + componentName);
      }
      if (componentName == null) {
        componentName=IMAGE_WALLPAPER;
        if (DEBUG)         Slog.v(TAG,"String_Node_Str");
      }
    }
    int serviceUserId=wallpaper.userId;
    ServiceInfo si=mIPackageManager.getServiceInfo(componentName,PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS,serviceUserId);
    if (si == null) {
      Slog.w(TAG,"String_Node_Str" + componentName + "String_Node_Str");
      return false;
    }
    if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
      String msg="String_Node_Str" + android.Manifest.permission.BIND_WALLPAPER + "String_Node_Str"+ componentName;
      if (fromUser) {
        throw new SecurityException(msg);
      }
      Slog.w(TAG,msg);
      return false;
    }
    WallpaperInfo wi=null;
    Intent intent=new Intent(WallpaperService.SERVICE_INTERFACE);
    if (componentName != null && !componentName.equals(IMAGE_WALLPAPER)) {
      List<ResolveInfo> ris=mIPackageManager.queryIntentServices(intent,intent.resolveTypeIfNeeded(mContext.getContentResolver()),PackageManager.GET_META_DATA,serviceUserId);
      for (int i=0; i < ris.size(); i++) {
        ServiceInfo rsi=ris.get(i).serviceInfo;
        if (rsi.name.equals(si.name) && rsi.packageName.equals(si.packageName)) {
          try {
            wi=new WallpaperInfo(mContext,ris.get(i));
          }
 catch (          XmlPullParserException e) {
            if (fromUser) {
              throw new IllegalArgumentException(e);
            }
            Slog.w(TAG,e);
            return false;
          }
catch (          IOException e) {
            if (fromUser) {
              throw new IllegalArgumentException(e);
            }
            Slog.w(TAG,e);
            return false;
          }
          break;
        }
      }
      if (wi == null) {
        String msg="String_Node_Str" + componentName;
        if (fromUser) {
          throw new SecurityException(msg);
        }
        Slog.w(TAG,msg);
        return false;
      }
    }
    if (DEBUG)     Slog.v(TAG,"String_Node_Str" + componentName);
    WallpaperConnection newConn=new WallpaperConnection(wi,wallpaper);
    intent.setComponent(componentName);
    intent.putExtra(Intent.EXTRA_CLIENT_LABEL,com.android.internal.R.string.wallpaper_binding_label);
    intent.putExtra(Intent.EXTRA_CLIENT_INTENT,PendingIntent.getActivityAsUser(mContext,0,Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER),mContext.getText(com.android.internal.R.string.chooser_wallpaper)),0,null,new UserHandle(serviceUserId)));
    if (!mContext.bindServiceAsUser(intent,newConn,Context.BIND_AUTO_CREATE | Context.BIND_SHOWING_UI,new UserHandle(serviceUserId))) {
      String msg="String_Node_Str" + componentName;
      if (fromUser) {
        throw new IllegalArgumentException(msg);
      }
      Slog.w(TAG,msg);
      return false;
    }
    if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null) {
      detachWallpaperLocked(mLastWallpaper);
    }
    wallpaper.wallpaperComponent=componentName;
    wallpaper.connection=newConn;
    wallpaper.lastDiedTime=SystemClock.uptimeMillis();
    newConn.mReply=reply;
    try {
      if (wallpaper.userId == mCurrentUserId) {
        if (DEBUG)         Slog.v(TAG,"String_Node_Str" + newConn.mToken);
        mIWindowManager.addWindowToken(newConn.mToken,WindowManager.LayoutParams.TYPE_WALLPAPER);
        mLastWallpaper=wallpaper;
      }
    }
 catch (    RemoteException e) {
    }
  }
 catch (  RemoteException e) {
    String msg="String_Node_Str" + componentName + "String_Node_Str"+ e;
    if (fromUser) {
      throw new IllegalArgumentException(msg);
    }
    Slog.w(TAG,msg);
    return false;
  }
  return true;
}

Fixed version (ground truth):
boolean bindWallpaperComponentLocked(ComponentName componentName,boolean force,boolean fromUser,WallpaperData wallpaper,IRemoteCallback reply){
  if (DEBUG)   Slog.v(TAG,"String_Node_Str" + componentName);
  if (!force) {
    if (wallpaper.connection != null) {
      if (wallpaper.wallpaperComponent == null) {
        if (componentName == null) {
          if (DEBUG)           Slog.v(TAG,"String_Node_Str");
          return true;
        }
      }
 else       if (wallpaper.wallpaperComponent.equals(componentName)) {
        if (DEBUG)         Slog.v(TAG,"String_Node_Str");
        return true;
      }
    }
  }
  try {
    if (componentName == null) {
      String defaultComponent=mContext.getString(com.android.internal.R.string.default_wallpaper_component);
      if (defaultComponent != null) {
        componentName=ComponentName.unflattenFromString(defaultComponent);
        if (DEBUG)         Slog.v(TAG,"String_Node_Str" + componentName);
      }
      if (componentName == null) {
        componentName=IMAGE_WALLPAPER;
        if (DEBUG)         Slog.v(TAG,"String_Node_Str");
      }
    }
    int serviceUserId=wallpaper.userId;
    ServiceInfo si=mIPackageManager.getServiceInfo(componentName,PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS,serviceUserId);
    if (si == null) {
      Slog.w(TAG,"String_Node_Str" + componentName + "String_Node_Str");
      return false;
    }
    if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
      String msg="String_Node_Str" + android.Manifest.permission.BIND_WALLPAPER + "String_Node_Str"+ componentName;
      if (fromUser) {
        throw new SecurityException(msg);
      }
      Slog.w(TAG,msg);
      return false;
    }
    WallpaperInfo wi=null;
    Intent intent=new Intent(WallpaperService.SERVICE_INTERFACE);
    if (componentName != null && !componentName.equals(IMAGE_WALLPAPER)) {
      List<ResolveInfo> ris=mIPackageManager.queryIntentServices(intent,intent.resolveTypeIfNeeded(mContext.getContentResolver()),PackageManager.GET_META_DATA,serviceUserId);
      for (int i=0; i < ris.size(); i++) {
        ServiceInfo rsi=ris.get(i).serviceInfo;
        if (rsi.name.equals(si.name) && rsi.packageName.equals(si.packageName)) {
          try {
            wi=new WallpaperInfo(mContext,ris.get(i));
          }
 catch (          XmlPullParserException e) {
            if (fromUser) {
              throw new IllegalArgumentException(e);
            }
            Slog.w(TAG,e);
            return false;
          }
catch (          IOException e) {
            if (fromUser) {
              throw new IllegalArgumentException(e);
            }
            Slog.w(TAG,e);
            return false;
          }
          break;
        }
      }
      if (wi == null) {
        String msg="String_Node_Str" + componentName;
        if (fromUser) {
          throw new SecurityException(msg);
        }
        Slog.w(TAG,msg);
        return false;
      }
    }
    if (DEBUG)     Slog.v(TAG,"String_Node_Str" + componentName);
    WallpaperConnection newConn=new WallpaperConnection(wi,wallpaper);
    intent.setComponent(componentName);
    intent.putExtra(Intent.EXTRA_CLIENT_LABEL,com.android.internal.R.string.wallpaper_binding_label);
    intent.putExtra(Intent.EXTRA_CLIENT_INTENT,PendingIntent.getActivityAsUser(mContext,0,Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER),mContext.getText(com.android.internal.R.string.chooser_wallpaper)),0,null,new UserHandle(serviceUserId)));
    if (!mContext.bindServiceAsUser(intent,newConn,Context.BIND_AUTO_CREATE | Context.BIND_SHOWING_UI,new UserHandle(serviceUserId))) {
      String msg="String_Node_Str" + componentName;
      if (fromUser) {
        throw new IllegalArgumentException(msg);
      }
      Slog.w(TAG,msg);
      return false;
    }
    if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null) {
      detachWallpaperLocked(mLastWallpaper);
    }
    wallpaper.wallpaperComponent=componentName;
    wallpaper.connection=newConn;
    newConn.mReply=reply;
    try {
      if (wallpaper.userId == mCurrentUserId) {
        if (DEBUG)         Slog.v(TAG,"String_Node_Str" + newConn.mToken);
        mIWindowManager.addWindowToken(newConn.mToken,WindowManager.LayoutParams.TYPE_WALLPAPER);
        mLastWallpaper=wallpaper;
      }
    }
 catch (    RemoteException e) {
    }
  }
 catch (  RemoteException e) {
    String msg="String_Node_Str" + componentName + "String_Node_Str"+ e;
    if (fromUser) {
      throw new IllegalArgumentException(msg);
    }
    Slog.w(TAG,msg);
    return false;
  }
  return true;
}