Loading services/core/java/com/android/server/wallpaper/WallpaperData.java +7 −9 Original line number Original line Diff line number Diff line Loading @@ -133,16 +133,14 @@ class WallpaperData { */ */ final Rect cropHint = new Rect(0, 0, 0, 0); final Rect cropHint = new Rect(0, 0, 0, 0); WallpaperData(int userId, File wallpaperDir, String inputFileName, String cropFileName) { this.userId = userId; wallpaperFile = new File(wallpaperDir, inputFileName); cropFile = new File(wallpaperDir, cropFileName); } WallpaperData(int userId, @SetWallpaperFlags int wallpaperType) { WallpaperData(int userId, @SetWallpaperFlags int wallpaperType) { this(userId, getWallpaperDir(userId), this.userId = userId; (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_ORIG : WALLPAPER, this.mWhich = wallpaperType; (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_CROP : WALLPAPER_CROP); File wallpaperDir = getWallpaperDir(userId); String wallpaperFileName = (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_ORIG : WALLPAPER; String cropFileName = (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_CROP : WALLPAPER_CROP; this.wallpaperFile = new File(wallpaperDir, wallpaperFileName); this.cropFile = new File(wallpaperDir, cropFileName); } } /** /** Loading services/tests/mockingservicestests/src/com/android/server/wallpaper/WallpaperManagerServiceTests.java +23 −4 Original line number Original line Diff line number Diff line Loading @@ -17,8 +17,10 @@ package com.android.server.wallpaper; package com.android.server.wallpaper; import static android.app.WallpaperManager.COMMAND_REAPPLY; import static android.app.WallpaperManager.COMMAND_REAPPLY; import static android.app.WallpaperManager.FLAG_LOCK; import static android.app.WallpaperManager.FLAG_SYSTEM; import static android.app.WallpaperManager.FLAG_SYSTEM; import static android.os.FileObserver.CLOSE_WRITE; import static android.os.FileObserver.CLOSE_WRITE; import static android.os.UserHandle.MIN_SECONDARY_USER_ID; import static android.os.UserHandle.USER_SYSTEM; import static android.os.UserHandle.USER_SYSTEM; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY; Loading Loading @@ -106,6 +108,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets; import java.util.List; /** /** * Tests for the {@link WallpaperManagerService} class. * Tests for the {@link WallpaperManagerService} class. Loading Loading @@ -261,6 +264,25 @@ public class WallpaperManagerServiceTests { } } } } /** * Tests that the fundamental fields are set by the main WallpaperData constructor */ @Test public void testWallpaperDataConstructor() { final int testUserId = MIN_SECONDARY_USER_ID; for (int which: List.of(FLAG_LOCK, FLAG_SYSTEM)) { WallpaperData newWallpaperData = new WallpaperData(testUserId, which); assertEquals(which, newWallpaperData.mWhich); assertEquals(testUserId, newWallpaperData.userId); WallpaperData wallpaperData = mService.getWallpaperSafeLocked(testUserId, which); assertEquals(wallpaperData.cropFile.getAbsolutePath(), newWallpaperData.cropFile.getAbsolutePath()); assertEquals(wallpaperData.wallpaperFile.getAbsolutePath(), newWallpaperData.wallpaperFile.getAbsolutePath()); } } /** /** * Tests that internal basic data should be correct after boot up. * Tests that internal basic data should be correct after boot up. */ */ Loading Loading @@ -405,10 +427,7 @@ public class WallpaperManagerServiceTests { fail("exception occurred while writing system wallpaper attributes"); fail("exception occurred while writing system wallpaper attributes"); } } WallpaperData shouldMatchSystem = new WallpaperData(systemWallpaperData.userId, WallpaperData shouldMatchSystem = new WallpaperData(0, FLAG_SYSTEM); systemWallpaperData.wallpaperFile.getParentFile(), systemWallpaperData.wallpaperFile.getAbsolutePath(), systemWallpaperData.cropFile.getAbsolutePath()); try { try { TypedXmlPullParser parser = Xml.newBinaryPullParser(); TypedXmlPullParser parser = Xml.newBinaryPullParser(); mService.mWallpaperDataParser.parseWallpaperAttributes(parser, shouldMatchSystem, true); mService.mWallpaperDataParser.parseWallpaperAttributes(parser, shouldMatchSystem, true); Loading Loading
services/core/java/com/android/server/wallpaper/WallpaperData.java +7 −9 Original line number Original line Diff line number Diff line Loading @@ -133,16 +133,14 @@ class WallpaperData { */ */ final Rect cropHint = new Rect(0, 0, 0, 0); final Rect cropHint = new Rect(0, 0, 0, 0); WallpaperData(int userId, File wallpaperDir, String inputFileName, String cropFileName) { this.userId = userId; wallpaperFile = new File(wallpaperDir, inputFileName); cropFile = new File(wallpaperDir, cropFileName); } WallpaperData(int userId, @SetWallpaperFlags int wallpaperType) { WallpaperData(int userId, @SetWallpaperFlags int wallpaperType) { this(userId, getWallpaperDir(userId), this.userId = userId; (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_ORIG : WALLPAPER, this.mWhich = wallpaperType; (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_CROP : WALLPAPER_CROP); File wallpaperDir = getWallpaperDir(userId); String wallpaperFileName = (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_ORIG : WALLPAPER; String cropFileName = (wallpaperType == FLAG_LOCK) ? WALLPAPER_LOCK_CROP : WALLPAPER_CROP; this.wallpaperFile = new File(wallpaperDir, wallpaperFileName); this.cropFile = new File(wallpaperDir, cropFileName); } } /** /** Loading
services/tests/mockingservicestests/src/com/android/server/wallpaper/WallpaperManagerServiceTests.java +23 −4 Original line number Original line Diff line number Diff line Loading @@ -17,8 +17,10 @@ package com.android.server.wallpaper; package com.android.server.wallpaper; import static android.app.WallpaperManager.COMMAND_REAPPLY; import static android.app.WallpaperManager.COMMAND_REAPPLY; import static android.app.WallpaperManager.FLAG_LOCK; import static android.app.WallpaperManager.FLAG_SYSTEM; import static android.app.WallpaperManager.FLAG_SYSTEM; import static android.os.FileObserver.CLOSE_WRITE; import static android.os.FileObserver.CLOSE_WRITE; import static android.os.UserHandle.MIN_SECONDARY_USER_ID; import static android.os.UserHandle.USER_SYSTEM; import static android.os.UserHandle.USER_SYSTEM; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY; Loading Loading @@ -106,6 +108,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets; import java.util.List; /** /** * Tests for the {@link WallpaperManagerService} class. * Tests for the {@link WallpaperManagerService} class. Loading Loading @@ -261,6 +264,25 @@ public class WallpaperManagerServiceTests { } } } } /** * Tests that the fundamental fields are set by the main WallpaperData constructor */ @Test public void testWallpaperDataConstructor() { final int testUserId = MIN_SECONDARY_USER_ID; for (int which: List.of(FLAG_LOCK, FLAG_SYSTEM)) { WallpaperData newWallpaperData = new WallpaperData(testUserId, which); assertEquals(which, newWallpaperData.mWhich); assertEquals(testUserId, newWallpaperData.userId); WallpaperData wallpaperData = mService.getWallpaperSafeLocked(testUserId, which); assertEquals(wallpaperData.cropFile.getAbsolutePath(), newWallpaperData.cropFile.getAbsolutePath()); assertEquals(wallpaperData.wallpaperFile.getAbsolutePath(), newWallpaperData.wallpaperFile.getAbsolutePath()); } } /** /** * Tests that internal basic data should be correct after boot up. * Tests that internal basic data should be correct after boot up. */ */ Loading Loading @@ -405,10 +427,7 @@ public class WallpaperManagerServiceTests { fail("exception occurred while writing system wallpaper attributes"); fail("exception occurred while writing system wallpaper attributes"); } } WallpaperData shouldMatchSystem = new WallpaperData(systemWallpaperData.userId, WallpaperData shouldMatchSystem = new WallpaperData(0, FLAG_SYSTEM); systemWallpaperData.wallpaperFile.getParentFile(), systemWallpaperData.wallpaperFile.getAbsolutePath(), systemWallpaperData.cropFile.getAbsolutePath()); try { try { TypedXmlPullParser parser = Xml.newBinaryPullParser(); TypedXmlPullParser parser = Xml.newBinaryPullParser(); mService.mWallpaperDataParser.parseWallpaperAttributes(parser, shouldMatchSystem, true); mService.mWallpaperDataParser.parseWallpaperAttributes(parser, shouldMatchSystem, true); Loading