message: Don't call Cipher.updateAAD when aad is empty or null.
  Cipher.updateAAD doesn't work on Android KitKat, so this is a workaround for users that don't need aad.
  GitOrigin-RevId:
diff: @@ -41,6 +41,10 @@ public final class AesGcmJce implements Aead {
  }
  @Override
  + /**
  + * On Android KitKat (API level 19) this method does not support non null or non empty {@code
  + * associatedData}. It might not work at all in older versions.
  + */
  public byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
  throws GeneralSecurityException {
  // Check that ciphertext is not longer than the max. size of a Java array.
  @@ -54,17 +58,19 @@ public final class AesGcmJce implements Aead {
  Cipher cipher = instance();
  GCMParameterSpec params = new GCMParameterSpec(8 * TAG_SIZE_IN_BYTES, iv);
  cipher.init(Cipher.ENCRYPT_MODE, keySpec, params);
  - byte[] aad = associatedData;
  - if (aad == null) {
  - aad = new byte[0];
  + if (associatedData != null && associatedData.length != 0) {
  + cipher.updateAAD(associatedData);
  }
  - cipher.updateAAD(aad);
  int unusedWritten =
  cipher.doFinal(plaintext, 0, plaintext.length, ciphertext, IV_SIZE_IN_BYTES);
  return ciphertext;
  }
  @Override
  + /**
  + * On Android KitKat (API level 19) this method does not support non null or non empty {@code
  + * associatedData}. It might not work at all in older versions.
  + */
  public byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
  throws GeneralSecurityException {
  if (ciphertext.length < IV_SIZE_IN_BYTES + TAG_SIZE_IN_BYTES) {
  @@ -74,11 +80,9 @@ public final class AesGcmJce implements Aead {
  new GCMParameterSpec(8 * TAG_SIZE_IN_BYTES, ciphertext, 0, IV_SIZE_IN_BYTES);
  Cipher cipher = instance();
  cipher.init(Cipher.DECRYPT_MODE, keySpec, params);
  - byte[] aad = associatedData;
  - if (aad == null) {
  - aad = new byte[0];
  + if (associatedData != null && associatedData.length != 0) {
  + cipher.updateAAD(associatedData);
  }
  - cipher.updateAAD(aad);
  return cipher.doFinal(ciphertext, IV_SIZE_IN_BYTES, ciphertext.length - IV_SIZE_IN_BYTES);
  }
  };
  