Merge "DO NOT MERGE: Use a frozen version of ion.h."
diff --git a/hostsidetests/jvmti/attaching/app/jni/Android.mk b/hostsidetests/jvmti/attaching/app/jni/Android.mk
index 554fccf..a2c1db6 100644
--- a/hostsidetests/jvmti/attaching/app/jni/Android.mk
+++ b/hostsidetests/jvmti/attaching/app/jni/Android.mk
@@ -27,14 +27,15 @@
LOCAL_HEADER_LIBRARIES := libopenjdkjvmti_headers
LOCAL_SHARED_LIBRARIES := liblog \
- libdl
+ libdl \
+ libz
# The test implementation. We get this provided by ART.
# Note: Needs to be "whole" as this exposes JNI functions.
LOCAL_WHOLE_STATIC_LIBRARIES := libctstiagent
# Platform libraries that may not be available to apps. Link in statically.
-LOCAL_STATIC_LIBRARIES += libbase libcutils libutils
+LOCAL_STATIC_LIBRARIES += libbase_ndk
LOCAL_STRIP_MODULE := keep_symbols
@@ -58,6 +59,7 @@
-g \
-O0 \
-LOCAL_CXX_STL := libc++_static
+LOCAL_SDK_VERSION := current
+LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/jvmti/base/jni/Android.mk b/hostsidetests/jvmti/base/jni/Android.mk
index 0ed5327..8ecf315 100644
--- a/hostsidetests/jvmti/base/jni/Android.mk
+++ b/hostsidetests/jvmti/base/jni/Android.mk
@@ -36,14 +36,15 @@
LOCAL_HEADER_LIBRARIES := libopenjdkjvmti_headers
LOCAL_SHARED_LIBRARIES := liblog \
- libdl
+ libdl \
+ libz
# The test implementation. We get this provided by ART.
# Note: Needs to be "whole" as this exposes JNI functions.
LOCAL_WHOLE_STATIC_LIBRARIES := libctstiagent
# Platform libraries that may not be available to apps. Link in statically.
-LOCAL_STATIC_LIBRARIES += libbase libcutils libutils
+LOCAL_STATIC_LIBRARIES += libbase_ndk
LOCAL_STRIP_MODULE := keep_symbols
@@ -67,6 +68,7 @@
-g \
-O0 \
-LOCAL_CXX_STL := libc++_static
+LOCAL_SDK_VERSION := current
+LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
index 210fab8..0a39e03 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
@@ -15,6 +15,8 @@
*/
package android.autofillservice.cts;
+import static android.autofillservice.cts.Helper.runShellCommand;
+
import static com.google.common.truth.Truth.assertThat;
import android.app.Activity;
@@ -64,9 +66,11 @@
public final void testTapLink_changeOrientationThenTapBack() throws Exception {
sUiBot.setScreenOrientation(UiBot.PORTRAIT);
try {
+ runShellCommand("wm density 420");
saveUiRestoredAfterTappingLinkTest(
PostSaveLinkTappedAction.ROTATE_THEN_TAP_BACK_BUTTON);
} finally {
+ runShellCommand("wm density reset");
sUiBot.setScreenOrientation(UiBot.PORTRAIT);
}
}
@@ -84,6 +88,9 @@
protected abstract void saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction type)
throws Exception;
+ protected void cleanUpAfterScreenOrientationIsBackToPortrait() throws Exception {
+ }
+
/**
* Tests scenarios when user taps a link in the custom description, taps back to return to the
* activity with the Save UI, and touch outside the Save UI to dismiss it.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
index 8e4ec03..12ea855 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
@@ -518,6 +518,11 @@
}
@Override
+ protected void cleanUpAfterScreenOrientationIsBackToPortrait() throws Exception {
+ sReplier.getNextFillRequest();
+ }
+
+ @Override
protected void tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction action,
boolean manualRequest) throws Exception {
startActivity();
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
index d93d431..c9e0c56 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
@@ -211,7 +211,6 @@
}
public static boolean waitForUnBinding() {
- sServiceUnBoundLatch = TestUtils.waitForLock(sServiceUnBoundLatch);
- return sServiceUnBoundLatch != null;
+ return TestUtils.waitForLatchCountDown(sServiceUnBoundLatch);
}
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
index b057648..e6070ce 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
@@ -198,7 +198,7 @@
* timeout expired without the lock being released.
*/
public boolean waitForUpdate(int lock) {
- mLocks[lock] = waitForLock(mLocks[lock]);
+ mLocks[lock] = TestUtils.waitForLock(mLocks[lock]);
return mLocks[lock] != null;
}
@@ -207,31 +207,7 @@
* @return {@code true} if binding happened within the time limit, or {@code false} otherwise.
*/
public static boolean waitForBinding() {
- sBindingLock = waitForLock(sBindingLock);
- return sBindingLock != null;
- }
-
- /**
- * Given a {@link CountDownLatch}, wait for the latch to reach zero for 5 seconds. If the lock
- * was released, return a new instance. Otherwise, return null to indicate that the timeout
- * expired without the lock being released.
- *
- * @param lock The lock to wait on.
- * @return {@code true} if the lock was released, and {@code false} if it failed to be released.
- */
- private static CountDownLatch waitForLock(CountDownLatch lock) {
- boolean success;
- try {
- success = lock.await(5000, TimeUnit.MILLISECONDS);
- } catch (InterruptedException ie) {
- return null;
- }
-
- if (success) {
- return new CountDownLatch(1);
- } else {
- return null;
- }
+ return TestUtils.waitForLatchCountDown(sBindingLock);
}
public TestUtils.InvokeCounter getOnCreateIncomingHandoverConnectionCounter() {
diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
index 3980f7f..31000de 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
@@ -255,17 +255,36 @@
}
}
- public static CountDownLatch waitForLock(CountDownLatch lock) {
- boolean success;
- try {
- if (lock == null) {
- return null;
- }
- success = lock.await(5000, TimeUnit.MILLISECONDS);
- } catch (InterruptedException ie) {
- return null;
+ /**
+ * Waits for the {@link CountDownLatch} to count down to 0 and then returns without reseting
+ * the latch.
+ * @param lock the latch that the system will wait on.
+ * @return true if the latch was released successfully, false if the latch timed out before
+ * resetting.
+ */
+ public static boolean waitForLatchCountDown(CountDownLatch lock) {
+ if (lock == null) {
+ return false;
}
+ boolean success;
+ try {
+ success = lock.await(5000, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException ie) {
+ return false;
+ }
+
+ return success;
+ }
+
+ /**
+ * Waits for the {@link CountDownLatch} to count down to 0 and then returns a new reset latch.
+ * @param lock The lock that will await a countDown to 0.
+ * @return a new reset {@link CountDownLatch} if the lock successfully counted down to 0 or
+ * null if the operation timed out.
+ */
+ public static CountDownLatch waitForLock(CountDownLatch lock) {
+ boolean success = waitForLatchCountDown(lock);
if (success) {
return new CountDownLatch(1);
} else {
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java
index 5089381..e6a97ed 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java
@@ -21,6 +21,7 @@
import android.os.Bundle;
import android.telephony.MbmsDownloadSession;
import android.telephony.cts.embmstestapp.CtsDownloadService;
+import android.telephony.mbms.DownloadRequest;
import android.telephony.mbms.MbmsDownloadReceiver;
import java.io.File;
@@ -29,14 +30,16 @@
public class MbmsDownloadFlowTest extends MbmsDownloadTestBase {
private File tempFileRootDir;
- private String tempFileRootDirPath;
+ private DownloadRequest testDownloadRequest;
@Override
public void setUp() throws Exception {
super.setUp();
+ testDownloadRequest = downloadRequestTemplate
+ .setAppIntent(new Intent(MbmsDownloadReceiverTest.APP_INTENT_ACTION))
+ .build();
tempFileRootDir = new File(mContext.getFilesDir(), "CtsTestDir");
tempFileRootDir.mkdir();
- tempFileRootDirPath = tempFileRootDir.getCanonicalPath();
mDownloadSession.setTempFileRootDirectory(tempFileRootDir);
}
@@ -49,15 +52,15 @@
public void testFileDownloadFlow() throws Exception {
MbmsDownloadReceiverTest.AppIntentCapture captor =
- new MbmsDownloadReceiverTest.AppIntentCapture(mContext, mCallbackHandler);
- mDownloadSession.download(MbmsDownloadReceiverTest.TEST_DOWNLOAD_REQUEST);
+ new MbmsDownloadReceiverTest.AppIntentCapture(mContext, mHandler);
+ mDownloadSession.download(testDownloadRequest);
mMiddlewareControl.actuallyStartDownloadFlow();
Intent downloadDoneIntent = captor.getIntent();
assertEquals(MbmsDownloadReceiverTest.APP_INTENT_ACTION, downloadDoneIntent.getAction());
assertEquals(MbmsDownloadSession.RESULT_SUCCESSFUL,
downloadDoneIntent.getIntExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT, -1));
- assertEquals(MbmsDownloadReceiverTest.TEST_DOWNLOAD_REQUEST,
+ assertEquals(testDownloadRequest,
downloadDoneIntent.getParcelableExtra(
MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST));
assertEquals(CtsDownloadService.FILE_INFO,
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java
index 0d88f13..8232271 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java
@@ -47,9 +47,6 @@
public static final String APP_INTENT_ACTION =
"android.telephony.embms.cts.ACTION_TEST_DOWNLOAD_COMPLETE";
- public static final DownloadRequest TEST_DOWNLOAD_REQUEST = DOWNLOAD_REQUEST_TEMPLATE
- .setAppIntent(new Intent(APP_INTENT_ACTION))
- .build();
public static class AppIntentCapture {
private final BlockingQueue<Intent> mReceivedIntent = new LinkedBlockingQueue<>();
@@ -82,10 +79,14 @@
private MbmsDownloadReceiver mReceiver;
private File tempFileRootDir;
private String tempFileRootDirPath;
+ private DownloadRequest testDownloadRequest;
@Override
public void setUp() throws Exception {
super.setUp();
+ testDownloadRequest = downloadRequestTemplate
+ .setAppIntent(new Intent(APP_INTENT_ACTION))
+ .build();
mReceiver = new MbmsDownloadReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL);
@@ -140,9 +141,9 @@
intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT,
MbmsDownloadSession.RESULT_CANCELLED);
intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST,
- TEST_DOWNLOAD_REQUEST);
+ testDownloadRequest);
- AppIntentCapture intentCaptor = new AppIntentCapture(mContext, mCallbackHandler);
+ AppIntentCapture intentCaptor = new AppIntentCapture(mContext, mHandler);
sendBroadcastAndValidate(intentForReceiverTest, MbmsDownloadReceiver.RESULT_OK);
Intent receivedIntent = intentCaptor.getIntent();
@@ -150,7 +151,7 @@
assertEquals(MbmsDownloadSession.RESULT_CANCELLED,
receivedIntent.getIntExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT, -1));
- assertEquals(TEST_DOWNLOAD_REQUEST,
+ assertEquals(testDownloadRequest,
receivedIntent.getParcelableExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST));
}
@@ -162,7 +163,7 @@
intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT,
MbmsDownloadSession.RESULT_SUCCESSFUL);
intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST,
- TEST_DOWNLOAD_REQUEST);
+ testDownloadRequest);
intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_FILE_INFO,
CtsDownloadService.FILE_INFO);
intentForReceiverTest.putExtra(VendorUtils.EXTRA_FINAL_URI,
@@ -230,7 +231,7 @@
receivedExtras.add(getResultExtras(true));
receivedCode.add(getResultCode());
}
- }, mCallbackHandler, -1, null, null);
+ }, mHandler, -1, null, null);
try {
assertEquals(expectedCode,
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java
index 29e70bb..5e70828 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java
@@ -33,7 +33,7 @@
public void testDuplicateSession() throws Exception {
try {
MbmsDownloadSession failure = MbmsDownloadSession.create(
- mContext, mCallback, mCallbackHandler);
+ mContext, mCallbackExecutor, mCallback);
fail("Duplicate create should've thrown an exception");
} catch (IllegalStateException e) {
// Succeed
@@ -139,7 +139,7 @@
}
public void testResetDownloadKnowledge() throws Exception {
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ DownloadRequest request = downloadRequestTemplate.build();
mDownloadSession.resetDownloadKnowledge(request);
List<Bundle> resetDownloadKnowledgeCalls =
@@ -150,7 +150,7 @@
}
public void testGetDownloadStatus() throws Exception {
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ DownloadRequest request = downloadRequestTemplate.build();
mDownloadSession.requestDownloadState(request, CtsDownloadService.FILE_INFO);
List<Bundle> getDownloadStatusCalls =
@@ -163,7 +163,7 @@
}
public void testCancelDownload() throws Exception {
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ DownloadRequest request = downloadRequestTemplate.build();
mDownloadSession.cancelDownload(request);
List<Bundle> cancelDownloadCalls =
@@ -174,7 +174,11 @@
}
public void testListPendingDownloads() throws Exception {
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.setAppIntent(new Intent()).build();
+ File tempFileRootDir = new File(mContext.getFilesDir(), "CtsTestDir");
+ tempFileRootDir.mkdir();
+ mDownloadSession.setTempFileRootDirectory(tempFileRootDir);
+
+ DownloadRequest request = downloadRequestTemplate.setAppIntent(new Intent()).build();
mDownloadSession.download(request);
List<DownloadRequest> downloads = mDownloadSession.listPendingDownloads();
@@ -194,14 +198,12 @@
assertNotSame(mDownloadSession.getTempFileRootDirectory(), tempFileDirName);
}
- public void testDownloadRequestOpacity() throws Exception {
+ public void testDownloadRequestSerialization() throws Exception {
Intent intent = new Intent("sample_intent_action");
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.setAppIntent(intent).build();
- DownloadRequest newRequest = new DownloadRequest.Builder(request.getSourceUri())
- .setServiceId(request.getFileServiceId())
- .setSubscriptionId(request.getSubscriptionId())
- .setOpaqueData(request.getOpaqueData())
- .build();
+ DownloadRequest request = downloadRequestTemplate.setAppIntent(intent).build();
+ DownloadRequest newRequest =
+ DownloadRequest.Builder.fromSerializedRequest(request.toByteArray())
+ .build();
assertEquals(request, newRequest);
}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java
index a5cc2d0..c01de7c 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java
@@ -83,8 +83,8 @@
public void testFullCallback() throws Exception {
int sampleInt = 10;
TestDSCallback callback = new TestDSCallback(DownloadStateCallback.ALL_UPDATES);
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
- mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+ DownloadRequest request = downloadRequestTemplate.build();
+ mDownloadSession.registerStateCallback(request, mCallbackExecutor, callback);
mMiddlewareControl.fireOnProgressUpdated(request, CtsDownloadService.FILE_INFO,
sampleInt, sampleInt, sampleInt, sampleInt);
SomeArgs progressArgs = callback.waitOnProgressUpdated(ASYNC_TIMEOUT);
@@ -104,8 +104,8 @@
public void testDeregistration() throws Exception {
TestDSCallback callback = new TestDSCallback(DownloadStateCallback.ALL_UPDATES);
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
- mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+ DownloadRequest request = downloadRequestTemplate.build();
+ mDownloadSession.registerStateCallback(request, mCallbackExecutor, callback);
mDownloadSession.unregisterStateCallback(request, callback);
mMiddlewareControl.fireOnStateUpdated(null, null, 0);
@@ -116,8 +116,8 @@
public void testCallbackFiltering1() throws Exception {
TestDSCallback callback = new TestDSCallback(DownloadStateCallback.PROGRESS_UPDATES);
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
- mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+ DownloadRequest request = downloadRequestTemplate.build();
+ mDownloadSession.registerStateCallback(request, mCallbackExecutor, callback);
mMiddlewareControl.fireOnStateUpdated(null, null, 0);
assertNull(callback.waitOnStateUpdated(SHORT_TIMEOUT));
@@ -127,8 +127,8 @@
public void testCallbackFiltering2() throws Exception {
TestDSCallback callback = new TestDSCallback(DownloadStateCallback.STATE_UPDATES);
- DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
- mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+ DownloadRequest request = downloadRequestTemplate.build();
+ mDownloadSession.registerStateCallback(request, mCallbackExecutor, callback);
mMiddlewareControl.fireOnStateUpdated(null, null, 0);
assertNotNull(callback.waitOnStateUpdated(SHORT_TIMEOUT));
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java
index 9da5f04..bde9de6 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
@@ -41,6 +42,7 @@
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -107,13 +109,12 @@
}
}
- static final DownloadRequest.Builder DOWNLOAD_REQUEST_TEMPLATE =
- new DownloadRequest.Builder(CtsDownloadService.DOWNLOAD_SOURCE_URI)
- .setServiceInfo(CtsDownloadService.FILE_SERVICE_INFO);
+ DownloadRequest.Builder downloadRequestTemplate;
Context mContext;
HandlerThread mHandlerThread;
- Handler mCallbackHandler;
+ Handler mHandler;
+ Executor mCallbackExecutor;
ICtsDownloadMiddlewareControl mMiddlewareControl;
MbmsDownloadSession mDownloadSession;
TestCallback mCallback = new TestCallback();
@@ -123,8 +124,16 @@
mContext = getInstrumentation().getContext();
mHandlerThread = new HandlerThread("EmbmsCtsTestWorker");
mHandlerThread.start();
- mCallbackHandler = new Handler(mHandlerThread.getLooper());
+ mHandler = new Handler(mHandlerThread.getLooper());
+ mCallbackExecutor = mHandler::post;
mCallback = new TestCallback();
+
+ File destinationDirectory = new File(mContext.getFilesDir(), "downloads");
+ destinationDirectory.mkdirs();
+ Uri destinationDirectoryUri = Uri.fromFile(destinationDirectory);
+ downloadRequestTemplate = new DownloadRequest.Builder(
+ CtsDownloadService.DOWNLOAD_SOURCE_URI, destinationDirectoryUri)
+ .setServiceInfo(CtsDownloadService.FILE_SERVICE_INFO);
getControlBinder();
setupDownloadSession();
}
@@ -138,7 +147,7 @@
private void setupDownloadSession() throws Exception {
mDownloadSession = MbmsDownloadSession.create(
- mContext, mCallback, mCallbackHandler);
+ mContext, mCallbackExecutor, mCallback);
assertNotNull(mDownloadSession);
assertTrue(mCallback.waitOnMiddlewareReady());
assertEquals(0, mCallback.getNumErrorCalls());
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java
index 42e5618..835a6e4 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java
@@ -127,7 +127,7 @@
public void testStartStreaming() throws Exception {
StreamingService streamingService = mStreamingSession.startStreaming(
CtsStreamingService .STREAMING_SERVICE_INFO,
- mStreamingServiceCallback, mCallbackHandler);
+ mCallbackExecutor, mStreamingServiceCallback);
assertNotNull(streamingService);
assertEquals(CtsStreamingService.STREAMING_SERVICE_INFO, streamingService.getInfo());
@@ -145,7 +145,7 @@
public void testGetPlaybackUri() throws Exception {
StreamingService streamingService = mStreamingSession.startStreaming(
CtsStreamingService .STREAMING_SERVICE_INFO,
- mStreamingServiceCallback, mCallbackHandler);
+ mCallbackExecutor, mStreamingServiceCallback);
assertEquals(CtsStreamingService.STREAMING_URI, streamingService.getPlaybackUri());
List<List<Object>> getPlaybackUriCalls =
@@ -158,8 +158,8 @@
public void testStopStreaming() throws Exception {
StreamingService streamingService = mStreamingSession.startStreaming(
CtsStreamingService .STREAMING_SERVICE_INFO,
- mStreamingServiceCallback, mCallbackHandler);
- streamingService.stopStreaming();
+ mCallbackExecutor, mStreamingServiceCallback);
+ streamingService.close();
List<List<Object>> stopStreamingCalls =
getMiddlewareCalls(CtsStreamingService.METHOD_STOP_STREAMING);
assertEquals(1, stopStreamingCalls.size());
@@ -170,7 +170,7 @@
public void testStreamingCallbacks() throws Exception {
mStreamingSession.startStreaming(
CtsStreamingService .STREAMING_SERVICE_INFO,
- mStreamingServiceCallback, mCallbackHandler);
+ mCallbackExecutor, mStreamingServiceCallback);
mMiddlewareControl.fireErrorOnStream(
MbmsErrors.StreamingErrors.ERROR_UNABLE_TO_START_SERVICE, "");
@@ -194,7 +194,7 @@
mMiddlewareControl.forceErrorCode(
MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE);
mStreamingSession.startStreaming(CtsStreamingService.STREAMING_SERVICE_INFO,
- mStreamingServiceCallback, mCallbackHandler);
+ mCallbackExecutor, mStreamingServiceCallback);
assertEquals(MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE,
mCallback.waitOnError().arg1);
}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java
index 92b3fc9..0aeb734 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java
@@ -29,7 +29,7 @@
public void testDuplicateSession() throws Exception {
try {
MbmsStreamingSession failure = MbmsStreamingSession.create(
- mContext, mCallback, mCallbackHandler);
+ mContext, mCallbackExecutor, mCallback);
fail("Duplicate create should've thrown an exception");
} catch (IllegalStateException e) {
// Succeed
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java
index e170998..e4bb27b 100644
--- a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java
@@ -21,6 +21,7 @@
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -87,7 +88,7 @@
Context mContext;
HandlerThread mHandlerThread;
- Handler mCallbackHandler;
+ Executor mCallbackExecutor;
ICtsStreamingMiddlewareControl mMiddlewareControl;
MbmsStreamingSession mStreamingSession;
TestCallback mCallback = new TestCallback();
@@ -97,7 +98,7 @@
mContext = getInstrumentation().getContext();
mHandlerThread = new HandlerThread("EmbmsCtsTestWorker");
mHandlerThread.start();
- mCallbackHandler = new Handler(mHandlerThread.getLooper());
+ mCallbackExecutor = (new Handler(mHandlerThread.getLooper()))::post;
mCallback = new TestCallback();
getControlBinder();
setupStreamingSession();
@@ -112,7 +113,7 @@
private void setupStreamingSession() throws Exception {
mStreamingSession = MbmsStreamingSession.create(
- mContext, mCallback, mCallbackHandler);
+ mContext, mCallbackExecutor, mCallback);
assertNotNull(mStreamingSession);
assertTrue(mCallback.waitOnMiddlewareReady());
assertEquals(0, mCallback.getNumErrorCalls());