Delete app pairs on model load if flag is turned off

This CL adds a case to processFolderOrAppPair() -- if the ENABLE_APP_PAIRS flag is turned off, we do not load app pairs into launcher.

This prevents a case where a user uses backup+restore to migrate an app pair onto an environment where app pairs is disabled.

Fixes: 330412376
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TRUNKFOOD
Test: Manual
Change-Id: I4a97e4aadc620f8b727439fcdd70ab0e7a3005a8
(cherry picked from commit 08fc2d434f)
Merged-In: I4a97e4aadc620f8b727439fcdd70ab0e7a3005a8
This commit is contained in:
Jeremy Sim
2024-04-03 14:37:41 -07:00
committed by Vinit Nayak
parent ee1fdb4abc
commit af645fe110
@@ -32,6 +32,7 @@ import com.android.launcher3.LauncherAppState
import com.android.launcher3.LauncherSettings.Favorites
import com.android.launcher3.Utilities
import com.android.launcher3.backuprestore.LauncherRestoreEventLogger.RestoreError
import com.android.launcher3.config.FeatureFlags
import com.android.launcher3.logging.FileLog
import com.android.launcher3.model.data.AppPairInfo
import com.android.launcher3.model.data.FolderInfo
@@ -373,6 +374,12 @@ class WorkspaceItemProcessor(
// If we generated a placeholder Folder before this point, it may need to be replaced with
// an app pair.
if (c.itemType == Favorites.ITEM_TYPE_APP_PAIR && collection is FolderInfo) {
if (!FeatureFlags.enableAppPairs()) {
// If app pairs are not enabled, stop loading.
Log.e(TAG, "app pairs flag is off, did not load app pair")
return
}
val folderInfo: FolderInfo = collection
val newAppPair = AppPairInfo()
// Move the placeholder's contents over to the new app pair.