Improved ServicePermissionsTest logging.
For example, this test pass in some devices because they throw a
DeadObjectException, even though the service is not checking the permission,
which makes it harder to debug issues on other devices.
Bug: 143966438
Test: atest CtsSecurityTestCases:android.security.cts.ServicePermissionsTest#testDumpProtected
Change-Id: I4c6313cbb88be3a17f8929e97657a5beee0aebe7
diff --git a/tests/tests/security/src/android/security/cts/ServicePermissionsTest.java b/tests/tests/security/src/android/security/cts/ServicePermissionsTest.java
index 60e27e6..bccbe59 100644
--- a/tests/tests/security/src/android/security/cts/ServicePermissionsTest.java
+++ b/tests/tests/security/src/android/security/cts/ServicePermissionsTest.java
@@ -107,6 +107,7 @@
} catch (SecurityException e) {
String msg = e.getMessage();
if ((msg == null) || msg.contains("android.permission.DUMP")) {
+ Log.d(TAG, "Service " + service + " correctly checked permission");
// Service correctly checked for DUMP permission, yay
} else {
// Service is throwing about something else; they're
@@ -115,7 +116,9 @@
continue;
}
} catch (TransactionTooLargeException | DeadObjectException e) {
- // SELinux likely prevented the dump - assume safe
+ // SELinux likely prevented the dump - assume safe, but log anywasy
+ // (as the exception might happens in some devices but not on others)
+ Log.w(TAG, "Service " + service + " threw exception: " + e);
continue;
} finally {
out.close();