Merge "Share ExtendedWallpaper Flag between SystemUI & Customization Picker" into main
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index bb0d5d7..6c96279 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -1697,13 +1697,6 @@
 }
 
 flag {
-   name: "magic_portrait_wallpapers"
-   namespace: "systemui"
-   description: "Magic Portrait related changes in systemui"
-   bug: "370863642"
-}
-
-flag {
   name: "notes_role_qs_tile"
   namespace: "systemui"
   description: "Enables notes role qs tile which opens default notes role app in app bubbles"
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt
index 115edd0..2b16c00 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/WallpaperRepositoryImplTest.kt
@@ -25,16 +25,15 @@
 import androidx.test.ext.junit.runners.AndroidJUnit4
 import androidx.test.filters.SmallTest
 import com.android.internal.R
-import com.android.systemui.Flags
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.coroutines.collectLastValue
 import com.android.systemui.keyguard.data.repository.FakeKeyguardClockRepository
 import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
+import com.android.systemui.res.R as SysUIR
 import com.android.systemui.shared.Flags as SharedFlags
 import com.android.systemui.user.data.model.SelectedUserModel
 import com.android.systemui.user.data.model.SelectionStatus
 import com.android.systemui.user.data.repository.FakeUserRepository
-import com.android.systemui.wallpapers.data.repository.WallpaperRepositoryImpl.Companion.MAGIC_PORTRAIT_CLASSNAME
 import com.google.common.truth.Truth.assertThat
 import kotlinx.coroutines.ExperimentalCoroutinesApi
 import kotlinx.coroutines.test.StandardTestDispatcher
@@ -72,9 +71,12 @@
         )
     }
 
+    lateinit var focalAreaTarget: String
+
     @Before
     fun setUp() {
         whenever(wallpaperManager.isWallpaperSupported).thenReturn(true)
+        focalAreaTarget = context.resources.getString(SysUIR.string.focal_area_target)
     }
 
     @Test
@@ -248,17 +250,17 @@
         }
 
     @Test
