diff options
| -rw-r--r-- | services/core/java/com/android/server/wallpaper/WallpaperDataParser.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java b/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java index 0165d65283dc..65ab12930c59 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java @@ -314,6 +314,11 @@ public class WallpaperDataParser { wallpaper.wallpaperId = makeWallpaperIdLocked(); } + Rect legacyCropHint = new Rect( + getAttributeInt(parser, "cropLeft", 0), + getAttributeInt(parser, "cropTop", 0), + getAttributeInt(parser, "cropRight", 0), + getAttributeInt(parser, "cropBottom", 0)); Rect totalCropHint = new Rect( getAttributeInt(parser, "totalCropLeft", 0), getAttributeInt(parser, "totalCropTop", 0), @@ -332,18 +337,19 @@ public class WallpaperDataParser { parser.getAttributeInt(null, "cropBottom" + pair.second, 0)); if (!cropHint.isEmpty()) wallpaper.mCropHints.put(pair.first, cropHint); } - if (wallpaper.mCropHints.size() == 0) { + if (wallpaper.mCropHints.size() == 0 && totalCropHint.isEmpty()) { // migration case: the crops per screen orientation are not specified. - // use the old attributes to find the crop for one screen orientation. - Integer orientation = totalCropHint.width() < totalCropHint.height() + int orientation = legacyCropHint.width() < legacyCropHint.height() ? WallpaperManager.PORTRAIT : WallpaperManager.LANDSCAPE; - if (!totalCropHint.isEmpty()) wallpaper.mCropHints.put(orientation, totalCropHint); + if (!legacyCropHint.isEmpty()) { + wallpaper.mCropHints.put(orientation, legacyCropHint); + } } else { wallpaper.cropHint.set(totalCropHint); } wallpaper.mSampleSize = parser.getAttributeFloat(null, "sampleSize", 1f); } else { - wallpaper.cropHint.set(totalCropHint); + wallpaper.cropHint.set(legacyCropHint); } final DisplayData wpData = mWallpaperDisplayHelper .getDisplayDataOrCreate(DEFAULT_DISPLAY); |