Adapt WallpaperDataParser for lock screen engines
Previously, the component name was not loaded for a lock-only wallpaper: it was assumed to be ImageWallpaper. Now, always load the component name for a lock-only wallpaper, like for the system wallpaper. Test: atest CtsWallpaperTestCases Bug: 253507223 Change-Id: Ifcfd15f529bab963b181010a8a2fb328c4ec01c7
This commit is contained in:
@@ -74,13 +74,17 @@ class WallpaperDataParser {
|
||||
private final WallpaperCropper mWallpaperCropper;
|
||||
private final Context mContext;
|
||||
|
||||
// Temporary feature flag. TODO(b/197814683) remove
|
||||
private final boolean mEnableSeparateLockScreenEngine;
|
||||
|
||||
WallpaperDataParser(Context context, WallpaperDisplayHelper wallpaperDisplayHelper,
|
||||
WallpaperCropper wallpaperCropper) {
|
||||
WallpaperCropper wallpaperCropper, boolean enableSeparateLockScreenEngine) {
|
||||
mContext = context;
|
||||
mWallpaperDisplayHelper = wallpaperDisplayHelper;
|
||||
mWallpaperCropper = wallpaperCropper;
|
||||
mImageWallpaper = ComponentName.unflattenFromString(
|
||||
context.getResources().getString(R.string.image_wallpaper_component));
|
||||
mEnableSeparateLockScreenEngine = enableSeparateLockScreenEngine;
|
||||
}
|
||||
|
||||
private JournaledFile makeJournaledFile(int userId) {
|
||||
@@ -138,9 +142,17 @@ class WallpaperDataParser {
|
||||
FileInputStream stream = null;
|
||||
File file = journal.chooseForRead();
|
||||
|
||||
boolean migrateFromOld = wallpaper == null;
|
||||
|
||||
// don't reuse the wallpaper objects in the new version
|
||||
if (mEnableSeparateLockScreenEngine) {
|
||||
wallpaper = null;
|
||||
lockWallpaper = null;
|
||||
}
|
||||
|
||||
if (wallpaper == null) {
|
||||
// Do this once per boot
|
||||
migrateFromOld();
|
||||
if (migrateFromOld) migrateFromOld();
|
||||
wallpaper = new WallpaperData(userId, FLAG_SYSTEM);
|
||||
wallpaper.allowBackup = true;
|
||||
if (!wallpaper.cropExists()) {
|
||||
@@ -164,19 +176,25 @@ class WallpaperDataParser {
|
||||
type = parser.next();
|
||||
if (type == XmlPullParser.START_TAG) {
|
||||
String tag = parser.getName();
|
||||
if ("wp".equals(tag)) {
|
||||
// Common to system + lock wallpapers
|
||||
parseWallpaperAttributes(parser, wallpaper, keepDimensionHints);
|
||||
if ("wp".equals(tag)
|
||||
|| ("kwp".equals(tag) && mEnableSeparateLockScreenEngine)) {
|
||||
|
||||
if ("kwp".equals(tag) && lockWallpaper == null) {
|
||||
lockWallpaper = new WallpaperData(userId, FLAG_LOCK);
|
||||
}
|
||||
WallpaperData wallpaperToParse =
|
||||
"wp".equals(tag) ? wallpaper : lockWallpaper;
|
||||
|
||||
parseWallpaperAttributes(parser, wallpaperToParse, keepDimensionHints);
|
||||
|
||||
// A system wallpaper might also be a live wallpaper
|
||||
String comp = parser.getAttributeValue(null, "component");
|
||||
wallpaper.nextWallpaperComponent = comp != null
|
||||
wallpaperToParse.nextWallpaperComponent = comp != null
|
||||
? ComponentName.unflattenFromString(comp)
|
||||
: null;
|
||||
if (wallpaper.nextWallpaperComponent == null
|
||||
|| "android".equals(wallpaper.nextWallpaperComponent
|
||||
if (wallpaperToParse.nextWallpaperComponent == null
|
||||
|| "android".equals(wallpaperToParse.nextWallpaperComponent
|
||||
.getPackageName())) {
|
||||
wallpaper.nextWallpaperComponent = mImageWallpaper;
|
||||
wallpaperToParse.nextWallpaperComponent = mImageWallpaper;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
|
||||
@@ -1599,14 +1599,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
|
||||
dm.registerDisplayListener(mDisplayListener, null /* handler */);
|
||||
mWallpaperDisplayHelper = new WallpaperDisplayHelper(dm, mWindowManagerInternal);
|
||||
mWallpaperCropper = new WallpaperCropper(mWallpaperDisplayHelper);
|
||||
mWallpaperDataParser = new WallpaperDataParser(
|
||||
mContext, mWallpaperDisplayHelper, mWallpaperCropper);
|
||||
mActivityManager = mContext.getSystemService(ActivityManager.class);
|
||||
mMonitor = new MyPackageMonitor();
|
||||
mColorsChangedListeners = new SparseArray<>();
|
||||
|
||||
mEnableSeparateLockScreenEngine = mContext.getResources().getBoolean(
|
||||
R.bool.config_independentLockscreenLiveWallpaper);
|
||||
mWallpaperDataParser = new WallpaperDataParser(mContext, mWallpaperDisplayHelper,
|
||||
mWallpaperCropper, mEnableSeparateLockScreenEngine);
|
||||
if (DEBUG) {
|
||||
Slog.v(TAG, "Separate lock screen engine enabled: " + mEnableSeparateLockScreenEngine);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user