OSDN Git Service

RemotePrintDocument might get destroyed in constructor
authorPhilip P. Moltmann <moltmann@google.com>
Tue, 29 Mar 2016 21:47:01 +0000 (14:47 -0700)
committerPhilip P. Moltmann <moltmann@google.com>
Tue, 29 Mar 2016 21:47:04 +0000 (14:47 -0700)
... if it cannot connect to remote PrintDocumentAdapter. Then the state
will be set to destroyed and the print activity will be aborted via the
onDied callback.

Bug: 27899066
Change-Id: Ieb287b92ac21fc71a56b491a1035feaff6cd2837

packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java

index 2d3935b..99145b7 100644 (file)
@@ -178,6 +178,8 @@ public final class RemotePrintDocument {
         }
         if (mState == STATE_FAILED) {
             Log.w(LOG_TAG, "Failed before start.");
+        } else if (mState == STATE_DESTROYED) {
+            Log.w(LOG_TAG, "Destroyed before start.");
         } else {
             if (mState != STATE_INITIAL) {
                 throw new IllegalStateException("Cannot start in state:" + stateToString(mState));
@@ -267,7 +269,7 @@ public final class RemotePrintDocument {
         }
         if (mState != STATE_STARTED && mState != STATE_UPDATED
                 && mState != STATE_FAILED && mState != STATE_CANCELING
-                && mState != STATE_CANCELED) {
+                && mState != STATE_CANCELED && mState != STATE_DESTROYED) {
             throw new IllegalStateException("Cannot finish in state:"
                     + stateToString(mState));
         }