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

Commit 4e2cbb50 authored by Felipe Leme's avatar Felipe Leme
Browse files

Added tracing to multi-user operations on WallpaperManagerService.

Bug: 145558164
Test: adb logcat WallpaperManagerService *:s

Change-Id: Iacd0b3fad4f49efeebe092bb47a26a69ae226447
parent 15c81edf
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -55,7 +55,16 @@ public final class TimingsTraceAndSlog extends TimingsTraceLog {
     * Default constructor using {@code system_server} tags.
     */
    public TimingsTraceAndSlog() {
        this(SYSTEM_SERVER_TIMING_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
        this(SYSTEM_SERVER_TIMING_TAG);
    }

    /**
     * Custom constructor using {@code system_server} trace tag.
     *
     * @param tag {@code logcat} tag
     */
    public TimingsTraceAndSlog(@NonNull String tag) {
        this(tag, Trace.TRACE_TAG_SYSTEM_SERVER);
    }

    /**
+55 −45
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ import com.android.server.EventLogTags;
import com.android.server.FgThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.utils.TimingsTraceAndSlog;
import com.android.server.wm.WindowManagerInternal;

import libcore.io.IoUtils;
@@ -1785,6 +1786,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub

    @Override
    public void onUnlockUser(final int userId) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
        t.traceBegin("on-unlock-user-" + userId);
        try {
            synchronized (mLock) {
                if (mCurrentUserId == userId) {
                    if (mWaitingForUnlock) {
@@ -1801,9 +1805,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    // so we do it in the background to avoid holding up the user unlock operation.
                    if (!mUserRestorecon.get(userId)) {
                        mUserRestorecon.put(userId, true);
                    Runnable relabeler = new Runnable() {
                        @Override
                        public void run() {
                        Runnable relabeler = () -> {
                            final File wallpaperDir = getWallpaperDir(userId);
                            for (String filename : sPerUserFiles) {
                                File f = new File(wallpaperDir, filename);
@@ -1811,12 +1813,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                                    SELinux.restorecon(f);
                                }
                            }
                        }
                        };
                        BackgroundThread.getHandler().post(relabeler);
                    }
                }
            }
        } finally {
            t.traceEnd();
        }
    }

    void onRemoveUser(int userId) {
@@ -1833,6 +1837,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
    }

    void switchUser(int userId, IRemoteCallback reply) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
        t.traceBegin("switch-user-" + userId);
        try {
            final WallpaperData systemWallpaper;
            final WallpaperData lockWallpaper;
            synchronized (mLock) {
@@ -1858,6 +1865,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                notifyWallpaperColorsChanged(lockWallpaper, FLAG_LOCK);
                notifyWallpaperColorsChanged(mFallbackWallpaper, FLAG_SYSTEM);
            });
        } finally {
            t.traceEnd();
        }
    }

    void switchWallpaper(WallpaperData wallpaper, IRemoteCallback reply) {