diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-13 00:55:10 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-13 00:55:10 +0000 |
commit | 583b3c48399265c7ed42b95f791bd9298a4c6fda (patch) | |
tree | 93e6ebbe6153c49923202c1052b6d884fefdd1f0 | |
parent | 52e57657fad12d9902f98c2a8a8ba9eaa4f10b5e (diff) | |
parent | 6eff9a2004de6dd76b20755f4f08dc0b811d0230 (diff) | |
download | cts-aml_ips_340914280.tar.gz |
Snap for 10486386 from 6eff9a2004de6dd76b20755f4f08dc0b811d0230 to mainline-ipsec-releaseaml_ips_340914280aml_ips_340914200aml_ips_340914000
Change-Id: I12a10c37b42d7f36e670c4da25380bc26264a417
15 files changed, 273 insertions, 149 deletions
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java index b318d55480e..e1223580811 100644 --- a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java +++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java @@ -26,6 +26,7 @@ import com.android.tradefed.testtype.junit4.AfterClassWithInfo; import com.android.tradefed.testtype.junit4.BeforeClassWithInfo; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -45,6 +46,7 @@ import java.util.Map; * <p>Unlock your device when test locally. */ @RunWith(DeviceJUnit4ClassRunner.class) +@Ignore("b/290690596 Re-enable tests after fixing flaky behavior.") public class AppSearchMultiUserTest extends AppSearchHostTestBase { private static int sInitialUserId; diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java index e9b29936f82..ecf488a0982 100644 --- a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java +++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java @@ -23,6 +23,7 @@ import com.android.tradefed.util.RunUtil; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,6 +40,7 @@ import org.junit.runner.RunWith; * <p>Unlock your device when test locally. */ @RunWith(DeviceJUnit4ClassRunner.class) +@Ignore("b/290690596 Re-enable tests after fixing flaky behavior.") public class AppSearchPackageTest extends AppSearchHostTestBase { private int mPrimaryUserId; diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java index 245f0c0ac4a..1e667679a4f 100644 --- a/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java +++ b/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java @@ -39,6 +39,8 @@ import java.util.Collections; * <p>Unlock your device when testing locally. */ @RunWith(DeviceJUnit4ClassRunner.class) +@Ignore("b/285969557 Re-enable tests after figuring out a better way to wait for lifecycle " + + "events to complete") public class ContactsIndexerMultiUserTest extends AppSearchHostTestBase { private static int sSecondaryUserId; @@ -90,9 +92,6 @@ public class ContactsIndexerMultiUserTest extends AppSearchHostTestBase { } @Test - @Ignore - // TODO(b/285969557) Re-enable test after figuring out a better way to wait for lifecycle events - // to complete public void testMultiUser_CiDisabled_cancelsFullUpdateJobs() throws Exception { setCiEnabled(getDevice(), false); startUserAndInstallPackage(); @@ -102,9 +101,6 @@ public class ContactsIndexerMultiUserTest extends AppSearchHostTestBase { } @Test - @Ignore - // TODO(b/285969557) Re-enable test after figuring out a better way to wait for lifecycle events - // to complete public void testMultiUser_CiDisabledAndThenEnabled_schedulesFullUpdateJobs() throws Exception { setCiEnabled(getDevice(), false); setCiEnabled(getDevice(), true); diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java index a31088616c3..466060d1e23 100644 --- a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java +++ b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java @@ -18,6 +18,8 @@ package com.android.cts.documentclient; import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION; +import static android.os.SystemClock.uptimeMillis; +import static android.text.format.DateUtils.SECOND_IN_MILLIS; import android.app.Activity; import android.content.ContentResolver; @@ -42,7 +44,6 @@ import android.support.test.uiautomator.UiScrollable; import android.support.test.uiautomator.UiSelector; import android.test.MoreAsserts; import android.text.TextUtils; -import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -78,29 +79,52 @@ public class DocumentsClientTest extends DocumentsClientTestCase { private static final Duration SCROLL_ACKNOWLEDGEMENT_TIMEOUT = Duration.ofMillis(500); private long mOriginalScrollAcknowledgementTimeout; - private UiSelector findRootListSelector() throws UiObjectNotFoundException { + private UiSelector findRootListSelector() { return new UiSelector().resourceId( getDocumentsUiPackageId() + ":id/container_roots").childSelector( new UiSelector().resourceId(getDocumentsUiPackageId() + ":id/roots_list")); } - private void revealRoot(UiSelector rootsList, String label) throws UiObjectNotFoundException { - // We might need to expand drawer if not visible - if (!new UiObject(rootsList).waitForExists(TIMEOUT)) { - Log.d(TAG, "Failed to find roots list; trying to expand"); - final UiSelector hamburger = new UiSelector().resourceId( - getDocumentsUiPackageId() + ":id/toolbar").childSelector( - new UiSelector().className("android.widget.ImageButton").clickable(true)); - new UiObject(hamburger).click(); - } + private UiSelector toolbarSelector() { + return new UiSelector().resourceId(getDocumentsUiPackageId() + ":id/toolbar"); + } - // Wait for the first list item to appear - assertTrue("First list item", - new UiObject(rootsList.childSelector(new UiSelector())).waitForExists(TIMEOUT)); + private UiSelector hamburgerButtonSelector() { + return toolbarSelector().childSelector( + new UiSelector().className("android.widget.ImageButton").clickable(true)); + } + + private void revealRoot(UiSelector rootsListSelector, String label) + throws UiObjectNotFoundException { + waitForRootList(rootsListSelector); // Now scroll around to find our item - new UiScrollable(rootsList).scrollIntoView(new UiSelector().text(label)); + new UiScrollable(rootsListSelector).scrollIntoView(new UiSelector().text(label)); + } + + + private void waitForRootList(UiSelector rootsListSelector) throws UiObjectNotFoundException { + final UiObject rootList = new UiObject(rootsListSelector); + final UiObject hamburgerBtn = new UiObject(hamburgerButtonSelector()); + boolean hamburgerBtnClicked = false; + + final long startMills = uptimeMillis(); + while (!rootList.waitForExists(SECOND_IN_MILLIS)) { + if (uptimeMillis() - startMills > TIMEOUT) break; + + // We could not find the root list, this might be because the drawer is not visible. + // See if the drawer opening hamburger button exists, and if so click on it. + if (!hamburgerBtnClicked && hamburgerBtn.exists()) { + hamburgerBtn.click(); + hamburgerBtnClicked = true; + } + } + + // Wait for the first list item to appear + assertTrue("Could not find any items in the root list", + new UiObject(rootsListSelector.childSelector(new UiSelector())) + .waitForExists(TIMEOUT - (uptimeMillis() - startMills))); } private UiObject findSearchViewTextField() { @@ -175,13 +199,12 @@ public class DocumentsClientTest extends DocumentsClientTestCase { .childSelector(new UiSelector().resourceId("android:id/button1"))); } - private UiObject findPositiveButton() throws UiObjectNotFoundException { + private UiObject findPositiveButton() { return new UiObject(new UiSelector().resourceId("android:id/button1")); } - private boolean checkToolbarTitleEquals(String label) throws UiObjectNotFoundException { - final UiObject title = new UiObject(new UiSelector().resourceId( - getDocumentsUiPackageId() + ":id/toolbar").childSelector( + private boolean checkToolbarTitleEquals(String label) { + final UiObject title = new UiObject(toolbarSelector().childSelector( new UiSelector().className("android.widget.TextView").text(label))); return title.waitForExists(TIMEOUT); diff --git a/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java b/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java index 9c4d411ef5c..315a1dc0145 100644 --- a/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java +++ b/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java @@ -122,6 +122,7 @@ public class PhotoPickerBannersTest extends PhotoPickerBaseTest { } @Test + @Ignore("b/290892213") public void testChooseAppBannerOnDismiss() throws Exception { // 1. Setting up the 'Choose App' banner. setCloudMediaInfoForChooseAppBanner(); diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java index 3feb8230713..e114da5d817 100644 --- a/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java +++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java @@ -279,9 +279,12 @@ public class FullScreenMagnificationGestureHandlerTest { dispatch(doubleTap(mTapLocation)); mTouchListener.assertPropagated(ACTION_DOWN, ACTION_UP, ACTION_DOWN, ACTION_UP); + // Smaller display devices does not have much screen space in Zoomed state + PackageManager pm = mInstrumentation.getTargetContext().getPackageManager(); + int y = (pm.hasSystemFeature(pm.FEATURE_WATCH)) ? 5 : 29; dispatch(swipe( mTapLocation, - add(mTapLocation, 0, 29))); + add(mTapLocation, 0, y))); mTouchListener.assertPropagated(ACTION_DOWN, ACTION_MOVE, ACTION_UP); } diff --git a/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java index bab038cc97a..0e43f33592d 100644 --- a/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java +++ b/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java @@ -36,6 +36,7 @@ import static android.view.View.AUTOFILL_HINT_USERNAME; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertThrows; import static org.junit.Assume.assumeTrue; import android.autofillservice.cts.R; @@ -50,13 +51,16 @@ import android.autofillservice.cts.testcore.Helper; import android.autofillservice.cts.testcore.IdMode; import android.autofillservice.cts.testcore.InstrumentedAutoFillService.FillRequest; import android.content.Intent; +import android.graphics.drawable.Icon; import android.platform.test.annotations.FlakyTest; import android.util.Log; import android.view.View; +import android.widget.RemoteViews; import androidx.test.uiautomator.UiObject2; import com.android.compatibility.common.util.CddTest; +import com.android.compatibility.common.util.RetryableException; import org.junit.After; import org.junit.Test; @@ -977,6 +981,51 @@ public class LoginActivityTest extends AutoFillServiceTestCase.ManualActivityLau assertThat(v.isCredential()).isFalse(); } + @Test + public void remoteViews_doesNotSpillAcrossUsers() throws Exception { + enableFillDialogFeature(sContext); + enableService(); + + RemoteViews header = createPresentation("Dialog Header"); + RemoteViews dialogRv = createPresentation("Dialog Presentation"); + // bad url, should not be displayed + header.setImageViewIcon(R.id.icon, Icon.createWithContentUri( + "content://1000@com.android.contacts/display_photo/1")); + dialogRv.setImageViewIcon(R.id.icon, Icon.createWithContentUri( + "content://1000@com.android.contacts/display_photo/1")); + + // Set response with a dataset + final CannedFillResponse.Builder builder = new CannedFillResponse.Builder() + .addDataset(new CannedDataset.Builder() + .setField(ID_USERNAME, "dude") + .setField(ID_PASSWORD, "sweet") + .setPresentation(createPresentation("Dropdown Presentation")) + .setDialogPresentation(dialogRv) + .build()) + .setDialogHeader(header) + .setDialogTriggerIds(ID_PASSWORD); + sReplier.addResponse(builder.build()); + + // Start activity and autofill + LoginActivity activity = startLoginActivity(); + mUiBot.waitForIdleSync(); + + sReplier.getNextFillRequest(); + mUiBot.waitForIdleSync(); + + // Click on password field to trigger fill dialog + mUiBot.selectByRelativeId(ID_PASSWORD); + mUiBot.waitForIdleSync(); + + // Asserts that the header is not shown + assertThrows(RetryableException.class, + () -> mUiBot.findFillDialogHeaderPicker()); + + // Asserts that the + assertThrows(RetryableException.class, + () -> mUiBot.findFillDialogDatasetPicker()); + } + private FieldsNoPasswordActivity startNoPasswordActivity() throws Exception { final Intent intent = new Intent(mContext, FieldsNoPasswordActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java index 6e324034603..5d71d8c7fb1 100644 --- a/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java +++ b/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java @@ -75,6 +75,8 @@ import static com.android.compatibility.common.util.ShellUtils.tap; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static org.junit.Assert.assertThrows; + import android.app.PendingIntent; import android.app.assist.AssistStructure.ViewNode; import android.autofillservice.cts.R; @@ -104,6 +106,7 @@ import android.content.IntentFilter; import android.content.IntentSender; import android.graphics.Color; import android.graphics.Rect; +import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.SystemClock; import android.platform.test.annotations.AppModeFull; @@ -1468,6 +1471,46 @@ public class LoginActivityTest extends LoginActivityCommonTestCase { mActivity.assertAutoFilled(); } + @Test + public void remoteViews_doesNotSpillAcrossUsers() throws Exception { + // Set service. + enableService(); + + + RemoteViews firstRv = createPresentation("hello"); + RemoteViews secondRv = createPresentation("world"); + + // bad url, should not be displayed + firstRv.setImageViewIcon(R.id.icon, + Icon.createWithContentUri("content://1000@com.android.contacts/display_photo/1")); + secondRv.setImageViewIcon(R.id.icon, + Icon.createWithContentUri("content://1000@com.android.contacts/display_photo/1")); + + // Set expectations. + sReplier.addResponse(new CannedFillResponse.Builder() + .addDataset(new CannedDataset.Builder() + .setField(ID_USERNAME, "dude", firstRv) + .setField(ID_PASSWORD, "sweet", secondRv) + .build()) + .setHeader(firstRv) + .setFooter(secondRv) + .build()); + + mActivity.expectAutoFill("dude", "sweet"); + + // Trigger auto-fill. + requestFocusOnUsername(); + sReplier.getNextFillRequest(); + + // Asser that the dataset is not shown + assertThrows(RetryableException.class, + () -> mUiBot.assertDatasets("The Dude")); + + // Assert that header/footer is not shown + assertThrows(RetryableException.class, + () -> mUiBot.assertDatasetsWithBorders("hello", "world", "The Dude")); + } + /** * Tests the scenario where the service uses custom remote views for different fields (username * and password), but each dataset has a different number of fields. diff --git a/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java b/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java index ec19cf46b44..95a232a0717 100644 --- a/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java +++ b/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java @@ -1477,11 +1477,11 @@ public class UiBot { return waitForObject(FILL_DIALOG_SELECTOR, UI_DATASET_PICKER_TIMEOUT); } - private UiObject2 findFillDialogDatasetPicker() throws Exception { + public UiObject2 findFillDialogDatasetPicker() throws Exception { return waitForObject(FILL_DIALOG_DATASET_SELECTOR, UI_DATASET_PICKER_TIMEOUT); } - private UiObject2 findFillDialogHeaderPicker() throws Exception { + public UiObject2 findFillDialogHeaderPicker() throws Exception { return waitForObject(FILL_DIALOG_HEADER_SELECTOR, UI_DATASET_PICKER_TIMEOUT); } diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java index 79f39ccd770..77d02a068bd 100644 --- a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java @@ -160,8 +160,10 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase public void setUpWindowInsetsAnimationControllerTests() throws Throwable { assumeFalse( "In Automotive, auxiliary inset changes can happen when IME inset changes, so " - + "allow Automotive skip IME inset animation tests.", - isCar() && mType == ime()); + + "allow Automotive skip IME inset animation tests." + + "And if config_remoteInsetsControllerControlsSystemBars is enabled," + + "SystemBar controls doesn't work, so allow skip inset animation tests.", + isCar() && (mType == ime() || remoteInsetsControllerControlsSystemBars())); assertEquals("Test precondition failed: ValueAnimator.getDurationScale()", 1f, ValueAnimator.getDurationScale(), 0.001); @@ -267,8 +269,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_andCancel() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { runOnUiThread(() -> { setupAnimationListener(); @@ -289,8 +289,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Test public void testControl_andImmediatelyCancel() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { runOnUiThread(() -> { setupAnimationListener(); @@ -308,8 +306,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_immediately_show() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { setVisibilityAndWait(mType, false); @@ -333,8 +329,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_immediately_hide() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { setVisibilityAndWait(mType, true); @@ -358,8 +352,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_transition_show() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { setVisibilityAndWait(mType, false); @@ -381,8 +373,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_transition_hide() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { setVisibilityAndWait(mType, true); @@ -404,8 +394,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_transition_show_interpolator() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { mInterpolator = new DecelerateInterpolator(); setVisibilityAndWait(mType, false); @@ -428,8 +416,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Presubmit @Test public void testControl_transition_hide_interpolator() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { mInterpolator = new AccelerateInterpolator(); setVisibilityAndWait(mType, true); @@ -451,8 +437,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase @Test public void testControl_andLoseControl() throws Throwable { - assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime()); - retryIfCancelled(() -> { mInterpolator = new AccelerateInterpolator(); setVisibilityAndWait(mType, true); diff --git a/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java b/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java index 91219651a4b..593d3c98624 100644 --- a/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java +++ b/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java @@ -271,7 +271,9 @@ public class CtsSharesheetDeviceTest { // Note: EII and ECT cap is not tested here showsExtraInitialIntents(); - showsExtraChooserTargets(); + if (!mActivityManager.isLowRamDevice()) { + showsExtraChooserTargets(); + } isSharingShortcutDirectShareEnabled(); }, () -> { @@ -659,6 +661,10 @@ public class CtsSharesheetDeviceTest { @Test @ApiTest(apis = "android.content.Intent#EXTRA_CHOOSER_TARGETS") public void testChooserTargets() throws Throwable { + assumeFalse( + "EXTRA_CHOOSER_TARGETS not required on low RAM devices", + mActivityManager.isLowRamDevice()); + final CountDownLatch appStarted = new CountDownLatch(1); final AtomicReference<Intent> targetLaunchIntent = new AtomicReference<>(); @@ -698,6 +704,10 @@ public class CtsSharesheetDeviceTest { @Test @ApiTest(apis = "android.content.Intent#EXTRA_CHOOSER_TARGETS") public void testChooserTargetsRefinement() throws Throwable { + assumeFalse( + "EXTRA_CHOOSER_TARGETS not required on low RAM devices", + mActivityManager.isLowRamDevice()); + final CountDownLatch broadcastInvoked = new CountDownLatch(1); final CountDownLatch appStarted = new CountDownLatch(1); final AtomicReference<Intent> targetLaunchIntent = new AtomicReference<>(); diff --git a/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java index 9dd00fb6b02..74fdf642e09 100644 --- a/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java +++ b/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java @@ -73,6 +73,7 @@ import androidx.test.filters.SdkSuppress; import androidx.test.platform.app.InstrumentationRegistry; import com.android.compatibility.common.util.ApiLevelUtil; +import com.android.compatibility.common.util.ApiTest; import com.android.compatibility.common.util.ShellIdentityUtils; import java.util.ArrayDeque; @@ -1121,7 +1122,9 @@ public class SingleDeviceTest extends WifiJUnit3TestBase { * Validate successful suspend/resume with a publish session. */ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) - public void testSuspendResumeSuccessWithPublishSession() { + @ApiTest(apis = {"android.net.wifi.aware.DiscoverySession#suspend", + "android.net.wifi.aware.DiscoverySession#resume"}) + public void testSuspendResumeFailWithoutNdpOnPublishSession() { if (!TestUtils.shouldTestWifiAware(getContext())) { return; } @@ -1155,18 +1158,12 @@ public class SingleDeviceTest extends WifiJUnit3TestBase { // 2. suspend discoverySession.suspend(); - assertTrue("Publish session suspended", - discoveryCb.waitForCallback( - DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_SUCCEEDED)); - assertFalse(discoveryCb.waitForCallback( + assertTrue(discoveryCb.waitForCallback( DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_FAILED)); // 3. resume discoverySession.resume(); - assertTrue("Publish session resumed", - discoveryCb.waitForCallback( - DiscoverySessionCallbackTest.ON_SESSION_RESUME_SUCCEEDED)); - assertFalse(discoveryCb.waitForCallback( + assertTrue(discoveryCb.waitForCallback( DiscoverySessionCallbackTest.ON_SESSION_RESUME_FAILED)); // 4. destroy @@ -1422,7 +1419,9 @@ public class SingleDeviceTest extends WifiJUnit3TestBase { * Validate successful suspend/resume with a subscribe session. */ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) - public void testSuspendResumeSuccessWithSubscribeSession() { + @ApiTest(apis = {"android.net.wifi.aware.DiscoverySession#suspend", + "android.net.wifi.aware.DiscoverySession#resume"}) + public void testSuspendResumeFailWithoutNdpOnSubscribeSession() { if (!TestUtils.shouldTestWifiAware(getContext())) { return; } @@ -1457,18 +1456,12 @@ public class SingleDeviceTest extends WifiJUnit3TestBase { // 2. suspend discoverySession.suspend(); - assertTrue("Subscribe session suspended", - discoveryCb.waitForCallback( - DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_SUCCEEDED)); - assertFalse(discoveryCb.waitForCallback( + assertTrue(discoveryCb.waitForCallback( DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_FAILED)); // 3. resume discoverySession.resume(); - assertTrue("Subscribe session resumed", - discoveryCb.waitForCallback( - DiscoverySessionCallbackTest.ON_SESSION_RESUME_SUCCEEDED)); - assertFalse(discoveryCb.waitForCallback( + assertTrue(discoveryCb.waitForCallback( DiscoverySessionCallbackTest.ON_SESSION_RESUME_FAILED)); // 4. destroy diff --git a/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java index 02128cedf6c..d6a89f1daae 100644 --- a/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java +++ b/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java @@ -74,8 +74,9 @@ import com.android.compatibility.common.util.ShellIdentityUtils; import com.google.common.collect.Range; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -96,81 +97,93 @@ import java.util.concurrent.TimeUnit; @LargeTest @RunWith(AndroidJUnit4.class) public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { - private Context mContext; - private WifiManager mWifiManager; - private ConnectivityManager mConnectivityManager; - private UiDevice mUiDevice; - private TestHelper mTestHelper; - private TelephonyManager mTelephonyManager; + private static Context sContext; + private static WifiManager sWifiManager; + private static ConnectivityManager sConnectivityManager; + private static UiDevice sUiDevice; + private static TestHelper sTestHelper; + private static TelephonyManager sTelephonyManager; - private boolean mWasVerboseLoggingEnabled; + private static boolean sWasVerboseLoggingEnabled; private static final int WIFI_CONNECT_TIMEOUT_MILLIS = 30_000; private static final int TIMEOUT = 12_000; private static final int WAIT_DURATION = 5_000; - @Before - public void setUp() throws Exception { - mContext = InstrumentationRegistry.getInstrumentation().getContext(); + private static boolean sShouldRunTest = false; + private static boolean sWasScanThrottleEnabled; - // skip the test if WiFi is not supported - assumeTrue(WifiFeature.isWifiSupported(mContext)); + @BeforeClass + public static void setUpClass() throws Exception { + sContext = InstrumentationRegistry.getInstrumentation().getContext(); + + if (!WifiFeature.isWifiSupported(sContext)) { + return; + } + sShouldRunTest = true; - mWifiManager = mContext.getSystemService(WifiManager.class); - assertThat(mWifiManager).isNotNull(); + sWifiManager = sContext.getSystemService(WifiManager.class); + assertThat(sWifiManager).isNotNull(); // Location mode must be enabled, otherwise the connection info will be redacted. - assertThat(Objects.requireNonNull(mContext.getSystemService(LocationManager.class)) + assertThat(Objects.requireNonNull(sContext.getSystemService(LocationManager.class)) .isLocationEnabled()).isTrue(); - mConnectivityManager = mContext.getSystemService(ConnectivityManager.class); + sConnectivityManager = sContext.getSystemService(ConnectivityManager.class); // turn on verbose logging for tests - mWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions( - () -> mWifiManager.isVerboseLoggingEnabled()); + sWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions( + () -> sWifiManager.isVerboseLoggingEnabled()); + ShellIdentityUtils.invokeWithShellPermissions( + () -> sWifiManager.setVerboseLoggingEnabled(true)); + sWasScanThrottleEnabled = ShellIdentityUtils.invokeWithShellPermissions( + () -> sWifiManager.isScanThrottleEnabled()); ShellIdentityUtils.invokeWithShellPermissions( - () -> mWifiManager.setVerboseLoggingEnabled(true)); + () -> sWifiManager.setScanThrottleEnabled(false)); // enable Wifi - if (!mWifiManager.isWifiEnabled()) { - ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.setWifiEnabled(true)); + if (!sWifiManager.isWifiEnabled()) { + ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(true)); } - PollingCheck.check("Wifi not enabled", TIMEOUT, () -> mWifiManager.isWifiEnabled()); + PollingCheck.check("Wifi not enabled", TIMEOUT, () -> sWifiManager.isWifiEnabled()); // turn screen on - mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); + sUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); - mTestHelper = new TestHelper(mContext, mUiDevice); - mTestHelper.turnScreenOn(); - - // Clear any existing app state before each test. - if (WifiBuildCompat.isPlatformOrWifiModuleAtLeastS(mContext)) { - ShellIdentityUtils.invokeWithShellPermissions( - () -> mWifiManager.removeAppState(myUid(), mContext.getPackageName())); - } + sTestHelper = new TestHelper(sContext, sUiDevice); + sTestHelper.turnScreenOn(); // check we have >= 1 saved network List<WifiConfiguration> savedNetworks = ShellIdentityUtils.invokeWithShellPermissions( - () -> mWifiManager.getConfiguredNetworks()); + () -> sWifiManager.getConfiguredNetworks()); assertWithMessage("Need at least one saved network").that(savedNetworks).isNotEmpty(); + sTelephonyManager = sContext.getSystemService(TelephonyManager.class); + } + @Before + public void setUp() throws Exception { + assumeTrue(sShouldRunTest); + // Clear any existing app state before each test. + ShellIdentityUtils.invokeWithShellPermissions( + () -> sWifiManager.removeAppState(myUid(), sContext.getPackageName())); // ensure Wifi is connected - ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.reconnect()); + ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.reconnect()); PollingCheck.check( "Wifi not connected", WIFI_CONNECT_TIMEOUT_MILLIS, - () -> mWifiManager.getConnectionInfo().getNetworkId() != -1); - mTelephonyManager = mContext.getSystemService(TelephonyManager.class); + () -> sWifiManager.getConnectionInfo().getNetworkId() != -1); } - @After - public void tearDown() throws Exception { - if (!WifiFeature.isWifiSupported(mContext)) return; - if (!mWifiManager.isWifiEnabled()) { - ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.setWifiEnabled(true)); + @AfterClass + public static void tearDownClass() throws Exception { + if (!sShouldRunTest) return; + if (!sWifiManager.isWifiEnabled()) { + ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(true)); } - mTestHelper.turnScreenOff(); + sTestHelper.turnScreenOff(); + ShellIdentityUtils.invokeWithShellPermissions( + () -> sWifiManager.setVerboseLoggingEnabled(sWasVerboseLoggingEnabled)); ShellIdentityUtils.invokeWithShellPermissions( - () -> mWifiManager.setVerboseLoggingEnabled(mWasVerboseLoggingEnabled)); + () -> sWifiManager.setScanThrottleEnabled(sWasScanThrottleEnabled)); } private static class TestUsabilityStatsListener implements @@ -210,7 +223,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { new TestUsabilityStatsListener(countDownLatch); try { uiAutomation.adoptShellPermissionIdentity(); - mWifiManager.addOnWifiUsabilityStatsListener( + sWifiManager.addOnWifiUsabilityStatsListener( Executors.newSingleThreadExecutor(), usabilityStatsListener); // Wait for new usability stats (while connected & screen on this is triggered // by platform periodically). @@ -226,7 +239,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { assertThat(statsEntry.getTotalTxRetries()).isAtLeast(0L); assertThat(statsEntry.getTotalTxBad()).isAtLeast(0L); assertThat(statsEntry.getTotalRxSuccess()).isAtLeast(0L); - if (mWifiManager.isEnhancedPowerReportingSupported()) { + if (sWifiManager.isEnhancedPowerReportingSupported()) { assertThat(statsEntry.getTotalRadioOnTimeMillis()).isAtLeast(0L); assertThat(statsEntry.getTotalRadioTxTimeMillis()).isAtLeast(0L); assertThat(statsEntry.getTotalRadioRxTimeMillis()).isAtLeast(0L); @@ -296,9 +309,9 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { assertEquals(10, contentionStats.getContentionNumSamples()); // Note that -1 is also a possible returned value for utilization ratio. assertThat(statsEntry.getChannelUtilizationRatio()).isIn(Range.closed(-1, 255)); - if (mTelephonyManager != null) { + if (sTelephonyManager != null) { boolean isCellularDataAvailable = - mTelephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED; + sTelephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED; assertEquals(isCellularDataAvailable, statsEntry.isCellularDataAvailable()); } else { assertFalse(statsEntry.isCellularDataAvailable()); @@ -466,7 +479,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { assertThat(statsEntry.isSameRegisteredCell()).isFalse(); } } finally { - mWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener); + sWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener); uiAutomation.dropShellPermissionIdentity(); } } @@ -480,7 +493,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { try { uiAutomation.adoptShellPermissionIdentity(); // update scoring with dummy values. - mWifiManager.updateWifiUsabilityScore(0, 50, 50); + sWifiManager.updateWifiUsabilityScore(0, 50, 50); } finally { uiAutomation.dropShellPermissionIdentity(); } @@ -495,7 +508,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation(); try { uiAutomation.adoptShellPermissionIdentity(); - assertTrue(mWifiManager.setWifiScoringEnabled(true)); + assertTrue(sWifiManager.setWifiScoringEnabled(true)); } finally { uiAutomation.dropShellPermissionIdentity(); } @@ -629,10 +642,10 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { try { uiAutomation.adoptShellPermissionIdentity(); // Clear any external scorer already active on the device. - mWifiManager.clearWifiConnectedNetworkScorer(); + sWifiManager.clearWifiConnectedNetworkScorer(); Thread.sleep(500); - mWifiManager.setWifiConnectedNetworkScorer( + sWifiManager.setWifiConnectedNetworkScorer( Executors.newSingleThreadExecutor(), connectedNetworkScorer); // Since we're already connected, wait for onStart to be invoked. assertThat(countDownLatchScorer.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue(); @@ -647,7 +660,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { scoreUpdateObserver.notifyScoreUpdate(connectedNetworkScorer.startSessionId, 50); // Register the usability listener - mWifiManager.addOnWifiUsabilityStatsListener( + sWifiManager.addOnWifiUsabilityStatsListener( Executors.newSingleThreadExecutor(), usabilityStatsListener); // Trigger a usability stats update. scoreUpdateObserver.triggerUpdateOfWifiUsabilityStats( @@ -669,12 +682,12 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { scoreUpdateObserver.blocklistCurrentBssid(-1); } // Now disconnect from the network. - mWifiManager.disconnect(); + sWifiManager.disconnect(); // Wait for it to be disconnected. PollingCheck.check( "Wifi not disconnected", TIMEOUT, - () -> mWifiManager.getConnectionInfo().getNetworkId() == -1); + () -> sWifiManager.getConnectionInfo().getNetworkId() == -1); disconnected = true; // Wait for stop to be invoked and ensure that the session id matches. @@ -691,16 +704,16 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { connectedNetworkScorer.onStop(200); assertEquals(200, connectedNetworkScorer.stopSessionId.intValue()); } finally { - mWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener); - mWifiManager.clearWifiConnectedNetworkScorer(); + sWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener); + sWifiManager.clearWifiConnectedNetworkScorer(); if (disconnected) { - mWifiManager.reconnect(); + sWifiManager.reconnect(); // Wait for it to be reconnected. PollingCheck.check( "Wifi not reconnected", WIFI_CONNECT_TIMEOUT_MILLIS, - () -> mWifiManager.getConnectionInfo().getNetworkId() != -1); + () -> sWifiManager.getConnectionInfo().getNetworkId() != -1); } uiAutomation.dropShellPermissionIdentity(); } @@ -721,10 +734,10 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { try { uiAutomation.adoptShellPermissionIdentity(); // Clear any external scorer already active on the device. - mWifiManager.clearWifiConnectedNetworkScorer(); + sWifiManager.clearWifiConnectedNetworkScorer(); Thread.sleep(500); - mWifiManager.setWifiConnectedNetworkScorer( + sWifiManager.setWifiConnectedNetworkScorer( Executors.newSingleThreadExecutor(), connectedNetworkScorer); // Since we're already connected, wait for onStart to be invoked. assertThat(countDownLatchScorer.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue(); @@ -740,7 +753,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { connectedNetworkScorer.resetCountDownLatch(countDownLatchScorer); // Restart wifi subsystem. - mWifiManager.restartWifiSubsystem(); + sWifiManager.restartWifiSubsystem(); // wait for scorer to stop session due to network disconnection. assertThat(countDownLatchScorer.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue(); @@ -752,7 +765,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { PollingCheck.check( "Wifi not connected", WIFI_CONNECT_TIMEOUT_MILLIS * 2, - () -> mWifiManager.getConnectionInfo().getNetworkId() != -1); + () -> sWifiManager.getConnectionInfo().getNetworkId() != -1); // Followed by a new onStart() after the connection. // Note: There is a 5 second delay between stop/start when restartWifiSubsystem() is @@ -764,7 +777,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { assertThat(connectedNetworkScorer.scoreUpdateObserver).isSameInstanceAs( prevScoreUpdateObserver); } finally { - mWifiManager.clearWifiConnectedNetworkScorer(); + sWifiManager.clearWifiConnectedNetworkScorer(); uiAutomation.dropShellPermissionIdentity(); } } @@ -793,27 +806,27 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { READ_WIFI_CREDENTIAL); // Clear any external scorer already active on the device. - mWifiManager.clearWifiConnectedNetworkScorer(); + sWifiManager.clearWifiConnectedNetworkScorer(); Thread.sleep(500); - savedNetworks = mWifiManager.getPrivilegedConfiguredNetworks(); + savedNetworks = sWifiManager.getPrivilegedConfiguredNetworks(); WifiConfiguration testNetwork = - TestHelper.findMatchingSavedNetworksWithBssid(mWifiManager, savedNetworks, 1) + TestHelper.findMatchingSavedNetworksWithBssid(sWifiManager, savedNetworks, 1) .get(0); // Disconnect & disable auto-join on the saved network to prevent auto-connect from // interfering with the test. for (WifiConfiguration savedNetwork : savedNetworks) { - mWifiManager.disableNetwork(savedNetwork.networkId); + sWifiManager.disableNetwork(savedNetwork.networkId); } // Wait for Wifi to be disconnected. PollingCheck.check( "Wifi not disconnected", 20000, - () -> mWifiManager.getConnectionInfo().getNetworkId() == -1); + () -> sWifiManager.getConnectionInfo().getNetworkId() == -1); assertThat(testNetwork).isNotNull(); // Register the external scorer. - mWifiManager.setWifiConnectedNetworkScorer( + sWifiManager.setWifiConnectedNetworkScorer( Executors.newSingleThreadExecutor(), connectedNetworkScorer); // Now connect using the provided connection initiator @@ -824,7 +837,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { assertThat(connectedNetworkScorer.startSessionId).isNull(); // Now disconnect from the network. - mConnectivityManager.unregisterNetworkCallback(networkCallback); + sConnectivityManager.unregisterNetworkCallback(networkCallback); networkCallback = null; // We should not receive the stop either @@ -834,14 +847,14 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { assertThat(connectedNetworkScorer.stopSessionId).isNull(); } finally { executorService.shutdownNow(); - mWifiManager.clearWifiConnectedNetworkScorer(); + sWifiManager.clearWifiConnectedNetworkScorer(); if (networkCallback != null) { - mConnectivityManager.unregisterNetworkCallback(networkCallback); + sConnectivityManager.unregisterNetworkCallback(networkCallback); } // Re-enable the networks after the test. if (savedNetworks != null) { for (WifiConfiguration savedNetwork : savedNetworks) { - mWifiManager.enableNetwork(savedNetwork.networkId, false); + sWifiManager.enableNetwork(savedNetwork.networkId, false); } } uiAutomation.dropShellPermissionIdentity(); @@ -859,9 +872,9 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { // Connect using wifi network specifier. WifiNetworkSpecifier specifier = TestHelper.createSpecifierBuilderWithCredentialFromSavedNetwork( - testNetwork, false) + testNetwork, true) .build(); - return mTestHelper.testConnectionFlowWithSpecifierWithShellIdentity( + return sTestHelper.testConnectionFlowWithSpecifierWithShellIdentity( testNetwork, specifier, false); } ); @@ -882,7 +895,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { if (restrictedNetworkCapabilities.contains(NET_CAPABILITY_OEM_PRIVATE)) { suggestionBuilder.setOemPrivate(true); } - return mTestHelper.testConnectionFlowWithSuggestionWithShellIdentity( + return sTestHelper.testConnectionFlowWithSuggestionWithShellIdentity( testNetwork, suggestionBuilder.build(), executorService, restrictedNetworkCapabilities, false/* restrictedNetwork */); } @@ -930,8 +943,8 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { WifiSsid ssid = WifiSsid.fromBytes(new byte[]{0x12, 0x34, 0x56}); byte[] oui = new byte[]{0x00, 0x01, 0x02}; List<DhcpOption> options = new ArrayList<DhcpOption>(); - mWifiManager.addCustomDhcpOptions(ssid, oui, options); - mWifiManager.removeCustomDhcpOptions(ssid, oui); + sWifiManager.addCustomDhcpOptions(ssid, oui, options); + sWifiManager.removeCustomDhcpOptions(ssid, oui); } finally { uiAutomation.dropShellPermissionIdentity(); } @@ -950,7 +963,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase { WifiSsid ssid = WifiSsid.fromBytes(new byte[]{0x12, 0x34, 0x56}); byte[] oui = new byte[]{0x00, 0x01, 0x02}; List<DhcpOption> options = new ArrayList<DhcpOption>(); - mWifiManager.addCustomDhcpOptions(ssid, oui, options); + sWifiManager.addCustomDhcpOptions(ssid, oui, options); fail("Expected SecurityException"); } catch (SecurityException e) { // expected diff --git a/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java b/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java index 5d5e9bb6df7..fca2868830d 100644 --- a/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java +++ b/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java @@ -673,6 +673,7 @@ public class TestHelper { @Override public void onUserSelectionCallbackRegistration( WifiManager.NetworkRequestUserSelectionCallback userSelectionCallback) { + Log.d(TAG, "onUserSelectionCallbackRegistration"); synchronized (mLock) { onRegistrationCalled = true; this.userSelectionCallback = userSelectionCallback; @@ -682,6 +683,7 @@ public class TestHelper { @Override public void onAbort() { + Log.d(TAG, "onAbort"); synchronized (mLock) { onAbortCalled = true; mLock.notify(); @@ -690,6 +692,7 @@ public class TestHelper { @Override public void onMatch(List<ScanResult> scanResults) { + Log.d(TAG, "onMatch"); synchronized (mLock) { // This can be invoked multiple times. So, ignore after the first one to avoid // disturbing the rest of the test sequence. @@ -702,6 +705,7 @@ public class TestHelper { @Override public void onUserSelectionConnectSuccess(WifiConfiguration config) { + Log.d(TAG, "onUserSelectionConnectSuccess"); synchronized (mLock) { onConnectSuccessCalled = true; mLock.notify(); @@ -710,6 +714,7 @@ public class TestHelper { @Override public void onUserSelectionConnectFailure(WifiConfiguration config) { + Log.d(TAG, "onUserSelectionConnectFailure"); synchronized (mLock) { onConnectFailureCalled = true; mLock.notify(); @@ -821,6 +826,7 @@ public class TestHelper { Thread.sleep(1_000); // Start the UI interactions. uiThread.start(); + assertThat(localOnlyListener.await(DURATION_MILLIS)).isFalse(); // now wait for callback assertThat(testNetworkCallback.waitForAnyCallback(DURATION_NETWORK_CONNECTION_MILLIS)) .isTrue(); @@ -840,7 +846,6 @@ public class TestHelper { assertThat(wifiInfo.isPrimary()).isTrue(); } } - assertThat(localOnlyListener.await(DURATION_NETWORK_CONNECTION_MILLIS)).isFalse(); assertThat(localOnlyListener.onFailureCalled).isFalse(); } } catch (Throwable e /* catch assertions & exceptions */) { diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java index ece91c27238..0d3033b08f1 100644 --- a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java +++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java @@ -5935,7 +5935,7 @@ public class WifiManagerTest extends WifiJUnit4TestBase { try { uiAutomation.adoptShellPermissionIdentity(); boolean enabled = DeviceConfig.getBoolean(DEVICE_CONFIG_NAMESPACE, - "application_qos_policy_api_enabled", false); + "application_qos_policy_api_enabled", true); // If the feature flag is disabled, verify that all policies are rejected. if (!enabled) { |