/**
   * Checks whether too {@link PkgItem} are the same. This checks both items have the same state,
   * both main package are similar and that they have the same updating packages.
   */
  public boolean isSameItemAs(PkgItem item) {
    if (this == item) {
      return true;
    }
    boolean same = this.mState == item.mState;
    if (same) {
      same = isSameMainPackageAs(item.getMainPackage());
    }

    if (same) {
      // check updating packages are the same
      Package p1 = this.mUpdatePkg;
      Package p2 = item.getUpdatePkg();
      same = (p1 == p2) || (p1 == null && p2 == null) || (p1 != null && p2 != null);

      if (same && p1 != null) {
        same = p1.canBeUpdatedBy(p2) == UpdateInfo.NOT_UPDATE;
      }
    }

    return same;
  }
 public int compareTo(PkgItem pkg) {
   return getMainPackage().compareTo(pkg.getMainPackage());
 }