summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Svetoslav <svetoslavganov@google.com> 2014-09-05 02:02:46 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2014-09-05 02:02:47 +0000
commita88e8926ab14edee03d03a5058168b2e0f6d95cc (patch)
tree7cd3901a57223eb85dd1ba99292a7d20d5d73928
parentf634c08b57256bf236c00ce1e917f6299d34e8a1 (diff)
parentc82768ff4b045b5b4edc08405964d504438a681f (diff)
Merge "Handle user changes off the main thread." into lmp-dev
-rw-r--r--services/print/java/com/android/server/print/PrintManagerService.java48
1 files changed, 31 insertions, 17 deletions
diff --git a/services/print/java/com/android/server/print/PrintManagerService.java b/services/print/java/com/android/server/print/PrintManagerService.java
index 64242ba7e0a0..6785cb8df220 100644
--- a/services/print/java/com/android/server/print/PrintManagerService.java
+++ b/services/print/java/com/android/server/print/PrintManagerService.java
@@ -627,26 +627,40 @@ public final class PrintManagerService extends SystemService {
return userState;
}
- private void handleUserStarted(int userId) {
- UserState userState;
- synchronized (mLock) {
- userState = getOrCreateUserStateLocked(userId);
- userState.updateIfNeededLocked();
- }
- // This is the first time we switch to this user after boot, so
- // now is the time to remove obsolete print jobs since they
- // are from the last boot and no application would query them.
- userState.removeObsoletePrintJobs();
+ private void handleUserStarted(final int userId) {
+ // This code will touch the remote print spooler which
+ // must be called off the main thread, so post the work.
+ BackgroundThread.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ UserState userState;
+ synchronized (mLock) {
+ userState = getOrCreateUserStateLocked(userId);
+ userState.updateIfNeededLocked();
+ }
+ // This is the first time we switch to this user after boot, so
+ // now is the time to remove obsolete print jobs since they
+ // are from the last boot and no application would query them.
+ userState.removeObsoletePrintJobs();
+ }
+ });
}
- private void handleUserStopped(int userId) {
- synchronized (mLock) {
- UserState userState = mUserStates.get(userId);
- if (userState != null) {
- userState.destroyLocked();
- mUserStates.remove(userId);
+ private void handleUserStopped(final int userId) {
+ // This code will touch the remote print spooler which
+ // must be called off the main thread, so post the work.
+ BackgroundThread.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ synchronized (mLock) {
+ UserState userState = mUserStates.get(userId);
+ if (userState != null) {
+ userState.destroyLocked();
+ mUserStates.remove(userId);
+ }
+ }
}
- }
+ });
}
private int resolveCallingProfileParentLocked(int userId) {