code: @VisibleForTesting
      byte[] getAESKey() throws IncompatibleDeviceException, CryptoException {
          final String encodedEncryptedAES = storage.retrieveString(KEY_ALIAS);
          if (encodedEncryptedAES != null) {
              //Return existing key
              byte[] encryptedAES = Base64.decode(encodedEncryptedAES, Base64.DEFAULT);
              return RSADecrypt(encryptedAES);
          }
          //Key doesn't exist. Generate new AES
          try {
              KeyGenerator keyGen = KeyGenerator.getInstance(ALGORITHM_AES);
              keyGen.init(AES_KEY_SIZE);
              byte[] aes = keyGen.generateKey().getEncoded();
              //Save encrypted encoded version
              byte[] encryptedAES = RSAEncrypt(aes);
              String encodedEncryptedAESText = new String(Base64.encode(encryptedAES, Base64.DEFAULT));
              storage.store(KEY_ALIAS, encodedEncryptedAESText);
              return aes;
          } catch (NoSuchAlgorithmException e) {
              /*
               * This exceptions are safe to be ignored:
               *
               * - NoSuchAlgorithmException:
               *      Thrown if the Algorithm implementation is not available. AES was introduced in API 1
               *
               * Read more in https://developer.android.com/reference/javax/crypto/KeyGenerator
               */
              Log.e(TAG, "Error while creating the AES key.", e);
              throw new IncompatibleDeviceException(e);
          }
      }
docs: Attempts to recover the existing AES Key or generates a new one if none is found.
  
  @return a valid  AES Key bytes
  @throws IncompatibleDeviceException in the event the device can't understand the cryptographic settings required
  @throws CryptoException             if the stored RSA keys can't be recovered and should be deemed invalid