Merge "fix case test failure before secondary user is unlocked." into stage-aosp-rvc-ts-dev
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java
index fb25dd7..cf8fddf 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -16,7 +16,10 @@
package com.android.compatibility.common.util;
+import static org.junit.Assert.assertNotEquals;
+
import android.os.Build;
+import android.os.SystemProperties;
import androidx.test.InstrumentationRegistry;
@@ -41,7 +44,7 @@
private static final String BUILD_TYPE_PROPERTY = "ro.build.type";
private static final String MANUFACTURER_PROPERTY = "ro.product.manufacturer";
private static final String TAG_DEV_KEYS = "dev-keys";
- private static final String VNDK_VERSION = "ro.vndk.version";
+ private static final String VENDOR_SDK_VERSION = "ro.vendor.build.version.sdk";
public static final String GOOGLE_SETTINGS_QUERY =
"content query --uri content://com.google.settings/partner";
@@ -76,29 +79,25 @@
/**
* Return whether the SDK version of the vendor partiton is newer than the given API level.
- * If the property is set to non-integer value, this means the vendor partition is using
- * current API level and true is returned.
*/
public static boolean isVendorApiLevelNewerThan(int apiLevel) {
- int vendorApiLevel = getPropertyInt(VNDK_VERSION);
- if (vendorApiLevel == INT_VALUE_IF_UNSET) {
- return true;
- }
- return vendorApiLevel > apiLevel;
+ int vendorSdkVersion = SystemProperties.getInt(VENDOR_SDK_VERSION, 0);
+
+ assertNotEquals(0, vendorSdkVersion);
+
+ return vendorSdkVersion > apiLevel;
}
/**
* Return whether the SDK version of the vendor partiton is same or newer than the
* given API level.
- * If the property is set to non-integer value, this means the vendor partition is using
- * current API level and true is returned.
*/
public static boolean isVendorApiLevelAtLeast(int apiLevel) {
- int vendorApiLevel = getPropertyInt(VNDK_VERSION);
- if (vendorApiLevel == INT_VALUE_IF_UNSET) {
- return true;
- }
- return vendorApiLevel >= apiLevel;
+ int vendorSdkVersion = SystemProperties.getInt(VENDOR_SDK_VERSION, 0);
+
+ assertNotEquals(0, vendorSdkVersion);
+
+ return vendorSdkVersion >= apiLevel;
}
/**
diff --git a/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java b/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
index 144e28e..f24075e 100644
--- a/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
+++ b/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
@@ -271,7 +271,7 @@
Log.e(TAG, "Could not enable bluetooth to trigger state reset");
return;
}
- sleep(2_000); // Wait for Bluetooth to fully turn on.
+ sleep(3_000); // Wait for Bluetooth to fully turn on.
writeSliceByBleScanStateChangedAtom(whatAtomId, uid, false, false, false);
writeSliceByBleScanStateChangedAtom(whatAtomId, uid, false, false, false);
writeSliceByBleScanStateChangedAtom(whatAtomId, uid, false, false, false);
diff --git a/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java b/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
index 2c8535d..2fb7916 100644
--- a/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
+++ b/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
@@ -50,6 +50,20 @@
*/
@RunWith(AndroidJUnit4.class)
public class AccessibilityServiceInfoTest {
+ private static final int FLAGS_MASK = AccessibilityServiceInfo.DEFAULT
+ | AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
+ | AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY
+ | AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS
+ | AccessibilityServiceInfo.FLAG_ENABLE_ACCESSIBILITY_VOLUME
+ | AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON
+ | AccessibilityServiceInfo.FLAG_REQUEST_FINGERPRINT_GESTURES
+ | AccessibilityServiceInfo.FLAG_SERVICE_HANDLES_DOUBLE_TAP
+ | AccessibilityServiceInfo.FLAG_REQUEST_MULTI_FINGER_GESTURES
+ | AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
+ | AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS
+ | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS
+ | AccessibilityServiceInfo.FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK;
+
private AccessibilityManager mAccessibilityManager;
private PackageManager mPackageManager;
@@ -102,13 +116,16 @@
final AccessibilityServiceInfo speakingService = enabledServices.get(0);
assertSame(AccessibilityEvent.TYPES_ALL_MASK, speakingService.eventTypes);
assertSame(AccessibilityServiceInfo.FEEDBACK_SPOKEN, speakingService.feedbackType);
- assertEquals(AccessibilityServiceInfo.DEFAULT
+
+ int serviceFlags = AccessibilityServiceInfo.DEFAULT
| AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
| AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
| AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS
| AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS
- | AccessibilityServiceInfo.FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK,
- speakingService.flags);
+ | AccessibilityServiceInfo.FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK;
+
+ assertEquals(speakingService.flags & FLAGS_MASK, serviceFlags);
+
assertSame(/* expected= */ 0l, speakingService.notificationTimeout);
assertEquals(/* expected= */ "Some description", speakingService.getDescription());
assertNull(speakingService.packageNames /*all packages*/);
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/utils/ActivityLaunchUtils.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/utils/ActivityLaunchUtils.java
index 44fd804..34b3fc8 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/utils/ActivityLaunchUtils.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/utils/ActivityLaunchUtils.java
@@ -279,8 +279,8 @@
AccessibilityNodeInfo node = event.getSource();
if (node != null) {
final AccessibilityWindowInfo window = node.getWindow();
- if(TextUtils.equals(activityTitle, window.getTitle())) {
- return true;
+ if(!TextUtils.equals(activityTitle, window.getTitle())) {
+ return false;
}
}
final AccessibilityWindowInfo window =
diff --git a/tests/autofillservice/src/android/autofillservice/cts/Helper.java b/tests/autofillservice/src/android/autofillservice/cts/Helper.java
index b3315fd..d71006e 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/Helper.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/Helper.java
@@ -88,6 +88,7 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
+import java.util.regex.Pattern;
/**
* Helper for common funcionalities.
@@ -234,6 +235,24 @@
}
/**
+ * Dumps the state of {@link android.service.autofill.InlineSuggestionRenderService}, and assert
+ * that it says the number of active inline suggestion views is the given number.
+ *
+ * <p>Note that ideally we should have a test api to fetch the number and verify against it.
+ * But at the time this test is added for Android 11, we have passed the deadline for adding
+ * the new test api, hence this approach.
+ */
+ public static void assertActiveViewCountFromInlineSuggestionRenderService(int count) {
+ String response = runShellCommand(
+ "dumpsys activity service .InlineSuggestionRenderService");
+ Log.d(TAG, "InlineSuggestionRenderService dump: " + response);
+ Pattern pattern = Pattern.compile(".*mActiveInlineSuggestions: " + count + ".*");
+ assertWithMessage("Expecting view count " + count
+ + ", but seeing different count from service dumpsys " + response).that(
+ pattern.matcher(response).find()).isTrue();
+ }
+
+ /**
* Sets whether the user completed the initial setup.
*/
public static void setUserComplete(Context context, boolean complete) {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
index eb18e96..3ca3f34 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
@@ -44,6 +44,7 @@
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
+import android.os.SystemClock;
import android.platform.test.annotations.AppModeFull;
import android.service.autofill.FillContext;
import android.support.test.uiautomator.Direction;
@@ -457,4 +458,59 @@
MOCK_IME_TIMEOUT_MS);
}
}
+
+ @Test
+ public void testInlineSuggestionViewReleased() throws Exception {
+ // Set service
+ enableService();
+
+ // Prepare the autofill response
+ final CannedFillResponse.Builder builder = new CannedFillResponse.Builder()
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setPresentation(createPresentation("The Username"))
+ .setInlinePresentation(createInlinePresentation("The Username"))
+ .build())
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation(createPresentation("The Password"))
+ .setInlinePresentation(createInlinePresentation("The Password"))
+ .build())
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField(ID_PASSWORD, "lollipop")
+ .setPresentation(createPresentation("The Password2"))
+ .setInlinePresentation(createInlinePresentation("The Password2"))
+ .build());
+ sReplier.addResponse(builder.build());
+
+ // Trigger auto-fill on username field
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdleSync();
+ mUiBot.assertDatasets("The Username");
+ Helper.assertActiveViewCountFromInlineSuggestionRenderService(1);
+
+ // Switch focus to password
+ mUiBot.selectByRelativeId(ID_PASSWORD);
+ mUiBot.waitForIdleSync();
+ mUiBot.assertDatasets("The Password", "The Password2");
+ Helper.assertActiveViewCountFromInlineSuggestionRenderService(2);
+
+ // Switch focus back to username
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdleSync();
+ mUiBot.assertDatasets("The Username");
+ Helper.assertActiveViewCountFromInlineSuggestionRenderService(1);
+
+ // Select the autofill suggestion on username, then check the results
+ mActivity.expectAutoFill("dude");
+ mUiBot.selectDataset("The Username");
+ mUiBot.waitForIdleSync();
+ mActivity.assertAutoFilled();
+ sReplier.getNextFillRequest();
+
+ // Sleep for a while for the wait in {@link com.android.server.autofill.ui
+ // .RemoteInlineSuggestionUi} to timeout.
+ SystemClock.sleep(500);
+ Helper.assertActiveViewCountFromInlineSuggestionRenderService(0);
+ }
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/PerformanceTest.java b/tests/camera/src/android/hardware/camera2/cts/PerformanceTest.java
index 4a02036..954a0f6 100644
--- a/tests/camera/src/android/hardware/camera2/cts/PerformanceTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/PerformanceTest.java
@@ -94,6 +94,7 @@
private static final int WAIT_FOR_RESULT_TIMEOUT_MS = 3000;
private static final int NUM_RESULTS_WAIT_TIMEOUT = 100;
private static final int NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY = 8;
+ private static final long FRAME_DURATION_NS_30FPS = 33333333L;
private DeviceReportLog mReportLog;
@@ -183,7 +184,7 @@
// Blocking start preview (start preview to first image arrives)
SimpleCaptureCallback resultListener =
new SimpleCaptureCallback();
- blockingStartPreview(resultListener, imageListener);
+ blockingStartPreview(id, resultListener, imageListener);
previewStartedTimeMs = SystemClock.elapsedRealtime();
startPreviewTimes[i] = previewStartedTimeMs - configureTimeMs;
cameraLaunchTimes[i] = previewStartedTimeMs - startTimeMs;
@@ -378,7 +379,7 @@
imageListeners[j] = new SimpleImageListener();
}
- readers = prepareStillCaptureAndStartPreview(previewBuilder, captureBuilder,
+ readers = prepareStillCaptureAndStartPreview(id, previewBuilder, captureBuilder,
mTestRule.getOrderedPreviewSizes().get(0), imageSizes, formats,
previewResultListener, NUM_MAX_IMAGES, imageListeners,
false /*isHeic*/);
@@ -1151,14 +1152,18 @@
BlockingSessionCallback.SESSION_CLOSED, CameraTestUtils.SESSION_CLOSE_TIMEOUT_MS);
}
- private void blockingStartPreview(CaptureCallback listener, SimpleImageListener imageListener)
- throws Exception {
+ private void blockingStartPreview(String id, CaptureCallback listener,
+ SimpleImageListener imageListener) throws Exception {
if (mPreviewSurface == null || mTestRule.getReaderSurface() == null) {
throw new IllegalStateException("preview and reader surface must be initilized first");
}
CaptureRequest.Builder previewBuilder =
mTestRule.getCamera().createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ Range<Integer> targetRange =
+ CameraTestUtils.getSuitableFpsRangeForDuration(id,
+ FRAME_DURATION_NS_30FPS, mTestRule.getStaticInfo());
+ previewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, targetRange);
if (mTestRule.getStaticInfo().isColorOutputSupported()) {
previewBuilder.addTarget(mPreviewSurface);
}
@@ -1171,6 +1176,7 @@
/**
* Setup still capture configuration and start preview.
*
+ * @param id The camera id under test
* @param previewRequest The capture request to be used for preview
* @param stillRequest The capture request to be used for still capture
* @param previewSz Preview size
@@ -1181,7 +1187,7 @@
* @param imageListeners The single capture capture image listeners
* @param isHeic Capture HEIC image if true, JPEG image if false
*/
- private ImageReader[] prepareStillCaptureAndStartPreview(
+ private ImageReader[] prepareStillCaptureAndStartPreview(String id,
CaptureRequest.Builder previewRequest, CaptureRequest.Builder stillRequest,
Size previewSz, Size[] captureSizes, int[] formats, CaptureCallback resultListener,
int maxNumImages, ImageReader.OnImageAvailableListener[] imageListeners,
@@ -1202,15 +1208,31 @@
// Update preview size.
updatePreviewSurface(previewSz);
+ StreamConfigurationMap config =
+ mTestRule.getStaticInfo().getCharacteristics().get(
+ CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
ImageReader[] readers = new ImageReader[captureSizes.length];
List<Surface> outputSurfaces = new ArrayList<Surface>();
outputSurfaces.add(mPreviewSurface);
+ long minFrameDuration = FRAME_DURATION_NS_30FPS;
for (int i = 0; i < captureSizes.length; i++) {
+ long minFrameDurationForCapture =
+ config.getOutputMinFrameDuration(formats[i], captureSizes[i]);
+ if (minFrameDurationForCapture > minFrameDuration) {
+ minFrameDuration = minFrameDurationForCapture;
+ }
readers[i] = CameraTestUtils.makeImageReader(captureSizes[i], formats[i], maxNumImages,
imageListeners[i], mTestRule.getHandler());
outputSurfaces.add(readers[i].getSurface());
}
+ // Update target fps based on min frame durations
+ Range<Integer> targetRange =
+ CameraTestUtils.getSuitableFpsRangeForDuration(id,
+ minFrameDuration, mTestRule.getStaticInfo());
+ previewRequest.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, targetRange);
+ stillRequest.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, targetRange);
+
mTestRule.setCameraSessionListener(new BlockingSessionCallback());
mTestRule.setCameraSession(CameraTestUtils.configureCameraSession(
mTestRule.getCamera(), outputSurfaces,
diff --git a/tests/location/location_gnss/src/android/location/cts/gnss/GnssPseudorangeVerificationTest.java b/tests/location/location_gnss/src/android/location/cts/gnss/GnssPseudorangeVerificationTest.java
index d1cca19..4438304 100644
--- a/tests/location/location_gnss/src/android/location/cts/gnss/GnssPseudorangeVerificationTest.java
+++ b/tests/location/location_gnss/src/android/location/cts/gnss/GnssPseudorangeVerificationTest.java
@@ -39,6 +39,8 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
+import androidx.test.filters.RequiresDevice;
+
/**
* Test computing and verifying the pseudoranges based on the raw measurements
* reported by the GNSS chipset
@@ -251,6 +253,7 @@
*/
@CddTest(requirement = "7.3.3")
@AppModeFull(reason = "Flaky in instant mode")
+ @RequiresDevice // emulated devices do not support real measurements so far.
public void testPseudoPosition() throws Exception {
// Checks if Gnss hardware feature is present, skips test (pass) if not
if (!TestMeasurementUtil.canTestRunOnCurrentDevice(Build.VERSION_CODES.N,
diff --git a/tests/tests/jni/Android.bp b/tests/tests/jni/Android.bp
index 386b2ae..74e5426 100644
--- a/tests/tests/jni/Android.bp
+++ b/tests/tests/jni/Android.bp
@@ -27,6 +27,7 @@
static_libs: [
"ctstestrunner-axt",
"androidx.test.rules",
+ "compatibility-device-util-axt",
],
jni_libs: [
"libjni_test_dlclose",
diff --git a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
index 4742796b..e2bbcd7 100644
--- a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
@@ -16,7 +16,9 @@
package android.jni.cts;
+import android.os.Build;
import android.os.Process;
+import com.android.compatibility.common.util.PropertyUtil;
import java.io.File;
import java.io.IOException;
@@ -317,9 +319,11 @@
* dlopen(3) any of the public lib via file name (non-absolute path) should succeed.
*/
public void test_dlopenPublicLibraries() {
- String error = LinkerNamespacesHelper.runDlopenPublicLibraries();
- if (error != null) {
- fail(error);
+ if (PropertyUtil.isVendorApiLevelAtLeast(Build.VERSION_CODES.R)) {
+ String error = LinkerNamespacesHelper.runDlopenPublicLibraries();
+ if (error != null) {
+ fail(error);
+ }
}
}
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
index 55ba086..2ca4099 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
@@ -780,6 +780,7 @@
case 2:
case 3:
case 4:
+ case 41:
assertThat(teeEnforcedDigests, is(expectedDigests));
break;
@@ -808,8 +809,8 @@
@SuppressWarnings("unchecked")
private void checkAttestationSecurityLevelDependentParams(Attestation attestation) {
- assertThat("Attestation version must be 1, 2, or 3", attestation.getAttestationVersion(),
- either(is(1)).or(is(2)).or(is(3)));
+ assertThat("Attestation version must be 1, 2, 3, or 4", attestation.getAttestationVersion(),
+ either(is(1)).or(is(2)).or(is(3)).or(is(4)));
AuthorizationList teeEnforced = attestation.getTeeEnforced();
AuthorizationList softwareEnforced = attestation.getSoftwareEnforced();
diff --git a/tests/tests/permission/src/android/permission/cts/UndefinedGroupPermissionTest.kt b/tests/tests/permission/src/android/permission/cts/UndefinedGroupPermissionTest.kt
index ba9212b..d293c70 100644
--- a/tests/tests/permission/src/android/permission/cts/UndefinedGroupPermissionTest.kt
+++ b/tests/tests/permission/src/android/permission/cts/UndefinedGroupPermissionTest.kt
@@ -25,6 +25,7 @@
import android.os.Process
import android.support.test.uiautomator.By
import android.support.test.uiautomator.UiDevice
+import android.support.test.uiautomator.UiObject2
import android.support.test.uiautomator.UiObjectNotFoundException
import androidx.test.platform.app.InstrumentationRegistry
import com.android.compatibility.common.util.SystemUtil
@@ -34,6 +35,7 @@
import org.junit.Assert
import org.junit.Before
import org.junit.Test
+import java.util.regex.Pattern
/**
* Tests that the permissioncontroller behaves normally when an app defines a permission in the
@@ -44,11 +46,12 @@
private var mUiDevice: UiDevice? = null
private var mContext: Context? = null
private var mPm: PackageManager? = null
+ private var mAllowButtonText: Pattern? = null
@Before
fun install() {
SystemUtil.runShellCommand("pm install -r " +
- "$TEST_APP_DEFINES_UNDEFINED_PERMISSION_GROUP_ELEMENT_APK")
+ TEST_APP_DEFINES_UNDEFINED_PERMISSION_GROUP_ELEMENT_APK)
}
@Before
@@ -57,6 +60,14 @@
mUiDevice = UiDevice.getInstance(mInstrumentation)
mContext = mInstrumentation?.targetContext
mPm = mContext?.packageManager
+ val permissionControllerResources = mContext?.createPackageContext(
+ mContext?.packageManager?.permissionControllerPackageName, 0)?.resources
+ mAllowButtonText = Pattern.compile(
+ Pattern.quote(requireNotNull(permissionControllerResources?.getString(
+ permissionControllerResources.getIdentifier(
+ "grant_dialog_button_allow", "string",
+ "com.android.permissioncontroller")))),
+ Pattern.CASE_INSENSITIVE or Pattern.UNICODE_CASE)
}
@Before
@@ -94,9 +105,7 @@
eventually {
startRequestActivity(arrayOf(TEST))
mUiDevice!!.waitForIdle()
- waitFindObject(By.res(
- "com.android.permissioncontroller:id/permission_allow_button"),
- 100).click()
+ findAllowButton().click()
}
eventually {
Assert.assertEquals(mPm!!.checkPermission(CAMERA, APP_PKG_NAME),
@@ -113,6 +122,17 @@
SystemUtil.runShellCommand("pm uninstall $APP_PKG_NAME")
}
+ fun findAllowButton(): UiObject2 {
+ return if (mContext?.packageManager
+ ?.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) == true) {
+ waitFindObject(By.text(mAllowButtonText), 100)
+ } else {
+ waitFindObject(By.res(
+ "com.android.permissioncontroller:id/permission_allow_button"),
+ 100)
+ }
+ }
+
/**
* If app has one permission granted, then it can't grant itself another permission for free.
*/
@@ -131,7 +151,12 @@
startRequestActivity(arrayOf(targetPermission))
mUiDevice!!.waitForIdle()
try {
- waitFindObject(By.res("com.android.permissioncontroller:id/grant_dialog"), 100)
+ if (mContext?.packageManager
+ ?.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) == true) {
+ findAllowButton()
+ } else {
+ waitFindObject(By.res("com.android.permissioncontroller:id/grant_dialog"), 100)
+ }
} catch (e: UiObjectNotFoundException) {
Assert.assertEquals("grant dialog never showed.",
mPm!!.checkPermission(targetPermission,