-    @EnableFlags(Flags.FLAG_MAGIC_PORTRAIT_WALLPAPERS)
-    fun shouldSendNotificationLayout_setMagicPortraitWallpaper_launchSendLayoutJob() =
+    @EnableFlags(SharedFlags.FLAG_EXTENDED_WALLPAPER_EFFECTS)
+    fun shouldSendNotificationLayout_setExtendedEffectsWallpaper_launchSendLayoutJob() =
         testScope.runTest {
             val latest by collectLastValue(underTest.shouldSendFocalArea)
-            val magicPortraitWallpaper =
+            val extedendEffectsWallpaper =
                 mock<WallpaperInfo>().apply {
-                    whenever(this.component)
-                        .thenReturn(ComponentName(context, MAGIC_PORTRAIT_CLASSNAME))
+                    whenever(this.component).thenReturn(ComponentName(context, focalAreaTarget))
                 }
+
             whenever(wallpaperManager.getWallpaperInfoForUser(any()))
-                .thenReturn(magicPortraitWallpaper)
+                .thenReturn(extedendEffectsWallpaper)
             fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly(
                 context,
                 Intent(Intent.ACTION_WALLPAPER_CHANGED),
@@ -269,13 +271,16 @@
         }
 
     @Test
-    @EnableFlags(Flags.FLAG_MAGIC_PORTRAIT_WALLPAPERS)
-    fun shouldSendNotificationLayout_setNotMagicPortraitWallpaper_cancelSendLayoutJob() =
+    @EnableFlags(SharedFlags.FLAG_EXTENDED_WALLPAPER_EFFECTS)
+    fun shouldSendNotificationLayout_setNotExtendedEffectsWallpaper_cancelSendLayoutJob() =
         testScope.runTest {
             val latest by collectLastValue(underTest.shouldSendFocalArea)
-            val magicPortraitWallpaper = MAGIC_PORTRAIT_WP
+            val extendedEffectsWallpaper =
+                mock<WallpaperInfo>().apply {
+                    whenever(this.component).thenReturn(ComponentName("", focalAreaTarget))
+                }
             whenever(wallpaperManager.getWallpaperInfoForUser(any()))
-                .thenReturn(magicPortraitWallpaper)
+                .thenReturn(extendedEffectsWallpaper)
             fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly(
                 context,
                 Intent(Intent.ACTION_WALLPAPER_CHANGED),
@@ -284,9 +289,7 @@
             assertThat(underTest.sendLockscreenLayoutJob).isNotNull()
             assertThat(underTest.sendLockscreenLayoutJob!!.isActive).isEqualTo(true)
 
-            val nonMagicPortraitWallpaper = UNSUPPORTED_WP
-            whenever(wallpaperManager.getWallpaperInfoForUser(any()))
-                .thenReturn(nonMagicPortraitWallpaper)
+            whenever(wallpaperManager.getWallpaperInfoForUser(any())).thenReturn(UNSUPPORTED_WP)
             fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly(
                 context,
                 Intent(Intent.ACTION_WALLPAPER_CHANGED),
@@ -303,10 +306,5 @@
         val USER_WITH_SUPPORTED_WP = UserInfo(/* id= */ 4, /* name= */ "user4", /* flags= */ 0)
         val SUPPORTED_WP =
             mock<WallpaperInfo>().apply { whenever(this.supportsAmbientMode()).thenReturn(true) }
-
-        val MAGIC_PORTRAIT_WP =
-            mock<WallpaperInfo>().apply {
-                whenever(this.component).thenReturn(ComponentName("", MAGIC_PORTRAIT_CLASSNAME))
-            }
     }
 }
diff --git a/packages/SystemUI/res/values-xlarge-land/config.xml b/packages/SystemUI/res/values-xlarge-land/config.xml
index 6d8b64a..4c77f30 100644
--- a/packages/SystemUI/res/values-xlarge-land/config.xml
+++ b/packages/SystemUI/res/values-xlarge-land/config.xml
@@ -16,5 +16,5 @@
 
 <resources>
     <item name="shortcut_helper_screen_width_fraction"  format="float" type="dimen">0.8</item>
-    <bool name="center_align_magic_portrait_shape">true</bool>
+    <bool name="center_align_focal_area_shape">true</bool>
 </resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 68e33f2..9b8926e 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -1107,7 +1107,7 @@
     <!-- The dream component used when the device is low light environment. -->
     <string translatable="false" name="config_lowLightDreamComponent"/>
 
-    <!--Whether we should position magic portrait shape effects in the center of lockscreen
-    it's false by default, and only be true in tablet landscape -->
-    <bool name="center_align_magic_portrait_shape">false</bool>
+    <!-- Configuration for wallpaper focal area -->
+    <bool name="center_align_focal_area_shape">false</bool>
+    <string name="focal_area_target" translatable="false" />
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
index 621cc46..aaad101 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
@@ -326,10 +326,7 @@
 
     fun setShortcutAbsoluteTop(top: Float)
 
-    /**
-     * Set bottom of notifications from notification stack, and Magic Portrait will layout base on
-     * this value
-     */
+    /** Set bottom of notifications from notification stack */
     fun setNotificationStackAbsoluteBottom(bottom: Float)
 
     fun setWallpaperFocalAreaBounds(bounds: RectF)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WallpaperFocalAreaInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WallpaperFocalAreaInteractor.kt
index 934afe2..9c744d6 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WallpaperFocalAreaInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WallpaperFocalAreaInteractor.kt
@@ -50,8 +50,7 @@
     keyguardClockRepository: KeyguardClockRepository,
     wallpaperRepository: WallpaperRepository,
 ) {
-    // When there's notifications in splitshade, magic portrait shape effects should be left
-    // aligned in foldable
+    // When there's notifications in splitshade, the focal area shape effect should be left aligned
     private val notificationInShadeWideLayout: Flow<Boolean> =
         combine(
             shadeRepository.isShadeLayoutWide,
@@ -104,7 +103,7 @@
                     )
                 val (left, right) =
                 // tablet landscape
-                if (context.resources.getBoolean(R.bool.center_align_magic_portrait_shape)) {
+                if (context.resources.getBoolean(R.bool.center_align_focal_area_shape)) {
                         Pair(
                             scaledBounds.centerX() - maxFocalAreaWidth / 2F,
                             scaledBounds.centerX() + maxFocalAreaWidth / 2F,
@@ -129,7 +128,7 @@
                         wallpaperZoomedInScale
                 val top =
                     // tablet landscape
-                    if (context.resources.getBoolean(R.bool.center_align_magic_portrait_shape)) {
+                    if (context.resources.getBoolean(R.bool.center_align_focal_area_shape)) {
                         // no strict constraints for top, use bottom margin to make it symmetric
                         // vertically
                         scaledBounds.top + scaledBottomMargin
@@ -169,8 +168,8 @@
             )
         }
 
-        // A max width for magic portrait shape effects bounds, to avoid it going too large
-        // in large screen portrait mode
+        // A max width for focal area shape effects bounds, to avoid
+        // it becoming too large in large screen portrait mode
         const val FOCAL_AREA_MAX_WIDTH_DP = 500
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt
index f740144..ece1803 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt
@@ -28,6 +28,7 @@
 import com.android.systemui.keyguard.ui.viewmodel.ViewStateAccessor
 import com.android.systemui.lifecycle.repeatWhenAttached
 import com.android.systemui.scene.shared.flag.SceneContainerFlag
+import com.android.systemui.shared.Flags.extendedWallpaperEffects
 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
 import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCalculator
 import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
@@ -143,7 +144,7 @@
                     }
 
                     if (!SceneContainerFlag.isEnabled) {
-                        if (Flags.magicPortraitWallpapers()) {
+                        if (extendedWallpaperEffects()) {
                             launch {
                                 combine(
                                         viewModel.getNotificationStackAbsoluteBottom(
diff --git a/packages/SystemUI/src/com/android/systemui/wallpapers/data/repository/WallpaperRepository.kt b/packages/SystemUI/src/com/android/systemui/wallpapers/data/repository/WallpaperRepository.kt
index 9794c61..79a9630 100644
--- a/packages/SystemUI/src/com/android/systemui/wallpapers/data/repository/WallpaperRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/wallpapers/data/repository/WallpaperRepository.kt
@@ -27,12 +27,13 @@
 import androidx.annotation.VisibleForTesting
 import com.android.app.tracing.coroutines.launchTraced as launch
 import com.android.internal.R
-import com.android.systemui.Flags
 import com.android.systemui.broadcast.BroadcastDispatcher
 import com.android.systemui.dagger.SysUISingleton
 import com.android.systemui.dagger.qualifiers.Background
 import com.android.systemui.keyguard.data.repository.KeyguardRepository
+import com.android.systemui.res.R as SysUIR
 import com.android.systemui.shared.Flags.ambientAod
+import com.android.systemui.shared.Flags.extendedWallpaperEffects
 import com.android.systemui.user.data.model.SelectedUserModel
 import com.android.systemui.user.data.model.SelectionStatus
 import com.android.systemui.user.data.repository.UserRepository
@@ -66,7 +67,7 @@
     /** Set rootView to get its windowToken afterwards */
     var rootView: View?
 
-    /** when we use magic portrait wallpapers, we should always get its bounds from keyguard */
+    /** some wallpapers require bounds to be sent from keyguard */
     val shouldSendFocalArea: StateFlow<Boolean>
 }
 
@@ -80,7 +81,7 @@
     userRepository: UserRepository,
     keyguardRepository: KeyguardRepository,
     private val wallpaperManager: WallpaperManager,
-    context: Context,
+    private val context: Context,
 ) : WallpaperRepository {
     private val wallpaperChanged: Flow<Unit> =
         broadcastDispatcher
@@ -125,8 +126,8 @@
     override val shouldSendFocalArea =
         wallpaperInfo
             .map {
-                val shouldSendNotificationLayout =
-                    it?.component?.className == MAGIC_PORTRAIT_CLASSNAME
+                val focalAreaTarget = context.resources.getString(SysUIR.string.focal_area_target)
+                val shouldSendNotificationLayout = it?.component?.className == focalAreaTarget
                 if (shouldSendNotificationLayout) {
                     sendLockscreenLayoutJob =
                         scope.launch {
@@ -167,9 +168,8 @@
             }
             .stateIn(
                 scope,
-                // Always be listening for wallpaper changes when magic portrait flag is on
-                if (Flags.magicPortraitWallpapers()) SharingStarted.Eagerly else WhileSubscribed(),
-                initialValue = Flags.magicPortraitWallpapers(),
+                if (extendedWallpaperEffects()) SharingStarted.Eagerly else WhileSubscribed(),
+                initialValue = extendedWallpaperEffects(),
             )
 
     private suspend fun getWallpaper(selectedUser: SelectedUserModel): WallpaperInfo? {
@@ -177,9 +177,4 @@
             wallpaperManager.getWallpaperInfoForUser(selectedUser.userInfo.id)
         }
     }
-
-    companion object {
-        const val MAGIC_PORTRAIT_CLASSNAME =
-            "com.google.android.apps.magicportrait.service.MagicPortraitWallpaperService"
-    }
 }