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:
@@ -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);
|
||||
|
||||
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 -> {
|
||||
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()
|
||||
.indexSliceDataAsync(context);
|
||||
|
||||
|
Reference in New Issue
Block a user