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

Commit 01ac3d3a authored by Tony Mak's avatar Tony Mak Committed by android-build-merger
Browse files

Merge "Fix an issue that clicking on a smart action chip on keyguard ......

Merge "Fix an issue that clicking on a smart action chip on keyguard ... failed to launch app resolver when there are more than one app handlers." into qt-dev
am: 78a48f55

Change-Id: Ic7dd0c9f952e905c8f42001276f3def6e1797b70
parents 44149fc2 78a48f55
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -19,7 +19,9 @@ package android.view.textclassifier;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.Person;
import android.app.Person;
import android.app.RemoteAction;
import android.app.RemoteAction;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.Pair;
import android.util.Pair;
@@ -200,10 +202,12 @@ public final class ActionsSuggestionsHelper {
        if (remoteAction == null) {
        if (remoteAction == null) {
            return null;
            return null;
        }
        }
        Intent actionIntent = ExtrasUtils.getActionIntent(conversationAction.getExtras());
        ComponentName componentName = actionIntent.getComponent();
        // Action without a component name will be considered as from the same app.
        String packageName = componentName == null ? null : componentName.getPackageName();
        return new Pair<>(
        return new Pair<>(
                conversationAction.getAction().getTitle().toString(),
                conversationAction.getAction().getTitle().toString(), packageName);
                ExtrasUtils.getActionIntent(
                        conversationAction.getExtras()).getComponent().getPackageName());
    }
    }


    private static final class PersonEncoder {
    private static final class PersonEncoder {
+4 −2
Original line number Original line Diff line number Diff line
@@ -118,14 +118,16 @@ public final class LabeledIntent {
            return null;
            return null;
        }
        }
        Intent resolvedIntent = new Intent(intent);
        Intent resolvedIntent = new Intent(intent);
        resolvedIntent.setComponent(new ComponentName(packageName, className));
        resolvedIntent.putExtra(
        resolvedIntent.putExtra(
                TextClassifier.EXTRA_FROM_TEXT_CLASSIFIER,
                TextClassifier.EXTRA_FROM_TEXT_CLASSIFIER,
                getFromTextClassifierExtra(textLanguagesBundle));
                getFromTextClassifierExtra(textLanguagesBundle));

        boolean shouldShowIcon = false;
        boolean shouldShowIcon = false;
        Icon icon = null;
        Icon icon = null;
        if (!"android".equals(packageName)) {
        if (!"android".equals(packageName)) {
            // We only set the component name when the package name is not resolved to "android"
            // to workaround a bug that explicit intent with component name == ResolverActivity
            // can't be launched on keyguard.
            resolvedIntent.setComponent(new ComponentName(packageName, className));
            if (resolveInfo.activityInfo.getIconResource() != 0) {
            if (resolveInfo.activityInfo.getIconResource() != 0) {
                icon = Icon.createWithResource(
                icon = Icon.createWithResource(
                        packageName, resolveInfo.activityInfo.getIconResource());
                        packageName, resolveInfo.activityInfo.getIconResource());
+30 −0
Original line number Original line Diff line number Diff line
@@ -208,6 +208,36 @@ public class ActionsSuggestionsHelperTest {
        assertThat(conversationActions.get(2).getAction()).isNull();
        assertThat(conversationActions.get(2).getAction()).isNull();
    }
    }


    @Test
    public void testDeduplicateActions_nullComponent() {
        Bundle phoneExtras = new Bundle();
        Intent phoneIntent = new Intent(Intent.ACTION_DIAL);
        ExtrasUtils.putActionIntent(phoneExtras, phoneIntent);
        PendingIntent pendingIntent = PendingIntent.getActivity(
                InstrumentationRegistry.getTargetContext(),
                0,
                phoneIntent,
                0);
        Icon icon = Icon.createWithData(new byte[0], 0, 0);
        ConversationAction action =
                new ConversationAction.Builder(ConversationAction.TYPE_CALL_PHONE)
                        .setAction(new RemoteAction(icon, "label", "1", pendingIntent))
                        .setExtras(phoneExtras)
                        .build();
        ConversationAction actionWithSameLabel =
                new ConversationAction.Builder(ConversationAction.TYPE_CALL_PHONE)
                        .setAction(new RemoteAction(
                                icon, "label", "2", pendingIntent))
                        .setExtras(phoneExtras)
                        .build();

        List<ConversationAction> conversationActions =
                ActionsSuggestionsHelper.removeActionsWithDuplicates(
                        Arrays.asList(action, actionWithSameLabel));

        assertThat(conversationActions).isEmpty();
    }

    public void createLabeledIntentResult_null() {
    public void createLabeledIntentResult_null() {
        ActionsSuggestionsModel.ActionSuggestion nativeSuggestion =
        ActionsSuggestionsModel.ActionSuggestion nativeSuggestion =
                new ActionsSuggestionsModel.ActionSuggestion(
                new ActionsSuggestionsModel.ActionSuggestion(