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

Commit 38a5dc33 authored by Christopher Tate's avatar Christopher Tate
Browse files

Run the SELinux wallpaper restorecon operations on all users

And only run them once per device boot lifetime.

Bug 30229410

Change-Id: Ia6f7f7eea7f8985c83b531dfa16e96d08235b901
parent 50805412
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -487,6 +487,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
    final SparseArray<WallpaperData> mWallpaperMap = new SparseArray<WallpaperData>();
    final SparseArray<WallpaperData> mLockWallpaperMap = new SparseArray<WallpaperData>();

    final SparseArray<Boolean> mUserRestorecon = new SparseArray<Boolean>();
    int mCurrentUserId;

    static class WallpaperData {
@@ -944,13 +945,18 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {

    void onUnlockUser(final int userId) {
        synchronized (mLock) {
            if (mCurrentUserId == userId && mWaitingForUnlock) {
            if (mCurrentUserId == userId) {
                if (mWaitingForUnlock) {
                    // If we're switching users, now is when we transition the wallpaper
                    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.
                if (mUserRestorecon.get(userId) != Boolean.TRUE) {
                    mUserRestorecon.put(userId, Boolean.TRUE);
                    Runnable relabeler = new Runnable() {
                        @Override
                        public void run() {
@@ -967,6 +973,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
                }
            }
        }
    }

    void onRemoveUser(int userId) {
        if (userId < 1) return;