Merge "Avoid activity embedding if the activity is already embedded" into udc-dev

This commit is contained in:
Alexander Milantev
2023-03-29 11:26:39 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.TypedValue;
import androidx.window.embedding.ActivityEmbeddingController;
import androidx.window.embedding.SplitController;
import com.android.settings.R;
@@ -81,4 +82,13 @@ public class ActivityEmbeddingUtils {
return dm.widthPixels >= (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP, dm);
}
/**
* Check if activity is already embedded
*/
public static boolean isAlreadyEmbedded(Activity activity) {
return ActivityEmbeddingController
.getInstance(activity)
.isActivityEmbedded(activity);
}
}

View File

@@ -102,7 +102,8 @@ public class SearchResultTrampoline extends Activity {
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)
|| ActivityEmbeddingUtils.isAlreadyEmbedded(this)) {
startActivity(intent);
} else if (isSettingsIntelligence(callingActivity)) {
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {