Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95c870b3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add more logging when a package don't qualify for role."

parents 200dc55b 836f19df
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.provider.Settings;
import android.service.voice.VoiceInteractionService;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;

import androidx.annotation.NonNull;
@@ -49,6 +50,8 @@ import java.util.Set;
 */
public class AssistantRoleBehavior implements RoleBehavior {

    private static final String LOG_TAG = AssistantRoleBehavior.class.getSimpleName();

    private static final Intent ASSIST_SERVICE_PROBE =
            new Intent(VoiceInteractionService.SERVICE_INTERFACE);
    private static final Intent ASSIST_ACTIVITY_PROBE = new Intent(Intent.ACTION_ASSIST);
@@ -131,8 +134,16 @@ public class AssistantRoleBehavior implements RoleBehavior {
        }

        Intent pkgActivityProbe = new Intent(ASSIST_ACTIVITY_PROBE).setPackage(packageName);
        return !pm.queryIntentActivities(pkgActivityProbe,
        boolean hasAssistantActivity = !pm.queryIntentActivities(pkgActivityProbe,
                PackageManager.MATCH_DEFAULT_ONLY).isEmpty();

        if (!hasAssistantActivity) {
            Log.w(LOG_TAG, "Package " + packageName + " not qualified for " + role.getName()
                    + " due to " + (services.isEmpty() ? "missing service"
                    : "service without qualifying metadata") + " and missing activity");
        }

        return hasAssistantActivity;
    }

    private boolean isAssistantVoiceInteractionService(@NonNull PackageManager pm,
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class ExclusiveDefaultHolderMixin {
        }

        if (!role.isPackageQualified(packageName, context)) {
            Log.w(LOG_TAG, "Default holder does not qualify for the role, config: " + resourceName
                    + ", package: " + packageName);
            return null;
        }
        return packageName;