Loading services/core/java/com/android/server/am/ActivityManagerService.java +15 −1 Original line number Diff line number Diff line Loading @@ -13407,8 +13407,12 @@ public class ActivityManagerService extends IActivityManager.Stub public void setRenderThread(int tid) { synchronized (this) { ProcessRecord proc; synchronized (mPidsSelfLocked) { int pid = Binder.getCallingPid(); if (pid == Process.myPid()) { demoteSystemServerRenderThread(tid); return; } synchronized (mPidsSelfLocked) { proc = mPidsSelfLocked.get(pid); if (proc != null && proc.renderThreadTid == 0 && tid > 0) { // ensure the tid belongs to the process Loading Loading @@ -13441,6 +13445,16 @@ public class ActivityManagerService extends IActivityManager.Stub } } /** * We only use RenderThread in system_server to store task snapshots to the disk, which should * happen in the background. Thus, demote render thread from system_server to a lower priority. * * @param tid the tid of the RenderThread */ private void demoteSystemServerRenderThread(int tid) { setThreadPriority(tid, Process.THREAD_PRIORITY_BACKGROUND); } @Override public int setVrMode(IBinder token, boolean enabled, ComponentName packageName) { if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_VR_MODE)) { services/core/java/com/android/server/wm/TaskSnapshotController.java +9 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,15 @@ class TaskSnapshotController { mPersister.removeObsoleteFiles(persistentTaskIds, runningUserIds); } /** * Temporarily pauses/unpauses persisting of task snapshots. * * @param paused Whether task snapshot persisting should be paused. */ void setPersisterPaused(boolean paused) { mPersister.setPaused(paused); } void dump(PrintWriter pw, String prefix) { mCache.dump(pw, prefix); } Loading services/core/java/com/android/server/wm/TaskSnapshotPersister.java +19 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ class TaskSnapshotPersister { private final ArrayDeque<WriteQueueItem> mWriteQueue = new ArrayDeque<>(); @GuardedBy("mLock") private boolean mQueueIdling; @GuardedBy("mLock") private boolean mPaused; private boolean mStarted; private final Object mLock = new Object(); private final DirectoryResolver mDirectoryResolver; Loading Loading @@ -127,6 +129,15 @@ class TaskSnapshotPersister { } } void setPaused(boolean paused) { synchronized (mLock) { mPaused = paused; if (!paused) { mLock.notifyAll(); } } } @TestApi void waitForQueueEmpty() { while (true) { Loading @@ -142,8 +153,10 @@ class TaskSnapshotPersister { @GuardedBy("mLock") private void sendToQueueLocked(WriteQueueItem item) { mWriteQueue.offer(item); if (!mPaused) { mLock.notifyAll(); } } private File getDirectory(int userId) { return new File(mDirectoryResolver.getSystemDirectoryForUser(userId), SNAPSHOTS_DIRNAME); Loading Loading @@ -185,8 +198,12 @@ class TaskSnapshotPersister { while (true) { WriteQueueItem next; synchronized (mLock) { if (mPaused) { next = null; } else { next = mWriteQueue.poll(); } } if (next != null) { next.write(); SystemClock.sleep(DELAY_MS); Loading services/core/java/com/android/server/wm/WindowAnimator.java +9 −2 Original line number Diff line number Diff line Loading @@ -255,12 +255,19 @@ public class WindowAnimator { mWindowPlacerLocked.requestTraversal(); } if (mAnimating && !wasAnimating && Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { if (mAnimating && !wasAnimating) { // Usually app transitions but quite a load onto the system already (with all the things // happening in app), so pause task snapshot persisting to not increase the load. mService.mTaskSnapshotController.setPersisterPaused(true); if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0); } } if (!mAnimating && wasAnimating) { mWindowPlacerLocked.requestTraversal(); mService.mTaskSnapshotController.setPersisterPaused(false); if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0); } Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +15 −1 Original line number Diff line number Diff line Loading @@ -13407,8 +13407,12 @@ public class ActivityManagerService extends IActivityManager.Stub public void setRenderThread(int tid) { synchronized (this) { ProcessRecord proc; synchronized (mPidsSelfLocked) { int pid = Binder.getCallingPid(); if (pid == Process.myPid()) { demoteSystemServerRenderThread(tid); return; } synchronized (mPidsSelfLocked) { proc = mPidsSelfLocked.get(pid); if (proc != null && proc.renderThreadTid == 0 && tid > 0) { // ensure the tid belongs to the process Loading Loading @@ -13441,6 +13445,16 @@ public class ActivityManagerService extends IActivityManager.Stub } } /** * We only use RenderThread in system_server to store task snapshots to the disk, which should * happen in the background. Thus, demote render thread from system_server to a lower priority. * * @param tid the tid of the RenderThread */ private void demoteSystemServerRenderThread(int tid) { setThreadPriority(tid, Process.THREAD_PRIORITY_BACKGROUND); } @Override public int setVrMode(IBinder token, boolean enabled, ComponentName packageName) { if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_VR_MODE)) {
services/core/java/com/android/server/wm/TaskSnapshotController.java +9 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,15 @@ class TaskSnapshotController { mPersister.removeObsoleteFiles(persistentTaskIds, runningUserIds); } /** * Temporarily pauses/unpauses persisting of task snapshots. * * @param paused Whether task snapshot persisting should be paused. */ void setPersisterPaused(boolean paused) { mPersister.setPaused(paused); } void dump(PrintWriter pw, String prefix) { mCache.dump(pw, prefix); } Loading
services/core/java/com/android/server/wm/TaskSnapshotPersister.java +19 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ class TaskSnapshotPersister { private final ArrayDeque<WriteQueueItem> mWriteQueue = new ArrayDeque<>(); @GuardedBy("mLock") private boolean mQueueIdling; @GuardedBy("mLock") private boolean mPaused; private boolean mStarted; private final Object mLock = new Object(); private final DirectoryResolver mDirectoryResolver; Loading Loading @@ -127,6 +129,15 @@ class TaskSnapshotPersister { } } void setPaused(boolean paused) { synchronized (mLock) { mPaused = paused; if (!paused) { mLock.notifyAll(); } } } @TestApi void waitForQueueEmpty() { while (true) { Loading @@ -142,8 +153,10 @@ class TaskSnapshotPersister { @GuardedBy("mLock") private void sendToQueueLocked(WriteQueueItem item) { mWriteQueue.offer(item); if (!mPaused) { mLock.notifyAll(); } } private File getDirectory(int userId) { return new File(mDirectoryResolver.getSystemDirectoryForUser(userId), SNAPSHOTS_DIRNAME); Loading Loading @@ -185,8 +198,12 @@ class TaskSnapshotPersister { while (true) { WriteQueueItem next; synchronized (mLock) { if (mPaused) { next = null; } else { next = mWriteQueue.poll(); } } if (next != null) { next.write(); SystemClock.sleep(DELAY_MS); Loading
services/core/java/com/android/server/wm/WindowAnimator.java +9 −2 Original line number Diff line number Diff line Loading @@ -255,12 +255,19 @@ public class WindowAnimator { mWindowPlacerLocked.requestTraversal(); } if (mAnimating && !wasAnimating && Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { if (mAnimating && !wasAnimating) { // Usually app transitions but quite a load onto the system already (with all the things // happening in app), so pause task snapshot persisting to not increase the load. mService.mTaskSnapshotController.setPersisterPaused(true); if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0); } } if (!mAnimating && wasAnimating) { mWindowPlacerLocked.requestTraversal(); mService.mTaskSnapshotController.setPersisterPaused(false); if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0); } Loading