Loading services/core/java/com/android/server/wallpaper/WallpaperData.java +22 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,28 @@ class WallpaperData { */ final Rect cropHint = new Rect(0, 0, 0, 0); // Describes the context of a call to WallpaperManagerService#bindWallpaperComponentLocked enum BindSource { UNKNOWN, CONNECT_LOCKED, CONNECTION_TRY_TO_REBIND, INITIALIZE_FALLBACK, PACKAGE_UPDATE_FINISHED, RESTORE_SETTINGS_LIVE_FAILURE, RESTORE_SETTINGS_LIVE_SUCCESS, RESTORE_SETTINGS_STATIC, SET_LIVE, SET_LIVE_TO_CLEAR, SET_STATIC, SWITCH_WALLPAPER_FAILURE, SWITCH_WALLPAPER_SWITCH_USER, SWITCH_WALLPAPER_UNLOCK_USER, } // Context in which this wallpaper was bound. Intended for use in resolving b/301073479 but may // be useful after the issue is resolved as well. BindSource mBindSource = BindSource.UNKNOWN; // map of which -> File private final SparseArray<File> mWallpaperFiles = new SparseArray<>(); private final SparseArray<File> mCropFiles = new SparseArray<>(); Loading services/core/java/com/android/server/wallpaper/WallpaperDataParser.java +15 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.JournaledFile; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.server.wallpaper.WallpaperData.BindSource; import libcore.io.IoUtils; Loading Loading @@ -314,6 +315,14 @@ class WallpaperDataParser { wpData.mPadding.right = getAttributeInt(parser, "paddingRight", 0); wpData.mPadding.bottom = getAttributeInt(parser, "paddingBottom", 0); wallpaper.mWallpaperDimAmount = getAttributeFloat(parser, "dimAmount", 0f); BindSource bindSource; try { bindSource = Enum.valueOf(BindSource.class, getAttributeString(parser, "bindSource", BindSource.UNKNOWN.name())); } catch (IllegalArgumentException | NullPointerException e) { bindSource = BindSource.UNKNOWN; } wallpaper.mBindSource = bindSource; int dimAmountsCount = getAttributeInt(parser, "dimAmountsCount", 0); if (dimAmountsCount > 0) { SparseArray<Float> allDimAmounts = new SparseArray<>(dimAmountsCount); Loading Loading @@ -364,6 +373,11 @@ class WallpaperDataParser { return parser.getAttributeFloat(null, name, defValue); } private String getAttributeString(XmlPullParser parser, String name, String defValue) { String s = parser.getAttributeValue(null, name); return (s != null) ? s : defValue; } void saveSettingsLocked(int userId, WallpaperData wallpaper, WallpaperData lockWallpaper) { JournaledFile journal = makeJournaledFile(userId); FileOutputStream fstream = null; Loading Loading @@ -423,6 +437,7 @@ class WallpaperDataParser { } out.attributeFloat(null, "dimAmount", wallpaper.mWallpaperDimAmount); out.attribute(null, "bindSource", wallpaper.mBindSource.name()); int dimAmountsCount = wallpaper.mUidToDimAmount.size(); out.attributeInt(null, "dimAmountsCount", dimAmountsCount); if (dimAmountsCount > 0) { Loading services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +17 −1 Original line number Diff line number Diff line Loading @@ -122,6 +122,7 @@ import com.android.server.ServiceThread; import com.android.server.SystemService; import com.android.server.pm.UserManagerInternal; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wallpaper.WallpaperData.BindSource; import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -335,6 +336,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub }; // If this was the system wallpaper, rebind... wallpaper.mBindSource = BindSource.SET_STATIC; bindWallpaperComponentLocked(mImageWallpaper, true, false, wallpaper, callback); } Loading @@ -354,6 +356,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } }; wallpaper.mBindSource = BindSource.SET_STATIC; bindWallpaperComponentLocked(mImageWallpaper, true /* force */, false /* fromUser */, wallpaper, callback); } else if (isAppliedToLock) { Loading Loading @@ -811,6 +814,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub Slog.w(TAG, "Failed attaching wallpaper on display", e); if (wallpaper != null && !wallpaper.wallpaperUpdating && connection.getConnectedEngineSize() == 0) { wallpaper.mBindSource = BindSource.CONNECT_LOCKED; bindWallpaperComponentLocked(null /* componentName */, false /* force */, false /* fromUser */, wallpaper, null /* reply */); } Loading Loading @@ -1035,6 +1039,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub final ComponentName wpService = mWallpaper.wallpaperComponent; // The broadcast of package update could be delayed after service disconnected. Try // to re-bind the service for 10 seconds. mWallpaper.mBindSource = BindSource.CONNECTION_TRY_TO_REBIND; if (bindWallpaperComponentLocked( wpService, true, false, mWallpaper, null)) { mWallpaper.connection.scheduleTimeoutLocked(); Loading Loading @@ -1321,6 +1326,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } wallpaper.wallpaperUpdating = false; clearWallpaperComponentLocked(wallpaper); wallpaper.mBindSource = BindSource.PACKAGE_UPDATE_FINISHED; if (!bindWallpaperComponentLocked(wpService, false, false, wallpaper, null)) { Slog.w(TAG, "Wallpaper " + wpService Loading Loading @@ -1711,6 +1717,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mHomeWallpaperWaitingForUnlock) { final WallpaperData systemWallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM); systemWallpaper.mBindSource = BindSource.SWITCH_WALLPAPER_UNLOCK_USER; switchWallpaper(systemWallpaper, null); // TODO(b/278261563): call notifyCallbacksLocked inside switchWallpaper notifyCallbacksLocked(systemWallpaper); Loading @@ -1718,6 +1725,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mLockWallpaperWaitingForUnlock) { final WallpaperData lockWallpaper = getWallpaperSafeLocked(userId, FLAG_LOCK); lockWallpaper.mBindSource = BindSource.SWITCH_WALLPAPER_UNLOCK_USER; switchWallpaper(lockWallpaper, null); notifyCallbacksLocked(lockWallpaper); } Loading Loading @@ -1838,6 +1846,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // delete them in order to show the default wallpaper. clearWallpaperBitmaps(wallpaper); fallback.mBindSource = BindSource.SWITCH_WALLPAPER_FAILURE; bindWallpaperComponentLocked(mImageWallpaper, true, false, fallback, reply); if ((wallpaper.mWhich & FLAG_SYSTEM) != 0) mHomeWallpaperWaitingForUnlock = true; if ((wallpaper.mWhich & FLAG_LOCK) != 0) mLockWallpaperWaitingForUnlock = true; Loading Loading @@ -2963,6 +2972,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub */ boolean forceRebind = force || (same && systemIsBoth && which == FLAG_SYSTEM); newWallpaper.mBindSource = (name == null) ? BindSource.SET_LIVE_TO_CLEAR : BindSource.SET_LIVE; bindSuccess = bindWallpaperComponentLocked(name, /* force */ forceRebind, /* fromUser */ true, newWallpaper, reply); if (bindSuccess) { Loading Loading @@ -3530,6 +3541,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub mFallbackWallpaper = new WallpaperData(systemUserId, FLAG_SYSTEM); mFallbackWallpaper.allowBackup = false; mFallbackWallpaper.wallpaperId = makeWallpaperIdLocked(); mFallbackWallpaper.mBindSource = BindSource.INITIALIZE_FALLBACK; bindWallpaperComponentLocked(mDefaultWallpaperComponent, true, false, mFallbackWallpaper, null); } Loading @@ -3553,11 +3565,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub wallpaper.allowBackup = true; // by definition if it was restored if (wallpaper.nextWallpaperComponent != null && !wallpaper.nextWallpaperComponent.equals(mImageWallpaper)) { wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_LIVE_SUCCESS; if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false, wallpaper, null)) { // No such live wallpaper or other failure; fall back to the default // live wallpaper (since the profile being restored indicated that the // user had selected a live rather than static one). wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_LIVE_FAILURE; bindWallpaperComponentLocked(null, false, false, wallpaper, null); } success = true; Loading @@ -3575,6 +3589,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub + " id=" + wallpaper.wallpaperId); if (success) { mWallpaperCropper.generateCrop(wallpaper); // based on the new image + metadata wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_STATIC; bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, true, false, wallpaper, null); } Loading Loading @@ -3608,7 +3623,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub pw.print(" User "); pw.print(wallpaper.userId); pw.print(": id="); pw.print(wallpaper.wallpaperId); pw.print(": mWhich="); pw.print(wallpaper.mWhich); pw.print(": mSystemWasBoth="); pw.println(wallpaper.mSystemWasBoth); pw.print(": mSystemWasBoth="); pw.print(wallpaper.mSystemWasBoth); pw.print(": mBindSource="); pw.println(wallpaper.mBindSource.name()); pw.println(" Display state:"); mWallpaperDisplayHelper.forEachDisplayData(wpSize -> { pw.print(" displayId="); Loading Loading
services/core/java/com/android/server/wallpaper/WallpaperData.java +22 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,28 @@ class WallpaperData { */ final Rect cropHint = new Rect(0, 0, 0, 0); // Describes the context of a call to WallpaperManagerService#bindWallpaperComponentLocked enum BindSource { UNKNOWN, CONNECT_LOCKED, CONNECTION_TRY_TO_REBIND, INITIALIZE_FALLBACK, PACKAGE_UPDATE_FINISHED, RESTORE_SETTINGS_LIVE_FAILURE, RESTORE_SETTINGS_LIVE_SUCCESS, RESTORE_SETTINGS_STATIC, SET_LIVE, SET_LIVE_TO_CLEAR, SET_STATIC, SWITCH_WALLPAPER_FAILURE, SWITCH_WALLPAPER_SWITCH_USER, SWITCH_WALLPAPER_UNLOCK_USER, } // Context in which this wallpaper was bound. Intended for use in resolving b/301073479 but may // be useful after the issue is resolved as well. BindSource mBindSource = BindSource.UNKNOWN; // map of which -> File private final SparseArray<File> mWallpaperFiles = new SparseArray<>(); private final SparseArray<File> mCropFiles = new SparseArray<>(); Loading
services/core/java/com/android/server/wallpaper/WallpaperDataParser.java +15 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.JournaledFile; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.server.wallpaper.WallpaperData.BindSource; import libcore.io.IoUtils; Loading Loading @@ -314,6 +315,14 @@ class WallpaperDataParser { wpData.mPadding.right = getAttributeInt(parser, "paddingRight", 0); wpData.mPadding.bottom = getAttributeInt(parser, "paddingBottom", 0); wallpaper.mWallpaperDimAmount = getAttributeFloat(parser, "dimAmount", 0f); BindSource bindSource; try { bindSource = Enum.valueOf(BindSource.class, getAttributeString(parser, "bindSource", BindSource.UNKNOWN.name())); } catch (IllegalArgumentException | NullPointerException e) { bindSource = BindSource.UNKNOWN; } wallpaper.mBindSource = bindSource; int dimAmountsCount = getAttributeInt(parser, "dimAmountsCount", 0); if (dimAmountsCount > 0) { SparseArray<Float> allDimAmounts = new SparseArray<>(dimAmountsCount); Loading Loading @@ -364,6 +373,11 @@ class WallpaperDataParser { return parser.getAttributeFloat(null, name, defValue); } private String getAttributeString(XmlPullParser parser, String name, String defValue) { String s = parser.getAttributeValue(null, name); return (s != null) ? s : defValue; } void saveSettingsLocked(int userId, WallpaperData wallpaper, WallpaperData lockWallpaper) { JournaledFile journal = makeJournaledFile(userId); FileOutputStream fstream = null; Loading Loading @@ -423,6 +437,7 @@ class WallpaperDataParser { } out.attributeFloat(null, "dimAmount", wallpaper.mWallpaperDimAmount); out.attribute(null, "bindSource", wallpaper.mBindSource.name()); int dimAmountsCount = wallpaper.mUidToDimAmount.size(); out.attributeInt(null, "dimAmountsCount", dimAmountsCount); if (dimAmountsCount > 0) { Loading
services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +17 −1 Original line number Diff line number Diff line Loading @@ -122,6 +122,7 @@ import com.android.server.ServiceThread; import com.android.server.SystemService; import com.android.server.pm.UserManagerInternal; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wallpaper.WallpaperData.BindSource; import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -335,6 +336,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub }; // If this was the system wallpaper, rebind... wallpaper.mBindSource = BindSource.SET_STATIC; bindWallpaperComponentLocked(mImageWallpaper, true, false, wallpaper, callback); } Loading @@ -354,6 +356,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } }; wallpaper.mBindSource = BindSource.SET_STATIC; bindWallpaperComponentLocked(mImageWallpaper, true /* force */, false /* fromUser */, wallpaper, callback); } else if (isAppliedToLock) { Loading Loading @@ -811,6 +814,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub Slog.w(TAG, "Failed attaching wallpaper on display", e); if (wallpaper != null && !wallpaper.wallpaperUpdating && connection.getConnectedEngineSize() == 0) { wallpaper.mBindSource = BindSource.CONNECT_LOCKED; bindWallpaperComponentLocked(null /* componentName */, false /* force */, false /* fromUser */, wallpaper, null /* reply */); } Loading Loading @@ -1035,6 +1039,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub final ComponentName wpService = mWallpaper.wallpaperComponent; // The broadcast of package update could be delayed after service disconnected. Try // to re-bind the service for 10 seconds. mWallpaper.mBindSource = BindSource.CONNECTION_TRY_TO_REBIND; if (bindWallpaperComponentLocked( wpService, true, false, mWallpaper, null)) { mWallpaper.connection.scheduleTimeoutLocked(); Loading Loading @@ -1321,6 +1326,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } wallpaper.wallpaperUpdating = false; clearWallpaperComponentLocked(wallpaper); wallpaper.mBindSource = BindSource.PACKAGE_UPDATE_FINISHED; if (!bindWallpaperComponentLocked(wpService, false, false, wallpaper, null)) { Slog.w(TAG, "Wallpaper " + wpService Loading Loading @@ -1711,6 +1717,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mHomeWallpaperWaitingForUnlock) { final WallpaperData systemWallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM); systemWallpaper.mBindSource = BindSource.SWITCH_WALLPAPER_UNLOCK_USER; switchWallpaper(systemWallpaper, null); // TODO(b/278261563): call notifyCallbacksLocked inside switchWallpaper notifyCallbacksLocked(systemWallpaper); Loading @@ -1718,6 +1725,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mLockWallpaperWaitingForUnlock) { final WallpaperData lockWallpaper = getWallpaperSafeLocked(userId, FLAG_LOCK); lockWallpaper.mBindSource = BindSource.SWITCH_WALLPAPER_UNLOCK_USER; switchWallpaper(lockWallpaper, null); notifyCallbacksLocked(lockWallpaper); } Loading Loading @@ -1838,6 +1846,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // delete them in order to show the default wallpaper. clearWallpaperBitmaps(wallpaper); fallback.mBindSource = BindSource.SWITCH_WALLPAPER_FAILURE; bindWallpaperComponentLocked(mImageWallpaper, true, false, fallback, reply); if ((wallpaper.mWhich & FLAG_SYSTEM) != 0) mHomeWallpaperWaitingForUnlock = true; if ((wallpaper.mWhich & FLAG_LOCK) != 0) mLockWallpaperWaitingForUnlock = true; Loading Loading @@ -2963,6 +2972,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub */ boolean forceRebind = force || (same && systemIsBoth && which == FLAG_SYSTEM); newWallpaper.mBindSource = (name == null) ? BindSource.SET_LIVE_TO_CLEAR : BindSource.SET_LIVE; bindSuccess = bindWallpaperComponentLocked(name, /* force */ forceRebind, /* fromUser */ true, newWallpaper, reply); if (bindSuccess) { Loading Loading @@ -3530,6 +3541,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub mFallbackWallpaper = new WallpaperData(systemUserId, FLAG_SYSTEM); mFallbackWallpaper.allowBackup = false; mFallbackWallpaper.wallpaperId = makeWallpaperIdLocked(); mFallbackWallpaper.mBindSource = BindSource.INITIALIZE_FALLBACK; bindWallpaperComponentLocked(mDefaultWallpaperComponent, true, false, mFallbackWallpaper, null); } Loading @@ -3553,11 +3565,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub wallpaper.allowBackup = true; // by definition if it was restored if (wallpaper.nextWallpaperComponent != null && !wallpaper.nextWallpaperComponent.equals(mImageWallpaper)) { wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_LIVE_SUCCESS; if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false, wallpaper, null)) { // No such live wallpaper or other failure; fall back to the default // live wallpaper (since the profile being restored indicated that the // user had selected a live rather than static one). wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_LIVE_FAILURE; bindWallpaperComponentLocked(null, false, false, wallpaper, null); } success = true; Loading @@ -3575,6 +3589,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub + " id=" + wallpaper.wallpaperId); if (success) { mWallpaperCropper.generateCrop(wallpaper); // based on the new image + metadata wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_STATIC; bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, true, false, wallpaper, null); } Loading Loading @@ -3608,7 +3623,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub pw.print(" User "); pw.print(wallpaper.userId); pw.print(": id="); pw.print(wallpaper.wallpaperId); pw.print(": mWhich="); pw.print(wallpaper.mWhich); pw.print(": mSystemWasBoth="); pw.println(wallpaper.mSystemWasBoth); pw.print(": mSystemWasBoth="); pw.print(wallpaper.mSystemWasBoth); pw.print(": mBindSource="); pw.println(wallpaper.mBindSource.name()); pw.println(" Display state:"); mWallpaperDisplayHelper.forEachDisplayData(wpSize -> { pw.print(" displayId="); Loading