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

Commit ebfda7f2 authored by Joanne Chung's avatar Joanne Chung
Browse files

Fix broken SimpleSaveActivityTest#testTapUrlSpanOnCustomDescription_thenTapBack

Add FLAG_ACTIVITY_MATCH_EXTERNAL to make instant app can be resolved.

Bug: 148099813
Test: atest CtsAutoFillServiceTestCases:android.autofillservice.cts.\
SimpleSaveActivityTest#testTapUrlSpanOnCustomDescription_thenTapBack
Test: atest --instant CtsAutoFillServiceTestCases:android.autofillservice\
.cts.SimpleSaveActivityTest#testTapUrlSpanOnCustomDescription_thenTapBack

Change-Id: Idaf01fb61a5214eebcac3c9597e4f849123cf2eb
parent 358221de
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.metrics.LogMaker;
@@ -187,7 +188,10 @@ final class SaveUi {
        context = new ContextThemeWrapper(context, mThemeId) {
            @Override
            public void startActivity(Intent intent) {
                if (intent.resolveActivity(getPackageManager()) == null) {
                if (resolveActivity(intent) == null) {
                    if (sDebug) {
                        Slog.d(TAG, "Can not startActivity for save UI with intent=" + intent);
                    }
                    return;
                }
                intent.putExtra(AutofillManager.EXTRA_RESTORE_CROSS_ACTIVITY, true);
@@ -199,6 +203,16 @@ final class SaveUi {
                // Apply restore mechanism
                startIntentSenderWithRestore(p, intent);
            }

            private ComponentName resolveActivity(Intent intent) {
                final PackageManager packageManager = getPackageManager();
                final ComponentName componentName = intent.resolveActivity(packageManager);
                if (componentName != null) {
                    return componentName;
                }
                intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
                return intent.resolveActivity(packageManager);
            }
        };
        final LayoutInflater inflater = LayoutInflater.from(context);
        final View view = inflater.inflate(R.layout.autofill_save, null);