Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ade57106 authored by Yan Yan's avatar Yan Yan Committed by Gerrit Code Review
Browse files

Merge "Encode IkeSessionParams using getIkeOptions" into main

parents 7c60e2c3 5457e16d
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -162,14 +162,23 @@ public final class IkeSessionParamsUtils {
        result.putInt(IP_VERSION_KEY, params.getIpVersion());
        result.putInt(ENCAP_TYPE_KEY, params.getEncapType());

        // TODO: b/185941731 Make sure IkeSessionParamsUtils is automatically updated when a new
        // IKE_OPTION is defined in IKE module and added in the IkeSessionParams
        final List<Integer> enabledIkeOptions = new ArrayList<>();

        try {
            // TODO: b/328844044: Ideally this code should gate the behavior by checking the
            // com.android.ipsec.flags.enabled_ike_options_api flag but that flag is not accessible
            // right now. We should either update the code when the flag is accessible or remove the
            // legacy behavior after VIC SDK finalization
            enabledIkeOptions.addAll(params.getIkeOptions());
        } catch (Exception e) {
            // getIkeOptions throws. It means the API is not available
            enabledIkeOptions.clear();
            for (int option : IKE_OPTIONS) {
                if (isIkeOptionValid(option) && params.hasIkeOption(option)) {
                    enabledIkeOptions.add(option);
                }
            }
        }

        final int[] optionArray = enabledIkeOptions.stream().mapToInt(i -> i).toArray();
        result.putIntArray(IKE_OPTIONS_KEY, optionArray);