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

Commit 0e03b12d authored by Tsung-Mao Fang's avatar Tsung-Mao Fang
Browse files

Fix abnormal behavior on search page

Prior to this cl, if user opens settings app
in single-pane first and navigates to
the search page, then rotate the device,
user observed the search page was still shown
with full screen.

Because we didn't register correct split rule,
it causes the abormal behavior on two-pane mode.
In order to register correct rule,  we also need
to assign correct component name while opening the
search page.

Fix: 206896763
Test: Rebuilt apk and verify the behavior
Change-Id: I7343467aa716d71da63f2ad0a034dc6c1b7fd415
parent 37ec371f
Loading
Loading
Loading
Loading
+34 −8
Original line number Diff line number Diff line
@@ -94,20 +94,26 @@ public class ActivityEmbeddingRulesController {

    /**
     * Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
     * {@link Settings} or {@link SettingsHomepageActivity}, we register split rule twice for
     * two cases.
     * {@link Settings} or {@link SettingsHomepageActivity} or
     * {@link SliceDeepLinkHomepageActivity}, we register split rule for above cases.
     */
    public static void registerTwoPanePairRuleForSettingsHome(Context context,
            ComponentName secondaryComponent,
            String secondaryIntentAction,
            boolean finishPrimaryWithSecondary,
            boolean finishSecondaryWithPrimary,
            boolean clearTop) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
            return;
        }

        registerTwoPanePairRule(
                context,
                getComponentName(context, Settings.class),
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);

        registerTwoPanePairRule(
@@ -115,8 +121,8 @@ public class ActivityEmbeddingRulesController {
                new ComponentName(context, DeepLinkHomepageActivity.class),
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);

        registerTwoPanePairRule(
@@ -124,8 +130,8 @@ public class ActivityEmbeddingRulesController {
                getComponentName(context, SettingsHomepageActivity.class),
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);

        registerTwoPanePairRule(
@@ -133,6 +139,26 @@ public class ActivityEmbeddingRulesController {
                getComponentName(context, SliceDeepLinkHomepageActivity.class),
                secondaryComponent,
                secondaryIntentAction,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);
    }

    /**
     * Register a new SplitPairRule for Settings home.
     */
    public static void registerTwoPanePairRuleForSettingsHome(Context context,
            ComponentName secondaryComponent,
            String secondaryIntentAction,
            boolean clearTop) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
            return;
        }

        registerTwoPanePairRuleForSettingsHome(
                context,
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                clearTop);
+29 −8
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
@@ -33,11 +34,14 @@ import androidx.fragment.app.FragmentActivity;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.search.SearchIndexableResources;

import com.google.android.setupcompat.util.WizardManagerHelper;

import java.util.List;

/**
 * FeatureProvider for Settings Search
 */
@@ -60,6 +64,9 @@ public interface SearchFeatureProvider {
     */
    SearchIndexableResources getSearchIndexableResources();

    /**
     * @return a package name of settings intelligence.
     */
    default String getSettingsIntelligencePkgName(Context context) {
        return context.getString(R.string.config_settingsintelligence_package_name);
    }
@@ -90,16 +97,30 @@ public interface SearchFeatureProvider {
        navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
        navView.setBackground(null);

        toolbar.setOnClickListener(tb -> {
        final Context context = activity.getApplicationContext();
        final Intent intent = buildSearchIntent(context, pageId)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            if (activity.getPackageManager().queryIntentActivities(intent,
                    PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
        final List<ResolveInfo> resolveInfos =
                activity.getPackageManager().queryIntentActivities(intent,
                        PackageManager.MATCH_DEFAULT_ONLY);
        if (resolveInfos.isEmpty()) {
            return;
        }

        final ComponentName searchComponentName = resolveInfos.get(0)
                .getComponentInfo().getComponentName();
        // Set a component name since activity embedding requires a component name for
        // registering a rule.
        intent.setComponent(searchComponentName);
        ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
                context,
                searchComponentName,
                intent.getAction(),
                false /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                false /* clearTop */);

        toolbar.setOnClickListener(tb -> {
            FeatureFactory.getFactory(context).getSlicesFeatureProvider()
                    .indexSliceDataAsync(context);