Remove mContext from IpSecBaseTest
This commit removes the mContext from IpSecBaseTest, and replaces it with InstrumentationRegistry.getContext(). Bug: 72950854 Test: Ran on devices, passing. Change-Id: If6fa359825aa9d1f7d4c8d49aba7a34925c073ed
This commit is contained in:
@@ -76,11 +76,9 @@ public class IpSecBaseTest {
|
||||
|
||||
protected ConnectivityManager mCM;
|
||||
protected IpSecManager mISM;
|
||||
protected Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mContext = InstrumentationRegistry.getContext();
|
||||
mISM =
|
||||
(IpSecManager)
|
||||
InstrumentationRegistry.getContext()
|
||||
@@ -475,7 +473,7 @@ public class IpSecBaseTest {
|
||||
private IpSecTransform buildDefaultTransform(InetAddress localAddr) throws Exception {
|
||||
try (IpSecManager.SecurityParameterIndex spi =
|
||||
mISM.allocateSecurityParameterIndex(localAddr)) {
|
||||
return buildIpSecTransform(mContext, spi, null, localAddr);
|
||||
return buildIpSecTransform(InstrumentationRegistry.getContext(), spi, null, localAddr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -238,7 +239,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
mISM.allocateSecurityParameterIndex(localAddr);
|
||||
|
||||
IpSecTransform transform =
|
||||
new IpSecTransform.Builder(mContext)
|
||||
new IpSecTransform.Builder(InstrumentationRegistry.getContext())
|
||||
.setEncryption(new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY))
|
||||
.setAuthentication(
|
||||
new IpSecAlgorithm(
|
||||
@@ -456,7 +457,8 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
IpSecManager.SecurityParameterIndex spi =
|
||||
mISM.allocateSecurityParameterIndex(local)) {
|
||||
|
||||
IpSecTransform.Builder transformBuilder = new IpSecTransform.Builder(mContext);
|
||||
IpSecTransform.Builder transformBuilder =
|
||||
new IpSecTransform.Builder(InstrumentationRegistry.getContext());
|
||||
if (crypt != null) {
|
||||
transformBuilder.setEncryption(crypt);
|
||||
}
|
||||
@@ -617,7 +619,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
try (IpSecManager.SecurityParameterIndex spi =
|
||||
mISM.allocateSecurityParameterIndex(local);
|
||||
IpSecTransform transform =
|
||||
new IpSecTransform.Builder(mContext)
|
||||
new IpSecTransform.Builder(InstrumentationRegistry.getContext())
|
||||
.setEncryption(crypt)
|
||||
.setAuthentication(auth)
|
||||
.setIpv4Encapsulation(encapSocket, encapSocket.getPort())
|
||||
|
||||
Reference in New Issue
Block a user