[test] Fix deadlock in AvfIntegrationTest

This cl resolves the deadlock issue in issue in
AvfIntegrationTest that arises from the timeout
handling of the AndroidJUnit4 test runner. The
presence of the timeout causes the test setup and
the test method to be executed on different threads,
resulting in the test becoming stuck.

To fix this, this cl uses the BlockJUnit4ClassRunner
and JUnit's Timeout rule to ensure that the test
setup and test method are executed on the same thread.

Bug: 335627002
Test: atest AvfRkpdAppIntegrationTests
Change-Id: I42833f6a45bb8da84db2a35c50878137dbed139a
diff --git a/app/tests/avf/src/com/android/avf/rkpdapp/e2etest/AvfIntegrationTest.java b/app/tests/avf/src/com/android/avf/rkpdapp/e2etest/AvfIntegrationTest.java
index 103a4b0..19c88c8 100644
--- a/app/tests/avf/src/com/android/avf/rkpdapp/e2etest/AvfIntegrationTest.java
+++ b/app/tests/avf/src/com/android/avf/rkpdapp/e2etest/AvfIntegrationTest.java
@@ -24,7 +24,6 @@
 import android.os.Process;
 import android.os.SystemProperties;
 
-import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.work.ListenableWorker;
 import androidx.work.testing.TestWorkerBuilder;
 
@@ -43,8 +42,11 @@
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.Timeout;
 import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
 
 import java.security.cert.X509Certificate;
 import java.time.Instant;
@@ -60,7 +62,7 @@
  * - Have the RKP server hostname configured in the device. If not, you can set it using:
  * $ adb shell setprop remote_provisioning.hostname remoteprovisioning.googleapis.com
  */
-@RunWith(AndroidJUnit4.class)
+@RunWith(BlockJUnit4ClassRunner.class)
 public class AvfIntegrationTest extends MicrodroidDeviceTestBase {
     private static final String SERVICE_NAME = IRemotelyProvisionedComponent.DESCRIPTOR + "/avf";
 
@@ -68,6 +70,8 @@
     private PeriodicProvisioner mProvisioner;
     private AutoCloseable mPeriodicProvisionerLock;
 
+    @Rule public final Timeout mTimeout = Timeout.seconds(30);
+
     @Before
     public void setUp() throws Exception {
         assume().withMessage("AVF key provisioning is not supported on CF.")