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

Commit 49f9216a authored by chiachangwang's avatar chiachangwang Committed by Chiachang Wang
Browse files

Use PersistableBundle.getInt(String, int) with default value parameter

The default value for PersistableBundle.getInt(String) is 0. This
value is a valid value for the KEY_PREFERRED_IKE_PROTOCOL_INT
setting which is PREFERRED_IKE_PROTOCOL_AUTO. But the preferred
design now is to use IPv4 instead of AUTO. The default value for
getting KEY_PREFERRED_IKE_PROTOCOL_INT should be explicitly set
to an invalid value so that the flow will go into the default
case as expectation.

Bug: 269714970
Bug: 284246686
Test: m ; flash and check the value
Change-Id: Icf83ec1a50972b2d9ce7d168dad75dd9aa3cf1bb
parent 86ba6546
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -309,6 +309,8 @@ public class Vpn {
     */
    @VisibleForTesting
    static final int DEFAULT_LONG_LIVED_TCP_CONNS_EXPENSIVE_TIMEOUT_SEC = 60;

    private static final int PREFERRED_IKE_PROTOCOL_UNKNOWN = -1;
    /**
     *  Prefer using {@link IkeSessionParams.ESP_IP_VERSION_AUTO} and
     *  {@link IkeSessionParams.ESP_ENCAP_TYPE_AUTO} for ESP packets.
@@ -3643,11 +3645,11 @@ public class Vpn {

            final int natKeepalive =
                    carrierConfig.getInt(KEY_MIN_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT);
            final int preferredIpPortocol =
                    carrierConfig.getInt(KEY_PREFERRED_IKE_PROTOCOL_INT);
            final int preferredIpProtocol = carrierConfig.getInt(
                    KEY_PREFERRED_IKE_PROTOCOL_INT, PREFERRED_IKE_PROTOCOL_UNKNOWN);
            final String mccMnc = perSubTm.getSimOperator(subId);
            final CarrierConfigInfo info =
                    buildCarrierConfigInfo(mccMnc, natKeepalive, preferredIpPortocol);
                    buildCarrierConfigInfo(mccMnc, natKeepalive, preferredIpProtocol);
            synchronized (Vpn.this) {
                mCachedCarrierConfigInfoPerSubId.put(subId, info);
            }