예제 #1
0
  public static TransitIdentity parseTransitIdentity(Card card) {
    DesfireCard desfireCard = (DesfireCard) card;
    byte[] data = desfireCard.getApplication(4594).getFile(15).getData();
    data = Utils.reverseBuffer(data, 0, 16);

    long serialNumber1 = Utils.getBitsFromBuffer(data, 96, 32);
    long serialNumber2 = Utils.getBitsFromBuffer(data, 64, 32);
    return new TransitIdentity(NAME, formatSerialNumber(serialNumber1, serialNumber2));
  }
예제 #2
0
  public MykiTransitData(Card card) {
    DesfireCard desfireCard = (DesfireCard) card;
    byte[] metadata = desfireCard.getApplication(4594).getFile(15).getData();
    metadata = Utils.reverseBuffer(metadata, 0, 16);

    try {
      mSerialNumber1 = Utils.getBitsFromBuffer(metadata, 96, 32);
      mSerialNumber2 = Utils.getBitsFromBuffer(metadata, 64, 32);
    } catch (Exception ex) {
      throw new RuntimeException("Error parsing Myki data", ex);
    }
  }
예제 #3
0
파일: Utils.java 프로젝트: jardar/farebot
  public static void showErrorAndFinish(final Activity activity, Exception ex) {
    try {
      Log.e(activity.getClass().getName(), Utils.getErrorMessage(ex));
      ex.printStackTrace();

      new AlertDialog.Builder(activity)
          .setMessage(Utils.getErrorMessage(ex))
          .setCancelable(false)
          .setPositiveButton(
              android.R.string.ok,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface arg0, int arg1) {
                  activity.finish();
                }
              })
          .show();
    } catch (WindowManager.BadTokenException unused) {
      /* Ignore... happens if the activity was destroyed */
    }
  }
  @Override
  public boolean onListChildClick(
      ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    ClassicSector sector = mCard.getSector(groupPosition);
    ClassicBlock block = sector.getBlock(childPosition);

    String data = Utils.getHexString(block.getData(), "");

    String sectorTitle = getString(R.string.sector_title_format, sector.getIndex());
    String blockTitle = getString(R.string.block_title_format, block.getIndex());
    new AlertDialog.Builder(getActivity())
        .setTitle(String.format("%s, %s", sectorTitle, blockTitle))
        .setPositiveButton(android.R.string.ok, null)
        .setMessage(data)
        .show();

    return true;
  }
예제 #5
0
 private static String formatSerialNumber(long serialNumber1, long serialNumber2) {
   String formattedSerial = String.format("%06d%08d", serialNumber1, serialNumber2);
   return formattedSerial + Utils.calculateLuhn(formattedSerial);
 }
예제 #6
0
파일: Utils.java 프로젝트: jardar/farebot
 public static void showError(final Activity activity, Exception ex) {
   Log.e(activity.getClass().getName(), ex.getMessage(), ex);
   new AlertDialog.Builder(activity).setMessage(Utils.getErrorMessage(ex)).show();
 }
예제 #7
0
 @Override
 public String getSubscriptionName() {
   return Utils.localizeString(R.string.opal_automatic_top_up);
 }