resolver: get custom resolver activity
The cts case gets the custom ResolverActivity name with the command
'pm resolve-activity -a android.intent.action.SEND --brief'.
However, if another application exists that responds to the SEND intent
and has the tag Intent.CATEGORY_DEFAULT, the result of the command is
wrong and will not be a custom ResolverActivity. To fix this, instead
use the 'cmd overlay lookup android
android:string/config_customResolverActivity' command, which gets the
field config_customResolverActivity from the resource to get the
custom ResolverActivity name.
Test: run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.ManagedProfileTest#testResolverActivityLaunchedFromWorkProfileWithSelectedPersonalTab
Test: run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.ManagedProfileTest#testResolverActivityLaunchedFromPersonalProfileWithSelectedWorkTab
Bug: 263829609
Change-Id: I4664db81064ec9348c7a931b946912e904154d0e
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index aa94006..52e4cbb 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -599,7 +599,7 @@
assertActivityInForeground("android/com.android.internal.app.ResolverActivity", userId);
} catch (AssertionError e) {
CLog.v("ResolverActivity is not the default: " + e);
- assertActivityInForeground(resolveActivity("android.intent.action.SEND"), userId);
+ assertActivityInForeground(getCustomResolverActivity(), userId);
}
}
@@ -644,4 +644,16 @@
return outputs[1];
}
+
+ private String getCustomResolverActivity() throws Exception {
+ final String[] outputs = getDevice().executeShellCommand(
+ "cmd overlay lookup android android:string/config_customResolverActivity")
+ .split("\n");
+
+ String customResolverActivity = resolveActivity("android.intent.action.SEND");
+ if (outputs != null && outputs.length >= 1 && outputs[0] != null && !outputs[0].isEmpty()) {
+ customResolverActivity = outputs[0];
+ }
+ return customResolverActivity;
+ }
}