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
This commit is contained in:
@@ -94,20 +94,26 @@ public class ActivityEmbeddingRulesController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
|
* 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
|
* {@link Settings} or {@link SettingsHomepageActivity} or
|
||||||
* two cases.
|
* {@link SliceDeepLinkHomepageActivity}, we register split rule for above cases.
|
||||||
*/
|
*/
|
||||||
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
||||||
ComponentName secondaryComponent,
|
ComponentName secondaryComponent,
|
||||||
String secondaryIntentAction,
|
String secondaryIntentAction,
|
||||||
|
boolean finishPrimaryWithSecondary,
|
||||||
|
boolean finishSecondaryWithPrimary,
|
||||||
boolean clearTop) {
|
boolean clearTop) {
|
||||||
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
context,
|
context,
|
||||||
getComponentName(context, Settings.class),
|
getComponentName(context, Settings.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
finishPrimaryWithSecondary,
|
||||||
true /* finishSecondaryWithPrimary */,
|
finishSecondaryWithPrimary,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -115,8 +121,8 @@ public class ActivityEmbeddingRulesController {
|
|||||||
new ComponentName(context, DeepLinkHomepageActivity.class),
|
new ComponentName(context, DeepLinkHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
finishPrimaryWithSecondary,
|
||||||
true /* finishSecondaryWithPrimary */,
|
finishSecondaryWithPrimary,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -124,8 +130,8 @@ public class ActivityEmbeddingRulesController {
|
|||||||
getComponentName(context, SettingsHomepageActivity.class),
|
getComponentName(context, SettingsHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
finishPrimaryWithSecondary,
|
||||||
true /* finishSecondaryWithPrimary */,
|
finishSecondaryWithPrimary,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -133,6 +139,26 @@ public class ActivityEmbeddingRulesController {
|
|||||||
getComponentName(context, SliceDeepLinkHomepageActivity.class),
|
getComponentName(context, SliceDeepLinkHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
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 /* finishPrimaryWithSecondary */,
|
||||||
true /* finishSecondaryWithPrimary */,
|
true /* finishSecondaryWithPrimary */,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
@@ -24,6 +24,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -33,11 +34,14 @@ import androidx.fragment.app.FragmentActivity;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.search.SearchIndexableResources;
|
import com.android.settingslib.search.SearchIndexableResources;
|
||||||
|
|
||||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FeatureProvider for Settings Search
|
* FeatureProvider for Settings Search
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +64,9 @@ public interface SearchFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
SearchIndexableResources getSearchIndexableResources();
|
SearchIndexableResources getSearchIndexableResources();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a package name of settings intelligence.
|
||||||
|
*/
|
||||||
default String getSettingsIntelligencePkgName(Context context) {
|
default String getSettingsIntelligencePkgName(Context context) {
|
||||||
return context.getString(R.string.config_settingsintelligence_package_name);
|
return context.getString(R.string.config_settingsintelligence_package_name);
|
||||||
}
|
}
|
||||||
@@ -90,16 +97,30 @@ public interface SearchFeatureProvider {
|
|||||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
navView.setBackground(null);
|
navView.setBackground(null);
|
||||||
|
|
||||||
|
final Context context = activity.getApplicationContext();
|
||||||
|
final Intent intent = buildSearchIntent(context, pageId)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
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 -> {
|
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()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
||||||
.indexSliceDataAsync(context);
|
.indexSliceDataAsync(context);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user