Loading core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2029,6 +2029,9 @@ <!-- Class name of WallpaperManagerService. --> <string name="config_wallpaperManagerServiceName" translatable="false">com.android.server.wallpaper.WallpaperManagerService</string> <!-- True if live wallpapers can be supported in the deskop experience --> <bool name="config_isLiveWallpaperSupportedInDesktopExperience">false</bool> <!-- Specifies priority of automatic time sources. Suggestions from higher entries in the list take precedence over lower ones. See com.android.server.timedetector.TimeDetectorStrategy for available sources. --> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2282,6 +2282,7 @@ <java-symbol type="string" name="heavy_weight_notification_detail" /> <java-symbol type="string" name="image_wallpaper_component" /> <java-symbol type="string" name="fallback_wallpaper_component" /> <java-symbol type="bool" name="config_isLiveWallpaperSupportedInDesktopExperience" /> <java-symbol type="string" name="input_method_binding_label" /> <java-symbol type="string" name="input_method_ime_switch_long_click_action_desc" /> <java-symbol type="string" name="launch_warning_original" /> Loading services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +10 −1 Original line number Diff line number Diff line Loading @@ -747,13 +747,22 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (connection == null) { return false; } boolean isWallpaperDesktopExperienceEnabled = isDeviceEligibleForDesktopExperienceWallpaper( mContext); boolean isLiveWallpaperSupportedInDesktopExperience = mContext.getResources().getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); // Non image wallpaper. if (connection.mInfo != null) { if (isWallpaperDesktopExperienceEnabled && !isLiveWallpaperSupportedInDesktopExperience) { return false; } return connection.mInfo.supportsMultipleDisplays(); } // Image wallpaper if (isDeviceEligibleForDesktopExperienceWallpaper(mContext)) { if (isWallpaperDesktopExperienceEnabled) { return mWallpaperCropper.isWallpaperCompatibleForDisplay(displayId, connection.mWallpaper); } Loading services/tests/mockingservicestests/src/com/android/server/wallpaper/WallpaperManagerServiceTests.java +70 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.graphics.Color; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; Loading Loading @@ -1188,6 +1189,10 @@ public class WallpaperManagerServiceTests { @Test @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void setWallpaperComponent_systemAndLockWallpapers_multiDisplays_shouldHaveExpectedConnections() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(true).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int incompatibleDisplayId = 2; final int compatibleDisplayId = 3; setUpDisplays(Map.of( Loading Loading @@ -1227,6 +1232,71 @@ public class WallpaperManagerServiceTests { .isTrue(); } @Test @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void isWallpaperCompatibleForDisplay_liveWallpaperSupported_desktopExperienceEnabled_shouldReturnTrue() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(true).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int displayId = 2; setUpDisplays(Map.of( DEFAULT_DISPLAY, true, displayId, true)); final int testUserId = USER_SYSTEM; mService.switchUser(testUserId, null); mService.setWallpaperComponent(TEST_WALLPAPER_COMPONENT, sContext.getOpPackageName(), FLAG_SYSTEM | FLAG_LOCK, testUserId); assertThat(mService.isWallpaperCompatibleForDisplay(displayId, mService.mLastWallpaper.connection)).isTrue(); } @Test @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void isWallpaperCompatibleForDisplay_liveWallpaperUnsupported_desktopExperienceEnabled_shouldReturnFalse() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(false).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int displayId = 2; setUpDisplays(Map.of( DEFAULT_DISPLAY, true, displayId, true)); final int testUserId = USER_SYSTEM; mService.switchUser(testUserId, null); mService.setWallpaperComponent(TEST_WALLPAPER_COMPONENT, sContext.getOpPackageName(), FLAG_SYSTEM | FLAG_LOCK, testUserId); assertThat(mService.isWallpaperCompatibleForDisplay(displayId, mService.mLastWallpaper.connection)).isFalse(); } @Test @DisableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void isWallpaperCompatibleForDisplay_liveWallpaperUnsupported_desktopExperienceDisabled_shouldReturnTrue() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(false).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int displayId = 2; setUpDisplays(Map.of( DEFAULT_DISPLAY, true, displayId, true)); final int testUserId = USER_SYSTEM; mService.switchUser(testUserId, null); mService.setWallpaperComponent(TEST_WALLPAPER_COMPONENT, sContext.getOpPackageName(), FLAG_SYSTEM | FLAG_LOCK, testUserId); // config_isLiveWallpaperSupportedInDesktopExperience is not used if the desktop experience // flag for wallpaper is disabled. assertThat(mService.isWallpaperCompatibleForDisplay(displayId, mService.mLastWallpaper.connection)).isTrue(); } // Verify that after continue switch user from userId 0 to lastUserId, the wallpaper data for // non-current user must not bind to wallpaper service. private void verifyNoConnectionBeforeLastUser(int lastUserId) { Loading Loading
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2029,6 +2029,9 @@ <!-- Class name of WallpaperManagerService. --> <string name="config_wallpaperManagerServiceName" translatable="false">com.android.server.wallpaper.WallpaperManagerService</string> <!-- True if live wallpapers can be supported in the deskop experience --> <bool name="config_isLiveWallpaperSupportedInDesktopExperience">false</bool> <!-- Specifies priority of automatic time sources. Suggestions from higher entries in the list take precedence over lower ones. See com.android.server.timedetector.TimeDetectorStrategy for available sources. --> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2282,6 +2282,7 @@ <java-symbol type="string" name="heavy_weight_notification_detail" /> <java-symbol type="string" name="image_wallpaper_component" /> <java-symbol type="string" name="fallback_wallpaper_component" /> <java-symbol type="bool" name="config_isLiveWallpaperSupportedInDesktopExperience" /> <java-symbol type="string" name="input_method_binding_label" /> <java-symbol type="string" name="input_method_ime_switch_long_click_action_desc" /> <java-symbol type="string" name="launch_warning_original" /> Loading
services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +10 −1 Original line number Diff line number Diff line Loading @@ -747,13 +747,22 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (connection == null) { return false; } boolean isWallpaperDesktopExperienceEnabled = isDeviceEligibleForDesktopExperienceWallpaper( mContext); boolean isLiveWallpaperSupportedInDesktopExperience = mContext.getResources().getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); // Non image wallpaper. if (connection.mInfo != null) { if (isWallpaperDesktopExperienceEnabled && !isLiveWallpaperSupportedInDesktopExperience) { return false; } return connection.mInfo.supportsMultipleDisplays(); } // Image wallpaper if (isDeviceEligibleForDesktopExperienceWallpaper(mContext)) { if (isWallpaperDesktopExperienceEnabled) { return mWallpaperCropper.isWallpaperCompatibleForDisplay(displayId, connection.mWallpaper); } Loading
services/tests/mockingservicestests/src/com/android/server/wallpaper/WallpaperManagerServiceTests.java +70 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.graphics.Color; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; Loading Loading @@ -1188,6 +1189,10 @@ public class WallpaperManagerServiceTests { @Test @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void setWallpaperComponent_systemAndLockWallpapers_multiDisplays_shouldHaveExpectedConnections() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(true).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int incompatibleDisplayId = 2; final int compatibleDisplayId = 3; setUpDisplays(Map.of( Loading Loading @@ -1227,6 +1232,71 @@ public class WallpaperManagerServiceTests { .isTrue(); } @Test @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void isWallpaperCompatibleForDisplay_liveWallpaperSupported_desktopExperienceEnabled_shouldReturnTrue() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(true).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int displayId = 2; setUpDisplays(Map.of( DEFAULT_DISPLAY, true, displayId, true)); final int testUserId = USER_SYSTEM; mService.switchUser(testUserId, null); mService.setWallpaperComponent(TEST_WALLPAPER_COMPONENT, sContext.getOpPackageName(), FLAG_SYSTEM | FLAG_LOCK, testUserId); assertThat(mService.isWallpaperCompatibleForDisplay(displayId, mService.mLastWallpaper.connection)).isTrue(); } @Test @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void isWallpaperCompatibleForDisplay_liveWallpaperUnsupported_desktopExperienceEnabled_shouldReturnFalse() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(false).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int displayId = 2; setUpDisplays(Map.of( DEFAULT_DISPLAY, true, displayId, true)); final int testUserId = USER_SYSTEM; mService.switchUser(testUserId, null); mService.setWallpaperComponent(TEST_WALLPAPER_COMPONENT, sContext.getOpPackageName(), FLAG_SYSTEM | FLAG_LOCK, testUserId); assertThat(mService.isWallpaperCompatibleForDisplay(displayId, mService.mLastWallpaper.connection)).isFalse(); } @Test @DisableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WALLPAPER) public void isWallpaperCompatibleForDisplay_liveWallpaperUnsupported_desktopExperienceDisabled_shouldReturnTrue() { Resources resources = sContext.getResources(); spyOn(resources); doReturn(false).when(resources).getBoolean( R.bool.config_isLiveWallpaperSupportedInDesktopExperience); final int displayId = 2; setUpDisplays(Map.of( DEFAULT_DISPLAY, true, displayId, true)); final int testUserId = USER_SYSTEM; mService.switchUser(testUserId, null); mService.setWallpaperComponent(TEST_WALLPAPER_COMPONENT, sContext.getOpPackageName(), FLAG_SYSTEM | FLAG_LOCK, testUserId); // config_isLiveWallpaperSupportedInDesktopExperience is not used if the desktop experience // flag for wallpaper is disabled. assertThat(mService.isWallpaperCompatibleForDisplay(displayId, mService.mLastWallpaper.connection)).isTrue(); } // Verify that after continue switch user from userId 0 to lastUserId, the wallpaper data for // non-current user must not bind to wallpaper service. private void verifyNoConnectionBeforeLastUser(int lastUserId) { Loading