Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52d750c5 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Check which file changed before requesting backup

Make sure that the changed file is one of the wallpaper files
before requesting backup or informing listeners.

Bug: 18694053
Change-Id: Iaa8fe9d3c97634b3cc6a9ccd67c36cf394d17ca0
parent 6bdbae07
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
        final WallpaperData mWallpaper;
        final File mWallpaperDir;
        final File mWallpaperFile;
        final File mWallpaperInfoFile;

        public WallpaperObserver(WallpaperData wallpaper) {
            super(getWallpaperDir(wallpaper.userId).getAbsolutePath(),
@@ -123,6 +124,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
            mWallpaperDir = getWallpaperDir(wallpaper.userId);
            mWallpaper = wallpaper;
            mWallpaperFile = new File(mWallpaperDir, WALLPAPER);
            mWallpaperInfoFile = new File(mWallpaperDir, WALLPAPER_INFO);
        }

        @Override
@@ -131,13 +133,15 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
                return;
            }
            synchronized (mLock) {
                File changedFile = new File(mWallpaperDir, path);
                if (mWallpaperFile.equals(changedFile)
                        || mWallpaperInfoFile.equals(changedFile)) {
                    // changing the wallpaper means we'll need to back up the new one
                    long origId = Binder.clearCallingIdentity();
                    BackupManager bm = new BackupManager(mContext);
                    bm.dataChanged();
                    Binder.restoreCallingIdentity(origId);

                File changedFile = new File(mWallpaperDir, path);
                }
                if (mWallpaperFile.equals(changedFile)) {
                    notifyCallbacksLocked(mWallpaper);
                    final boolean written = (event == CLOSE_WRITE || event == MOVED_TO);