Log all cross-profile intents that are handled badly.
When some intents are forwarded but should not be, or are not
forwarded but should be:
Instead of logging only one that has an issue, log all of them.
BUG:27240411
Change-Id: I11f910ef2882482273bb57e1a1b90c7e1eed0072
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
index 58a1fef..0cf58f7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
@@ -283,15 +283,9 @@
}
// Check for intents which can be forwarded to the managed profile.
- Intent intent = checkForIntentsNotHandled(forwardedIntentsFromPrimary,
- forwarderActivityInfo, true);
- if (intent != null) {
- Log.d(TAG, intent + " from primary profile should be forwarded to the " +
- "managed profile but is not.");
- return false;
- }
-
- return true;
+ return checkForIntentsNotHandled(forwardedIntentsFromPrimary,
+ forwarderActivityInfo, "from primary profile should be forwarded to the " +
+ "managed profile but is not.", true);
}
/**
@@ -307,25 +301,17 @@
return false;
}
+ boolean success = true;
// Check for intents which can be forwarded to the primary profile.
- Intent intent = checkForIntentsNotHandled(forwardedIntentsFromManaged,
- forwarderActivityInfo, true);
- if (intent != null) {
- Log.d(TAG, intent + " from managed profile should be forwarded to the " +
- "primary profile but is not.");
- return false;
- }
+ success &= checkForIntentsNotHandled(forwardedIntentsFromManaged,
+ forwarderActivityInfo, " from managed profile should be forwarded to the " +
+ "primary profile but is not.", true);
// Check for intents which cannot be forwarded to the primary profile.
- intent = checkForIntentsNotHandled(notForwardedIntentsFromManaged,
- forwarderActivityInfo, false);
- if (intent != null) {
- Log.d(TAG, intent + " from managed profile should not be forwarded to the " +
- "primary profile but it is.");
- return false;
- }
-
- return true;
+ success &= checkForIntentsNotHandled(notForwardedIntentsFromManaged,
+ forwarderActivityInfo, "from managed profile should not be forwarded to the " +
+ "primary profile but it is.", false);
+ return success;
}
/**
@@ -365,17 +351,18 @@
/**
* Checks if the intents passed are correctly handled.
- * @return {@code null} if all the intents are correctly handled
- * otherwise, the first intent in the list which is not handled correctly.
+ * @return {@code false} if at least one intent is not handled correctly.
*/
- private Intent checkForIntentsNotHandled(ArrayList<Intent> intentList,
- ActivityInfo expectedForwarderActivityInfo, boolean canResolve) {
+ private boolean checkForIntentsNotHandled(ArrayList<Intent> intentList,
+ ActivityInfo expectedForwarderActivityInfo, String errorMessage, boolean canResolve) {
+ boolean success = true;
for (Intent intent : intentList) {
if (canForwarderActivityHandleIntent(intent,
expectedForwarderActivityInfo) != canResolve) {
- return intent;
+ Log.e(TAG, intent + " " + errorMessage);
+ success = false;
}
}
- return null;
+ return success;
}
}