summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Felipe Leme <felipeal@google.com> 2019-12-02 16:46:49 -0800
committer Felipe Leme <felipeal@google.com> 2019-12-02 16:54:35 -0800
commit4e2cbb50cabdcc423e59b8886feed8db66e6d680 (patch)
treefeb0e18f69fc0c3f4a16964559396a8d27f324f2
parent15c81edf433484fdb99ee0bd1369dafd30d33259 (diff)
Added tracing to multi-user operations on WallpaperManagerService.
Bug: 145558164 Test: adb logcat WallpaperManagerService *:s Change-Id: Iacd0b3fad4f49efeebe092bb47a26a69ae226447
-rw-r--r--services/core/java/com/android/server/utils/TimingsTraceAndSlog.java11
-rw-r--r--services/core/java/com/android/server/wallpaper/WallpaperManagerService.java100
2 files changed, 65 insertions, 46 deletions
diff --git a/services/core/java/com/android/server/utils/TimingsTraceAndSlog.java b/services/core/java/com/android/server/utils/TimingsTraceAndSlog.java
index 03c96e99a5ad..6bdb5cea7f9c 100644
--- a/services/core/java/com/android/server/utils/TimingsTraceAndSlog.java
+++ b/services/core/java/com/android/server/utils/TimingsTraceAndSlog.java
@@ -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);
}
/**
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index d66aa18950d0..03139d2e5e03 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -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,25 +1786,26 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
@Override
public void onUnlockUser(final int userId) {
- synchronized (mLock) {
- if (mCurrentUserId == userId) {
- if (mWaitingForUnlock) {
- // the desired wallpaper is not direct-boot aware, load it now
- final WallpaperData systemWallpaper =
- getWallpaperSafeLocked(userId, FLAG_SYSTEM);
- switchWallpaper(systemWallpaper, null);
- notifyCallbacksLocked(systemWallpaper);
- }
-
- // 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)) {
- mUserRestorecon.put(userId, true);
- Runnable relabeler = new Runnable() {
- @Override
- public void run() {
+ TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
+ t.traceBegin("on-unlock-user-" + userId);
+ try {
+ synchronized (mLock) {
+ if (mCurrentUserId == userId) {
+ if (mWaitingForUnlock) {
+ // the desired wallpaper is not direct-boot aware, load it now
+ final WallpaperData systemWallpaper =
+ getWallpaperSafeLocked(userId, FLAG_SYSTEM);
+ switchWallpaper(systemWallpaper, null);
+ notifyCallbacksLocked(systemWallpaper);
+ }
+
+ // 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)) {
+ mUserRestorecon.put(userId, true);
+ Runnable relabeler = () -> {
final File wallpaperDir = getWallpaperDir(userId);
for (String filename : sPerUserFiles) {
File f = new File(wallpaperDir, filename);
@@ -1811,11 +1813,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
SELinux.restorecon(f);
}
}
- }
- };
- BackgroundThread.getHandler().post(relabeler);
+ };
+ BackgroundThread.getHandler().post(relabeler);
+ }
}
}
+ } finally {
+ t.traceEnd();
}
}
@@ -1833,31 +1837,37 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
}
void switchUser(int userId, IRemoteCallback reply) {
- final WallpaperData systemWallpaper;
- final WallpaperData lockWallpaper;
- synchronized (mLock) {
- if (mCurrentUserId == userId) {
- return;
- }
- mCurrentUserId = userId;
- systemWallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM);
- final WallpaperData tmpLockWallpaper = mLockWallpaperMap.get(userId);
- lockWallpaper = tmpLockWallpaper == null ? systemWallpaper : tmpLockWallpaper;
- // Not started watching yet, in case wallpaper data was loaded for other reasons.
- if (systemWallpaper.wallpaperObserver == null) {
- systemWallpaper.wallpaperObserver = new WallpaperObserver(systemWallpaper);
- systemWallpaper.wallpaperObserver.startWatching();
+ TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
+ t.traceBegin("switch-user-" + userId);
+ try {
+ final WallpaperData systemWallpaper;
+ final WallpaperData lockWallpaper;
+ synchronized (mLock) {
+ if (mCurrentUserId == userId) {
+ return;
+ }
+ mCurrentUserId = userId;
+ systemWallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM);
+ final WallpaperData tmpLockWallpaper = mLockWallpaperMap.get(userId);
+ lockWallpaper = tmpLockWallpaper == null ? systemWallpaper : tmpLockWallpaper;
+ // Not started watching yet, in case wallpaper data was loaded for other reasons.
+ if (systemWallpaper.wallpaperObserver == null) {
+ systemWallpaper.wallpaperObserver = new WallpaperObserver(systemWallpaper);
+ systemWallpaper.wallpaperObserver.startWatching();
+ }
+ switchWallpaper(systemWallpaper, reply);
}
- switchWallpaper(systemWallpaper, reply);
- }
- // Offload color extraction to another thread since switchUser will be called
- // from the main thread.
- FgThread.getHandler().post(() -> {
- notifyWallpaperColorsChanged(systemWallpaper, FLAG_SYSTEM);
- notifyWallpaperColorsChanged(lockWallpaper, FLAG_LOCK);
- notifyWallpaperColorsChanged(mFallbackWallpaper, FLAG_SYSTEM);
- });
+ // Offload color extraction to another thread since switchUser will be called
+ // from the main thread.
+ FgThread.getHandler().post(() -> {
+ notifyWallpaperColorsChanged(systemWallpaper, FLAG_SYSTEM);
+ notifyWallpaperColorsChanged(lockWallpaper, FLAG_LOCK);
+ notifyWallpaperColorsChanged(mFallbackWallpaper, FLAG_SYSTEM);
+ });
+ } finally {
+ t.traceEnd();
+ }
}
void switchWallpaper(WallpaperData wallpaper, IRemoteCallback reply) {