Loading src/com/android/settings/SettingsApplication.java +42 −3 Original line number Diff line number Diff line Loading @@ -17,11 +17,19 @@ package com.android.settings; import android.app.Application; import android.database.ContentObserver; import android.net.Uri; import android.provider.Settings; import android.util.FeatureFlagUtils; import androidx.window.embedding.SplitController; import com.android.settings.activityembedding.ActivityEmbeddingRulesController; import com.android.settings.homepage.SettingsHomepageActivity; import com.android.settingslib.applications.AppIconCacheManager; import com.google.android.setupcompat.util.WizardManagerHelper; import java.lang.ref.WeakReference; /** Settings application which sets up activity embedding rules for the large screen device. */ Loading @@ -33,9 +41,14 @@ public class SettingsApplication extends Application { public void onCreate() { super.onCreate(); final ActivityEmbeddingRulesController controller = new ActivityEmbeddingRulesController(this); controller.initRules(); if (FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN) && SplitController.getInstance().isSplitSupported()) { if (WizardManagerHelper.isUserSetupComplete(this)) { new ActivityEmbeddingRulesController(this).initRules(); } else { new DeviceProvisionedObserver().registerContentObserver(); } } } public void setHomeActivity(SettingsHomepageActivity homeActivity) { Loading @@ -51,4 +64,30 @@ public class SettingsApplication extends Application { super.onLowMemory(); AppIconCacheManager.getInstance().release(); } private class DeviceProvisionedObserver extends ContentObserver { private final Uri mDeviceProvisionedUri = Settings.Secure.getUriFor( Settings.Secure.USER_SETUP_COMPLETE); DeviceProvisionedObserver() { super(null /* handler */); } @Override public void onChange(boolean selfChange, Uri uri, int flags) { if (!mDeviceProvisionedUri.equals(uri)) { return; } SettingsApplication.this.getContentResolver().unregisterContentObserver(this); new ActivityEmbeddingRulesController(SettingsApplication.this).initRules(); } public void registerContentObserver() { SettingsApplication.this.getContentResolver().registerContentObserver( mDeviceProvisionedUri, false /* notifyForDescendants */, this); } } } src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java +7 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import androidx.window.embedding.SplitController; import com.android.settings.R; import com.google.android.setupcompat.util.WizardManagerHelper; /** An util class collecting all common methods for the embedding activity features. */ public class ActivityEmbeddingUtils { // The smallest value of current width of the window when the split should be used. Loading Loading @@ -65,14 +67,16 @@ public class ActivityEmbeddingUtils { /** Whether to support embedding activity feature. */ public static boolean isEmbeddingActivityEnabled(Context context) { final boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context, boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN); final boolean isSplitSupported = SplitController.getInstance().isSplitSupported(); boolean isSplitSupported = SplitController.getInstance().isSplitSupported(); boolean isUserSetupComplete = WizardManagerHelper.isUserSetupComplete(context); Log.d(TAG, "isFlagEnabled = " + isFlagEnabled); Log.d(TAG, "isSplitSupported = " + isSplitSupported); Log.d(TAG, "isUserSetupComplete = " + isUserSetupComplete); return isFlagEnabled && isSplitSupported; return isFlagEnabled && isSplitSupported && isUserSetupComplete; } /** Whether to show the regular or simplified homepage layout. */ Loading src/com/android/settings/homepage/SettingsHomepageActivity.java +24 −10 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.Utils; import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin; import com.google.android.setupcompat.util.WizardManagerHelper; import java.net.URISyntaxException; import java.util.Set; Loading Loading @@ -219,7 +221,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements }, R.id.main_content); // Launch the intent from deep link for large screen devices. if (shouldLaunchDeepLinkIntentToRight()) { launchDeepLinkIntentToRight(); } updateHomepagePaddings(); updateSplitLayout(); } Loading @@ -242,8 +246,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements return; } // Launch the intent from deep link for large screen devices. if (shouldLaunchDeepLinkIntentToRight()) { launchDeepLinkIntentToRight(); } } @Override public void onConfigurationChanged(Configuration newConfig) { Loading Loading @@ -390,17 +396,18 @@ public class SettingsHomepageActivity extends FragmentActivity implements return showFragment; } private void launchDeepLinkIntentToRight() { if (!mIsEmbeddingActivityEnabled) { return; private boolean shouldLaunchDeepLinkIntentToRight() { if (!FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN) || !SplitController.getInstance().isSplitSupported()) { return false; } final Intent intent = getIntent(); if (intent == null || !TextUtils.equals(intent.getAction(), ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)) { return; Intent intent = getIntent(); return intent != null && TextUtils.equals(intent.getAction(), ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY); } private void launchDeepLinkIntentToRight() { if (!(this instanceof DeepLinkHomepageActivity || this instanceof DeepLinkHomepageActivityInternal)) { Log.e(TAG, "Not a deep link component"); Loading @@ -408,6 +415,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements return; } if (!WizardManagerHelper.isUserSetupComplete(this)) { Log.e(TAG, "Cancel deep link before SUW completed"); finish(); return; } final Intent intent = getIntent(); final String intentUriString = intent.getStringExtra( EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI); if (TextUtils.isEmpty(intentUriString)) { Loading Loading
src/com/android/settings/SettingsApplication.java +42 −3 Original line number Diff line number Diff line Loading @@ -17,11 +17,19 @@ package com.android.settings; import android.app.Application; import android.database.ContentObserver; import android.net.Uri; import android.provider.Settings; import android.util.FeatureFlagUtils; import androidx.window.embedding.SplitController; import com.android.settings.activityembedding.ActivityEmbeddingRulesController; import com.android.settings.homepage.SettingsHomepageActivity; import com.android.settingslib.applications.AppIconCacheManager; import com.google.android.setupcompat.util.WizardManagerHelper; import java.lang.ref.WeakReference; /** Settings application which sets up activity embedding rules for the large screen device. */ Loading @@ -33,9 +41,14 @@ public class SettingsApplication extends Application { public void onCreate() { super.onCreate(); final ActivityEmbeddingRulesController controller = new ActivityEmbeddingRulesController(this); controller.initRules(); if (FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN) && SplitController.getInstance().isSplitSupported()) { if (WizardManagerHelper.isUserSetupComplete(this)) { new ActivityEmbeddingRulesController(this).initRules(); } else { new DeviceProvisionedObserver().registerContentObserver(); } } } public void setHomeActivity(SettingsHomepageActivity homeActivity) { Loading @@ -51,4 +64,30 @@ public class SettingsApplication extends Application { super.onLowMemory(); AppIconCacheManager.getInstance().release(); } private class DeviceProvisionedObserver extends ContentObserver { private final Uri mDeviceProvisionedUri = Settings.Secure.getUriFor( Settings.Secure.USER_SETUP_COMPLETE); DeviceProvisionedObserver() { super(null /* handler */); } @Override public void onChange(boolean selfChange, Uri uri, int flags) { if (!mDeviceProvisionedUri.equals(uri)) { return; } SettingsApplication.this.getContentResolver().unregisterContentObserver(this); new ActivityEmbeddingRulesController(SettingsApplication.this).initRules(); } public void registerContentObserver() { SettingsApplication.this.getContentResolver().registerContentObserver( mDeviceProvisionedUri, false /* notifyForDescendants */, this); } } }
src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java +7 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import androidx.window.embedding.SplitController; import com.android.settings.R; import com.google.android.setupcompat.util.WizardManagerHelper; /** An util class collecting all common methods for the embedding activity features. */ public class ActivityEmbeddingUtils { // The smallest value of current width of the window when the split should be used. Loading Loading @@ -65,14 +67,16 @@ public class ActivityEmbeddingUtils { /** Whether to support embedding activity feature. */ public static boolean isEmbeddingActivityEnabled(Context context) { final boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context, boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN); final boolean isSplitSupported = SplitController.getInstance().isSplitSupported(); boolean isSplitSupported = SplitController.getInstance().isSplitSupported(); boolean isUserSetupComplete = WizardManagerHelper.isUserSetupComplete(context); Log.d(TAG, "isFlagEnabled = " + isFlagEnabled); Log.d(TAG, "isSplitSupported = " + isSplitSupported); Log.d(TAG, "isUserSetupComplete = " + isUserSetupComplete); return isFlagEnabled && isSplitSupported; return isFlagEnabled && isSplitSupported && isUserSetupComplete; } /** Whether to show the regular or simplified homepage layout. */ Loading
src/com/android/settings/homepage/SettingsHomepageActivity.java +24 −10 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.Utils; import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin; import com.google.android.setupcompat.util.WizardManagerHelper; import java.net.URISyntaxException; import java.util.Set; Loading Loading @@ -219,7 +221,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements }, R.id.main_content); // Launch the intent from deep link for large screen devices. if (shouldLaunchDeepLinkIntentToRight()) { launchDeepLinkIntentToRight(); } updateHomepagePaddings(); updateSplitLayout(); } Loading @@ -242,8 +246,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements return; } // Launch the intent from deep link for large screen devices. if (shouldLaunchDeepLinkIntentToRight()) { launchDeepLinkIntentToRight(); } } @Override public void onConfigurationChanged(Configuration newConfig) { Loading Loading @@ -390,17 +396,18 @@ public class SettingsHomepageActivity extends FragmentActivity implements return showFragment; } private void launchDeepLinkIntentToRight() { if (!mIsEmbeddingActivityEnabled) { return; private boolean shouldLaunchDeepLinkIntentToRight() { if (!FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN) || !SplitController.getInstance().isSplitSupported()) { return false; } final Intent intent = getIntent(); if (intent == null || !TextUtils.equals(intent.getAction(), ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)) { return; Intent intent = getIntent(); return intent != null && TextUtils.equals(intent.getAction(), ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY); } private void launchDeepLinkIntentToRight() { if (!(this instanceof DeepLinkHomepageActivity || this instanceof DeepLinkHomepageActivityInternal)) { Log.e(TAG, "Not a deep link component"); Loading @@ -408,6 +415,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements return; } if (!WizardManagerHelper.isUserSetupComplete(this)) { Log.e(TAG, "Cancel deep link before SUW completed"); finish(); return; } final Intent intent = getIntent(); final String intentUriString = intent.getStringExtra( EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI); if (TextUtils.isEmpty(intentUriString)) { Loading