Prevent INTERACT_ACROSS_USERS exception in DefaultDialerManager.

When TelecomManager methods perform a read phonestate check from a work
profile user, it is possible to get an INTERACT_ACROSS_USERS exception.
This is due to the fact that the filterByIntent method was not calling
queryIntentActivitiesAsUser.

Test: Manual
Bug: 31304557
Merged-In: I6bc7419ba260050281d83e33f7f328ec5ccb3cd8
Change-Id: I2a1869162e5a52aed986a99cc378a6c630af4a70
This commit is contained in:
Tyler Gunn
2017-09-01 15:17:05 -07:00
parent 47b23176bd
commit 79e2bf90c3

View File

@@ -170,7 +170,7 @@ public class DefaultDialerManager {
final Intent dialIntentWithTelScheme = new Intent(Intent.ACTION_DIAL);
dialIntentWithTelScheme.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, "", null));
return filterByIntent(context, packageNames, dialIntentWithTelScheme);
return filterByIntent(context, packageNames, dialIntentWithTelScheme, userId);
}
public static List<String> getInstalledDialerApplications(Context context) {
@@ -204,17 +204,18 @@ public class DefaultDialerManager {
*
* @param context A valid context
* @param packageNames List of package names to filter.
* @param userId The UserId
* @return The filtered list.
*/
private static List<String> filterByIntent(Context context, List<String> packageNames,
Intent intent) {
Intent intent, int userId) {
if (packageNames == null || packageNames.isEmpty()) {
return new ArrayList<>();
}
final List<String> result = new ArrayList<>();
final List<ResolveInfo> resolveInfoList = context.getPackageManager()
.queryIntentActivities(intent, 0);
.queryIntentActivitiesAsUser(intent, 0, userId);
final int length = resolveInfoList.size();
for (int i = 0; i < length; i++) {
final ActivityInfo info = resolveInfoList.get(i).activityInfo;