summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2013-09-24 20:37:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-24 20:37:59 +0000
commit0d38d0b42fba7dc50454d5c0652cf351c58a9db6 (patch)
tree6c21f1718a04d83e506be5a5a9996598b84f6fcc /services
parent08df7d9137bd90c57623bc9cc9db3629e3a945eb (diff)
parentb5f180608db6de123b54ae94de569ff1ebca705c (diff)
downloadframeworks_base-0d38d0b42fba7dc50454d5c0652cf351c58a9db6.zip
frameworks_base-0d38d0b42fba7dc50454d5c0652cf351c58a9db6.tar.gz
frameworks_base-0d38d0b42fba7dc50454d5c0652cf351c58a9db6.tar.bz2
Merge "Multiple printer discovery session instances and other bugs." into klp-dev
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/print/RemotePrintService.java17
-rw-r--r--services/java/com/android/server/print/UserState.java17
2 files changed, 23 insertions, 11 deletions
diff --git a/services/java/com/android/server/print/RemotePrintService.java b/services/java/com/android/server/print/RemotePrintService.java
index a20973e..5b9dc28 100644
--- a/services/java/com/android/server/print/RemotePrintService.java
+++ b/services/java/com/android/server/print/RemotePrintService.java
@@ -85,7 +85,7 @@ final class RemotePrintService implements DeathRecipient {
private boolean mHasPrinterDiscoverySession;
- private boolean mServiceDead;
+ private boolean mServiceDied;
private List<PrinterId> mDiscoveryPriorityList;
@@ -107,7 +107,6 @@ final class RemotePrintService implements DeathRecipient {
mSpooler = spooler;
mHandler = new MyHandler(context.getMainLooper());
mPrintServiceClient = new RemotePrintServiceClient(this);
- mServiceDead = true;
}
public ComponentName getComponentName() {
@@ -157,7 +156,7 @@ final class RemotePrintService implements DeathRecipient {
private void handleBinderDied() {
mPrintService.asBinder().unlinkToDeath(this, 0);
mPrintService = null;
- mServiceDead = true;
+ mServiceDied = true;
mCallbacks.onServiceDied(this);
}
@@ -171,7 +170,7 @@ final class RemotePrintService implements DeathRecipient {
if (!isBound()) {
// The service is dead and neither has active jobs nor discovery
// session, so ensure we are unbound since the service has no work.
- if (mServiceDead && !mHasPrinterDiscoverySession) {
+ if (mServiceDied && !mHasPrinterDiscoverySession) {
ensureUnbound();
return;
}
@@ -286,7 +285,7 @@ final class RemotePrintService implements DeathRecipient {
if (!isBound()) {
// The service is dead and neither has active jobs nor discovery
// session, so ensure we are unbound since the service has no work.
- if (mServiceDead && !mHasActivePrintJobs) {
+ if (mServiceDied && !mHasActivePrintJobs) {
ensureUnbound();
return;
}
@@ -556,15 +555,15 @@ final class RemotePrintService implements DeathRecipient {
return;
}
// If the service died and there is a discovery session, recreate it.
- if (mServiceDead && mHasPrinterDiscoverySession) {
+ if (mServiceDied && mHasPrinterDiscoverySession) {
handleCreatePrinterDiscoverySession();
}
// If the service died and there is discovery started, restart it.
- if (mServiceDead && mDiscoveryPriorityList != null) {
+ if (mServiceDied && mDiscoveryPriorityList != null) {
handleStartPrinterDiscovery(mDiscoveryPriorityList);
}
// If the service died and printers were tracked, start tracking.
- if (mServiceDead && mTrackedPrinterList != null) {
+ if (mServiceDied && mTrackedPrinterList != null) {
final int trackedPrinterCount = mTrackedPrinterList.size();
for (int i = 0; i < trackedPrinterCount; i++) {
handleStartPrinterStateTracking(mTrackedPrinterList.get(i));
@@ -581,7 +580,7 @@ final class RemotePrintService implements DeathRecipient {
if (!mHasPrinterDiscoverySession && !mHasActivePrintJobs) {
ensureUnbound();
}
- mServiceDead = false;
+ mServiceDied = false;
}
@Override
diff --git a/services/java/com/android/server/print/UserState.java b/services/java/com/android/server/print/UserState.java
index fd4a3a4..8c21827 100644
--- a/services/java/com/android/server/print/UserState.java
+++ b/services/java/com/android/server/print/UserState.java
@@ -1007,12 +1007,25 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
mHandler.obtainMessage(
SessionHandler.MSG_CREATE_PRINTER_DISCOVERY_SESSION,
service).sendToTarget();
- // If there are some observers that started discovery - tell the service.
- if (mDiscoveryObservers.getRegisteredCallbackCount() > 0) {
+ // Start printer discovery if necessary.
+ if (!mStartedPrinterDiscoveryTokens.isEmpty()) {
mHandler.obtainMessage(
SessionHandler.MSG_START_PRINTER_DISCOVERY,
service).sendToTarget();
}
+ // Start tracking printers if necessary
+ final int trackedPrinterCount = mStateTrackedPrinters.size();
+ for (int i = 0; i < trackedPrinterCount; i++) {
+ PrinterId printerId = mStateTrackedPrinters.get(i);
+ if (printerId.getServiceName().equals(service.getComponentName())) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = service;
+ args.arg2 = printerId;
+ mHandler.obtainMessage(SessionHandler
+ .MSG_START_PRINTER_STATE_TRACKING, args)
+ .sendToTarget();
+ }
+ }
}
public void dump(PrintWriter pw, String prefix) {