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

Commit 6e78e3a9 authored by Christopher Tate's avatar Christopher Tate Committed by android-build-merger
Browse files

Merge \"Fix up mangled SELinux labeling of wallpaper files\" into nyc-mr1-dev

am: 87488ac8

Change-Id: Ib983d7f56e21ae61679edb89e5c2373c7e7c08d9
parents 10d3f985 87488ac8
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import android.view.WindowManager;

import com.android.internal.R;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.JournaledFile;
import com.android.server.EventLogTags;
@@ -175,7 +176,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
        final File mWallpaperDir;
        final File mWallpaperFile;
        final File mWallpaperLockFile;
        final File mWallpaperInfoFile;

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

        private WallpaperData dataForEvent(boolean sysChanged, boolean lockChanged) {
@@ -943,10 +942,28 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
        mLockWallpaperMap.remove(userId);
    }

    void onUnlockUser(int userId) {
    void onUnlockUser(final int userId) {
        synchronized (mLock) {
            if (mCurrentUserId == userId && mWaitingForUnlock) {
                switchUser(userId, null);

                // Make sure that the SELinux labeling of all the relevant files is correct.
                // This corrects for mislabeling bugs that might have arisen from move-to
                // operations involving the wallpaper files.  This isn't timing-critical,
                // so we do it in the background to avoid holding up the user unlock operation.
                Runnable relabeler = new Runnable() {
                    @Override
                    public void run() {
                        final File wallpaperDir = getWallpaperDir(userId);
                        for (String filename : sPerUserFiles) {
                            File f = new File(wallpaperDir, filename);
                            if (f.exists()) {
                                SELinux.restorecon(f);
                            }
                        }
                    }
                };
                BackgroundThread.getHandler().post(relabeler);
            }
        }
    }