summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-17 02:12:30 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-17 02:12:30 +0000
commitddc55773a0955607500408544b2026da80c23462 (patch)
tree91d3701e14d398f02328516a8ce608c88722b89c
parentbc1b4f2ffc0c7843983f1da15ddab05500d2e97a (diff)
parent88558244bfabba880d5dff50e9abf11a2d823b20 (diff)
downloadcts-android-mainline-12.0.0_r52.tar.gz
Snap for 7922329 from 88558244bfabba880d5dff50e9abf11a2d823b20 to mainline-resolv-releaseandroid-mainline-12.0.0_r52
Change-Id: I6197b4e14e0e53c9892101237eb0cfd55fa541f8
-rw-r--r--common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java7
-rw-r--r--common/device-side/util-axt/src/com/android/compatibility/common/util/MultiLogDevice.java47
-rw-r--r--tests/tests/role/src/android/app/role/cts/RoleManagerTest.java23
3 files changed, 20 insertions, 57 deletions
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java
index b0ec2e985bc..27d86b51a28 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java
@@ -18,6 +18,8 @@ package com.android.compatibility.common.util;
import static org.junit.Assert.assertTrue;
+import android.util.Log;
+
import org.junit.Before;
import java.util.List;
@@ -35,7 +37,7 @@ import java.util.List;
* Now Business Logics rules and actions can be called from the GCL by using the interface fully
* qualified name.
*/
-public abstract class ExtraBusinessLogicTestCase extends BusinessLogicTestCase implements MultiLogDevice {
+public abstract class ExtraBusinessLogicTestCase extends BusinessLogicTestCase {
private static final String LOG_TAG = BusinessLogicTestCase.class.getSimpleName();
@@ -52,7 +54,8 @@ public abstract class ExtraBusinessLogicTestCase extends BusinessLogicTestCase i
"Test \"%s\" is unable to execute as it depends on the missing remote "
+ "configuration.", mTestCase.getMethodName()), mCanReadBusinessLogic);
} else if (!mCanReadBusinessLogic) {
- logInfo(LOG_TAG, "Skipping Business Logic for %s", mTestCase.getMethodName());
+ Log.i(LOG_TAG, String.format(
+ "Skipping Business Logic for %s", mTestCase.getMethodName()));
return;
}
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/MultiLogDevice.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/MultiLogDevice.java
deleted file mode 100644
index dbe5128b7b1..00000000000
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/MultiLogDevice.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.compatibility.common.util;
-
-import android.util.Log;
-import com.android.compatibility.common.util.MultiLog;
-
-/** Implement the deviceside interface for logging on host+device-common code. */
-public interface MultiLogDevice extends MultiLog {
- /** {@inheritDoc} */
- @Override
- default void logInfo(String logTag, String format, Object... args) {
- Log.i(logTag, String.format(format, args));
- }
-
- /** {@inheritDoc} */
- @Override
- default void logDebug(String logTag, String format, Object... args) {
- Log.d(logTag, String.format(format, args));
- }
-
- /** {@inheritDoc} */
- @Override
- default void logWarn(String logTag, String format, Object... args) {
- Log.w(logTag, String.format(format, args));
- }
-
- /** {@inheritDoc} */
- @Override
- default void logError(String logTag, String format, Object... args) {
- Log.e(logTag, String.format(format, args));
- }
-}
diff --git a/tests/tests/role/src/android/app/role/cts/RoleManagerTest.java b/tests/tests/role/src/android/app/role/cts/RoleManagerTest.java
index 0b9f4d20963..b522f9550b9 100644
--- a/tests/tests/role/src/android/app/role/cts/RoleManagerTest.java
+++ b/tests/tests/role/src/android/app/role/cts/RoleManagerTest.java
@@ -138,8 +138,7 @@ public class RoleManagerTest {
@Before
public void saveRoleHolder() throws Exception {
- List<String> roleHolders = getRoleHolders(ROLE_NAME);
- mRoleHolder = !roleHolders.isEmpty() ? roleHolders.get(0) : null;
+ mRoleHolder = getRoleHolder(ROLE_NAME);
if (Objects.equals(mRoleHolder, APP_PACKAGE_NAME)) {
removeRoleHolder(ROLE_NAME, APP_PACKAGE_NAME);
@@ -915,7 +914,7 @@ public class RoleManagerTest {
public void removeSmsRoleHolderThenPermissionIsRevoked() throws Exception {
assumeTrue(sRoleManager.isRoleAvailable(RoleManager.ROLE_SMS));
- String smsRoleHolder = getRoleHolders(RoleManager.ROLE_SMS).get(0);
+ String smsRoleHolder = getRoleHolder(RoleManager.ROLE_SMS);
addRoleHolder(RoleManager.ROLE_SMS, APP_PACKAGE_NAME);
addRoleHolder(RoleManager.ROLE_SMS, smsRoleHolder);
@@ -929,7 +928,7 @@ public class RoleManagerTest {
&& sRoleManager.isRoleAvailable(RoleManager.ROLE_SMS));
addRoleHolder(RoleManager.ROLE_DIALER, APP_PACKAGE_NAME);
- String smsRoleHolder = getRoleHolders(RoleManager.ROLE_SMS).get(0);
+ String smsRoleHolder = getRoleHolder(RoleManager.ROLE_SMS);
addRoleHolder(RoleManager.ROLE_SMS, APP_PACKAGE_NAME);
addRoleHolder(RoleManager.ROLE_SMS, smsRoleHolder);
@@ -998,10 +997,12 @@ public class RoleManagerTest {
@Test
public void systemRoleDoesNotOverrideUserRevokedPermission() throws Exception {
assumeTrue(sRoleManager.isRoleAvailable(ROLE_SYSTEM_SPEECH_RECOGNIZER));
- String systemSpeechRecognizerPackageName = getRoleHolders(ROLE_SYSTEM_SPEECH_RECOGNIZER)
- .get(0);
- assertThat(sPackageManager.checkPermission(android.Manifest.permission.RECORD_AUDIO,
- systemSpeechRecognizerPackageName)).isEqualTo(PackageManager.PERMISSION_GRANTED);
+ String systemSpeechRecognizerPackageName = getRoleHolder(ROLE_SYSTEM_SPEECH_RECOGNIZER);
+ if (systemSpeechRecognizerPackageName != null) {
+ assertThat(sPackageManager.checkPermission(android.Manifest.permission.RECORD_AUDIO,
+ systemSpeechRecognizerPackageName))
+ .isEqualTo(PackageManager.PERMISSION_GRANTED);
+ }
assertThat(sPackageManager.checkPermission(android.Manifest.permission.RECORD_AUDIO,
APP_PACKAGE_NAME)).isEqualTo(PackageManager.PERMISSION_DENIED);
@@ -1025,6 +1026,12 @@ public class RoleManagerTest {
return callWithShellPermissionIdentity(() -> sRoleManager.getRoleHolders(roleName));
}
+ @Nullable
+ private String getRoleHolder(@NonNull String roleName) throws Exception {
+ List<String> roleHolders = getRoleHolders(roleName);
+ return !roleHolders.isEmpty() ? roleHolders.get(0) : null;
+ }
+
private void assertIsRoleHolder(@NonNull String roleName, @NonNull String packageName,
boolean shouldBeRoleHolder) throws Exception {
List<String> packageNames = getRoleHolders(roleName);