Merge "Improve Settings launch performance for normal phones" into udc-dev am: 75e591e413

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23123008

Change-Id: I65c041ecbe99ad70e3348ded7d76b71ac445ca3e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Charles Chen
2023-05-12 12:43:28 +00:00
committed by Automerger Merge Worker
3 changed files with 29 additions and 23 deletions

View File

@@ -51,8 +51,9 @@ public class SettingsApplication extends Application {
// Set Spa environment. // Set Spa environment.
setSpaEnvironment(); setSpaEnvironment();
if (FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN) if (ActivityEmbeddingUtils.isSettingsSplitEnabled(this)
&& ActivityEmbeddingUtils.isSettingsSplitEnabled(this)) { && FeatureFlagUtils.isEnabled(this,
FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN)) {
if (WizardManagerHelper.isUserSetupComplete(this)) { if (WizardManagerHelper.isUserSetupComplete(this)) {
new ActivityEmbeddingRulesController(this).initRules(); new ActivityEmbeddingRulesController(this).initRules();
} else { } else {

View File

@@ -97,16 +97,24 @@ public class ActivityEmbeddingUtils {
* </ul> * </ul>
*/ */
public static boolean isEmbeddingActivityEnabled(Context context) { public static boolean isEmbeddingActivityEnabled(Context context) {
boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context, // Activity Embedding feature is not enabled if Settings doesn't enable large screen
FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN); // optimization or the device is not supported.
boolean isSettingsSplitSupported = isSettingsSplitEnabled(context); if (!isSettingsSplitEnabled(context)) {
boolean isUserSetupComplete = WizardManagerHelper.isUserSetupComplete(context); Log.d(TAG, "isSettingsSplitSupported = false");
return false;
Log.d(TAG, "isFlagEnabled = " + isFlagEnabled); }
Log.d(TAG, "isSettingsSplitSupported = " + isSettingsSplitSupported); // Activity Embedding feature is not enabled if a user chooses to disable the feature.
Log.d(TAG, "isUserSetupComplete = " + isUserSetupComplete); if (!FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN)) {
Log.d(TAG, "isFlagEnabled = false");
return isFlagEnabled && isSettingsSplitSupported && isUserSetupComplete; return false;
}
// Don't enable Activity embedding for setup wizard.
if (!WizardManagerHelper.isUserSetupComplete(context)) {
Log.d(TAG, "isUserSetupComplete = false");
return false;
}
Log.d(TAG, "isEmbeddingActivityEnabled = true");
return true;
} }
/** Whether to show the regular or simplified homepage layout. */ /** Whether to show the regular or simplified homepage layout. */
@@ -120,8 +128,7 @@ public class ActivityEmbeddingUtils {
* Check if activity is already embedded * Check if activity is already embedded
*/ */
public static boolean isAlreadyEmbedded(Activity activity) { public static boolean isAlreadyEmbedded(Activity activity) {
return ActivityEmbeddingController return isEmbeddingActivityEnabled(activity) && ActivityEmbeddingController.getInstance(
.getInstance(activity) activity).isActivityEmbedded(activity);
.isActivityEmbedded(activity);
} }
} }

View File

@@ -57,7 +57,6 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.window.embedding.ActivityEmbeddingController;
import androidx.window.embedding.SplitRule; import androidx.window.embedding.SplitRule;
import com.android.settings.R; import com.android.settings.R;
@@ -108,7 +107,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
private View mTwoPaneSuggestionView; private View mTwoPaneSuggestionView;
private CategoryMixin mCategoryMixin; private CategoryMixin mCategoryMixin;
private Set<HomepageLoadedListener> mLoadedListeners; private Set<HomepageLoadedListener> mLoadedListeners;
private ActivityEmbeddingController mActivityEmbeddingController;
private boolean mIsEmbeddingActivityEnabled; private boolean mIsEmbeddingActivityEnabled;
private boolean mIsTwoPane; private boolean mIsTwoPane;
// A regular layout shows icons on homepage, whereas a simplified layout doesn't. // A regular layout shows icons on homepage, whereas a simplified layout doesn't.
@@ -200,8 +198,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
setupEdgeToEdge(); setupEdgeToEdge();
setContentView(R.layout.settings_homepage_container); setContentView(R.layout.settings_homepage_container);
mActivityEmbeddingController = ActivityEmbeddingController.getInstance(this); mIsTwoPane = ActivityEmbeddingUtils.isAlreadyEmbedded(this);
mIsTwoPane = mActivityEmbeddingController.isActivityEmbedded(this);
updateAppBarMinHeight(); updateAppBarMinHeight();
initHomepageContainer(); initHomepageContainer();
@@ -242,7 +239,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
// Settings app may be launched on an existing task. Reset SplitPairRule of SubSettings here // Settings app may be launched on an existing task. Reset SplitPairRule of SubSettings here
// to prevent SplitPairRule of an existing task applied on a new started Settings app. // to prevent SplitPairRule of an existing task applied on a new started Settings app.
if (ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this) if (mIsEmbeddingActivityEnabled
&& (getIntent().getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) { && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
initSplitPairRules(); initSplitPairRules();
} }
@@ -284,7 +281,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
final boolean newTwoPaneState = mActivityEmbeddingController.isActivityEmbedded(this); final boolean newTwoPaneState = ActivityEmbeddingUtils.isAlreadyEmbedded(this);
if (mIsTwoPane != newTwoPaneState) { if (mIsTwoPane != newTwoPaneState) {
mIsTwoPane = newTwoPaneState; mIsTwoPane = newTwoPaneState;
updateHomepageAppBar(); updateHomepageAppBar();
@@ -427,8 +424,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements
} }
private boolean shouldLaunchDeepLinkIntentToRight() { private boolean shouldLaunchDeepLinkIntentToRight() {
if (!FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN) if (!ActivityEmbeddingUtils.isSettingsSplitEnabled(this)
|| !ActivityEmbeddingUtils.isSettingsSplitEnabled(this)) { || !FeatureFlagUtils.isEnabled(this,
FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN)) {
return false; return false;
} }