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

Commit 0346207e authored by Yan Yan's avatar Yan Yan
Browse files

Check the existence of IpSecTransformState API with try catch

IpSecTransformState is a new API that exposed from a mainline module.
Ideally before SDK finalization, platform should check the API flag
com.android.net.flags.ipsec_transform_state before calling the API.
However the flag is defined in mainline module is not accessible from
the platform. Thus previously a placeholder flag was used.

This patch removes the usage of the placeholder flag. Instead the
code will check the availability of the API with a try catch block

Bug: 328844044
Test: atest FrameworksVcnTests && atest CtsVcnTestCases
Flag: NONE mainline API flag not accessible; using try catch
      block to gate the behavior
Change-Id: Ibbcb14817a6d714cdc99cf0894f1fc935a602a2c
parent 52bd4f13
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.vcn;

import android.annotation.NonNull;
import android.content.Context;
import android.net.IpSecTransformState;
import android.net.vcn.FeatureFlags;
import android.net.vcn.FeatureFlagsImpl;
import android.os.Looper;
@@ -34,7 +35,6 @@ public class VcnContext {
    @NonNull private final Looper mLooper;
    @NonNull private final VcnNetworkProvider mVcnNetworkProvider;
    @NonNull private final FeatureFlags mFeatureFlags;
    @NonNull private final android.net.platform.flags.FeatureFlags mCoreNetFeatureFlags;
    private final boolean mIsInTestMode;

    public VcnContext(
@@ -49,7 +49,6 @@ public class VcnContext {

        // Auto-generated class
        mFeatureFlags = new FeatureFlagsImpl();
        mCoreNetFeatureFlags = new android.net.platform.flags.FeatureFlagsImpl();
    }

    @NonNull
@@ -76,7 +75,16 @@ public class VcnContext {
    }

    public boolean isFlagIpSecTransformStateEnabled() {
        return mCoreNetFeatureFlags.ipsecTransformState();
        // TODO: b/328844044: Ideally this code should gate the behavior by checking the
        // android.net.platform.flags.ipsec_transform_state 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
        try {
            new IpSecTransformState.Builder();
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    @NonNull
+0 −1
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ public abstract class NetworkEvaluationTestBase {
    @Mock protected Context mContext;
    @Mock protected Network mNetwork;
    @Mock protected FeatureFlags mFeatureFlags;
    @Mock protected android.net.platform.flags.FeatureFlags mCoreNetFeatureFlags;
    @Mock protected TelephonySubscriptionSnapshot mSubscriptionSnapshot;
    @Mock protected ConnectivityManager mConnectivityManager;
    @Mock protected TelephonyManager mTelephonyManager;