private static String generateAesKeyName(Context context)
      throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
    final char[] password = context.getPackageName().toCharArray();

    final byte[] salt = getDeviceSerialNumber(context).getBytes();

    SecretKey key;
    try {
      // TODO: what if there's an OS upgrade and now supports the primary
      // PBE
      key =
          SecurePreferencesOld.generatePBEKey(
              password, salt, PRIMARY_PBE_KEY_ALG, ITERATIONS, KEY_SIZE);
    } catch (NoSuchAlgorithmException e) {
      // older devices may not support the have the implementation try
      // with a weaker
      // algorthm
      key =
          SecurePreferencesOld.generatePBEKey(
              password, salt, BACKUP_PBE_KEY_ALG, ITERATIONS, KEY_SIZE);
    }
    return SecurePreferencesOld.encode(key.getEncoded());
  }