865 Commits

Author SHA1 Message Date
Philip P. Moltmann
7134fcc07c RemotePrintDocument might get destroyed in constructor
... 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
2016-03-29 14:47:04 -07:00
Philip P. Moltmann
c7927cb648 Merge "Update printers even if there are no printers found." into nyc-dev 2016-03-28 21:59:40 +00:00
Geoff Mendal
60e532a47f Import translations. DO NOT MERGE
Change-Id: If53b6bafc90089964ee5de76e683bf196160c171
Auto-generated-cl: translation import
2016-03-28 07:27:25 -07:00
Philip P. Moltmann
b5be5ec3b7 Merge "Handle all configuration changes in PrintActivity as it cannot be destroyed synchronously." into nyc-dev 2016-03-26 18:13:24 +00:00
Bill Yi
397fb345ba Import translations. DO NOT MERGE
Change-Id: I311ab683a598426efc4739408be109d766aad721
Auto-generated-cl: translation import
2016-03-25 19:34:39 -07:00
Philip P. Moltmann
ebf397625e Merge "Change hasCustomPrintIcon and setStatus as requested by API council." into nyc-dev 2016-03-25 16:50:36 +00:00
Philip P. Moltmann
d74d1e5491 Change hasCustomPrintIcon and setStatus as requested by API council.
Bonus: null advanced keys produced a exception deep in the print
       spooler. Hence prevent null keys on the surface from now on.

Bug: 27716355
Change-Id: I3c064956f4e670cd7091437ade06605aa8d797b0
2016-03-24 16:53:36 -07:00
Joe Onorato
13460a6cba Turn off verbose logs and remove log that is covered by verbose logs.
Bug: 27744135
Change-Id: I436cfd325f87b3b9205d50e92e2a70a50dd33344
2016-03-24 11:32:17 -07:00
Philip P. Moltmann
940fa80cd1 Handle all configuration changes in PrintActivity as it cannot be
destroyed synchronously.

Also: Always destroy print spooler provider when it was initialized to
      avoid service leakage if print activity was finished after
      onCreate but before onPrinterRegistryReady.

Bug: 27814338
Change-Id: I8401dc6e447cbd726b1a8f7c361b4ddf42e7e11d
2016-03-23 17:04:35 -07:00
Philip P. Moltmann
30b0752ef5 Remove unnecessary strings and labels.
Bug: 27815807
Change-Id: I6388055938afbbadc954c913ce0554f9a4a313e8
2016-03-23 13:32:35 -07:00
Philip P. Moltmann
49435a7295 Merge "Deal with print-preview renderings that do not match the correct number of pages." into nyc-dev 2016-03-23 17:17:40 +00:00
Philip P. Moltmann
b170c08387 Don't mix UI and print job state
In PrintActivity.OnPause we set the print job state based on the
PrintActivity state. The issue was that FINISHED was interpreted as
"cancel print job". Actually with FINISHED does not tell what state the
job should be in.

The only purpose of the finished state was to guard against
double-invocation of doFinish().

Hence remove this recently introduced state and use a simple boolean to
guard against doule invocation of doFinish().

Bug: 27760331
Change-Id: I0767c2b0b9c28e8904647cc832c236f67f92bcfe
2016-03-21 12:53:06 -07:00
Geoff Mendal
c07f2d99da Import translations. DO NOT MERGE
Change-Id: I0d693f0c99347f9d04c7240e07bdd6ea526cb987
Auto-generated-cl: translation import
2016-03-19 14:01:30 +05:30
Philip P. Moltmann
066bf81b98 Deal with print-preview renderings that do not match the correct number
of pages.

If the printing app declares more pages than the print preview pdf has
we used to throw an exception in the PDFManupulationService. This caused
the bitmap to be never written and the read-bitmap function to hang
forever. This was because read() return 0 meaning "pipe is closed" which
lead to an infinite loop. Now a read of 0 page might cause an exception
if the page is not fully read. This exception then causes the
preview_page_error to be displayed.

Bug: 27556666
Change-Id: I7b9de50dce930629e8d38efd4e2659a00b70cc4e
2016-03-18 10:57:32 -07:00
Philip P. Moltmann
27db6611a7 Treat all remotedocumentadapter-command results as cancel in the case we
are canceling the command.

Before it could happen that we have a pending cancel on a layout command
but the layout command finishes normally. This enqueued a new write
command before the PrintActivity is notified. This in turn prevented the
printactivity from finishing as the write command was still pending.

Bug: 27642724
Change-Id: I3c532d53b0c66c40d2e48ab8b4419251ff473a79
2016-03-18 09:44:28 -07:00
Philip P. Moltmann
74f9a2fc2e Merge "Do not finish multiple times." into nyc-dev 2016-03-18 16:19:45 +00:00
Philip P. Moltmann
5849f20124 Merge "If we finish before the the remotePrintedDocument is initialized" into nyc-dev 2016-03-18 14:25:25 +00:00
Philip P. Moltmann
e7f06a874a The PageAdapter update might be caused by the RecylerView.
In this case it cannot call back into the recyclerView and update the
data. For the call path please see the bug.

Bug: 27614499
Change-Id: I84733fea30429c20a2c96085efb47d4da5e1948a
2016-03-16 16:24:38 -07:00
Philip P. Moltmann
ada5a047ba Update printers even if there are no printers found.
It can happen that before we stopped we reported a set of printers. Then
while the loader is stopped, we lost all printers. Then on re-start we
need to tell the clients that there are no printers anymore.

There is one issue: The fused-printers-provider might be started
before the printer registry is fully created. In this case we get a callback
and get all king of NPEs. Hence enqueue the first load behind the
current thread. This makes sure that the current operation - creation of
the printer registry - is finished.

Bug: 27643300
Change-Id: Ife6993d57457f23a0a4a54a11869c742c05da850
2016-03-14 10:16:08 -07:00
Geoff Mendal
03a76f7c9e Import translations. DO NOT MERGE
Change-Id: Iebdb30818688a27d0c8edb60c5686a37e69f3444
Auto-generated-cl: translation import
2016-03-14 07:19:18 -07:00
Bill Yi
f4735aa23a Import translations. DO NOT MERGE
Change-Id: I72b2693c21cc8536a5642b6c0526f611a28631bc
Auto-generated-cl: translation import
2016-03-10 18:50:20 -08:00
Geoff Mendal
70431d0653 Import translations. DO NOT MERGE
Change-Id: If1e61e7ff8623456b114a06e38ecaa4e7b65e7b8
Auto-generated-cl: translation import
2016-03-09 07:19:29 -08:00
Philip P. Moltmann
ba245f98d6 Update 'more options' button when changing the printer.
Change-Id: I1bf71629027c18e297426e26db2923c447e47734
2016-03-07 13:44:59 -08:00
Philip P. Moltmann
0ad7fc5250 Do not finish multiple times.
It can happen that multiple async calls fail and we end up calling
doFinish from all of them. We should just ignore the later ones.

Bug: 27198033
Change-Id: Ica596b966f96e9ade6409cc45c50fd62c4018b1e
2016-03-07 11:36:10 -08:00
Philip P. Moltmann
32e0755afc If we finish before the the remotePrintedDocument is initialized
... we should not check if it is updating. As it is not initailized,
we do not have to check either, hence we can just ignore this.

Bug: 27516795
Change-Id: If618f2a10563e83074e38f0b37342a648d54202a
2016-03-07 10:31:52 -08:00
Philip P. Moltmann
66c96591e2 Add "app printer activity" and always keep the print service state
updated. Also fiddle with the UI to use more standard values.

To be sure the print service state alwasy updated I changed
PrintManager.getPrintServices to return a loader which just wraps a
registerListener/getList/removeListener combo.

I also added a new function to enabled/disable a print service to be
keep all updating logic inside the PrintManagerService->UserState.

Then I changed all code to use this new interface.

Detailed comments:

PrintServiceInfo:
- I had to add the enabled state to the PrintServiceInfo as some users
  of PrintManager.getPrintServices want all services but then display
  different data depending on the enabled state. Of course I could have
  created two PrintManager.getPrintServices-loaders to load the two
  separate list of services. I think it is much easier to add this
  property though. It is updated every time new data is returned to the
  PrintManager.getPrintServices-loader.

AddPrinterActivity:
- This is shown as a dialog-style overlay to indicate that the user will
  return to the select-printers activity. It contains of three list that
  are updated via separate loaders.
- The recommended services will be added later to keep this path set
  small.

PrintActivity:
- There are two small places where we have to update the data when we
  get a new list of print services.
  - In very, very rare conditions it can happen that the print service
    of the current printer gains or looses the "advancedOptions"
    activity
  - If we have no enabled print services we want to show "Add printer"
    instead of "All printers...".
- Also the print registry is not the only loader anymore, hence we have
  to assign loader ids to it to not conflict with the other loaders in
  this activity.
- Small bug in onPrintersChanged: If a printer is selected and the print
  service of this printer gets disabled the holder goes into "removed"
  state which disables the printer. When the print service is then
  enabled again, we forgot to re-enable the holder.

PrinterRegistry:
- The registry assumed that the FusedPrinterProvider was the only loader
  in the activity. This is not true anymore, hence it has to assign the
  appropriate loader ids.
- The FusedPrinterProvider has an internal loader, hence we have to
  forward a loader Id into it.
- The PrintRegistry is only called backed for a single loader, hence no
  need to check the loader-id.

SelectPrinterActivity:
- The AddPrinterDialog was removed as we now have the
  AddPrinterActivity.
- Added a loader for the enabled services to update the empty state.
- Added dedicated loader Id for the PrinterRegistry again.
- If we have no enabled services, the SelectPrinterActivity chainloads
  the AddPrinterActivity as this is the only thing the user can do
  anyway. "Save a click". This should only happen when the activity is
  create the first time.
- Moved the "add printer" from the menu item to the list of printers as
  suggested by UX and Zach.

PrintManagerService, UserState and IPrintManagerParamtersTest:
- As the only place where the print service state is updated is now the
  userstate, we have no more sychronization problems. Whohoo.
- The users can now register for changes to the print services similar
  as they can register for changes to the print jobs.
- UserState.getPrintServices is the only function can exposes any
  knowledge of the print services to the outside world.

Change-Id: I9be2c7300431e06aaff9bdf7eb36120d869b56ac
2016-03-07 09:58:08 -08:00
Philip P. Moltmann
59d12c6a27 Merge "Update print document view if printer capabilities changed" into nyc-dev 2016-03-07 16:45:36 +00:00
Philip P. Moltmann
8eb451597d Redraw the UI when a print page preview is updated
When switching between two printers with different margins but with the
same paper size we were missing updates of the print preview. This
change triggers these updates.

The issue was the we reuse the a bitmap when a page is rewritten. This
causes View.setBackground(drawable) to do nothing as the old
background is the same as the new one. This function only checks the
background drawable object reference, not the content. Hence we need to
add a call that notifies the listeners to the changes on the content of
the drawable.

Bug: 26961677
Change-Id: Id8b9be59c9ca7220f40ac59168f78bfdcccb2761
2016-03-03 16:21:24 -08:00
Philip P. Moltmann
1bb7f3638a Update print document view if printer capabilities changed
Bonus: Remove Printer-onChange listener before other state gets cleaned
       up. Otherwise onChange callbacks at the wrong time cause into
       destroyed data.

Bug: 27219320
Change-Id: I8335b9d8dd71112b76aa684f00524d4d8aad3f94
2016-03-03 15:08:46 -08:00
Philip P. Moltmann
d365f695d2 Fix three bugs in the handling of the advanced options activity
- The selected pages is not stored in the print job. But this is used to
  communicate with the advanced options activity. Hence patch it up
  before sending it out.
- If no media size is set in the returned attributes, do not try to get
  the portait size of this null-media size
- The copies can be 0 if the PrintJobInfo was created via
  PrintJobInfo.Builder()

Change-Id: Ic75c1db0cd5ffad663d87913dfe23e3f5a729bbf
2016-02-29 16:54:00 -08:00
Philip P. Moltmann
645a3e1ca6 Force cancel pending RemotePrintDocument commands when the PrintActivity exits
Otherwise the print-client app can prevent the print activity from exiting as
we wait for the command to finish. As this is a violation of the
remote-print-document contract we deal with this similar to a command failure.
As the PrintActivity is exiting we don't further send any commands to the
print-client.

Bug: 27207751
Change-Id: Ieacb16786112f217ca5b8031bfb597598e28dc3d
2016-02-25 12:36:27 -08:00
Philip P. Moltmann
cc3fa0d295 Clarify synchronization between PrintActivity and RemotePrintDocument
The general theme of these changes is to always delay any action until
the printDocument finishes a command. This is done:
- Before callinng for into a different activity to select a name for the
  PDF
- Before finishing

The second theme is to fix the canceling behavior of
RemotePrintDocument.AsyncCommand.

There are four bugs fixed in this review:

(1)
When the RemotePrintDocument.AsyncCommand is canceled it goes into the
"canceling" state. When it is canceled again it should stay in this
state. Before it went to "canceled" but the command was still running.
(see AsyncCommand#cancel()).

(2)
When finishing the PrintActivity in PrintActivity.doFinish() we cancel
the RemotePrintDocument. If there is a command still in progress (i.e.
isUpdating()) and it finished as canceled we used to call doFinish()
again and then try to double-clean up which lead to exceptions.

The new behavior is that is the PrintActivity is calling doFinish()
while a command is still in progress (i.e. isUpdating()) we delay the
cleanup until the command finishes. The command might finish as
canceled, completed or failed. Hence we have to call doFinish() in the
callbacks for all three cases.

(3)
When canceling there might have still been a nextCommand ready, hence
canceling does not stop execution of the RemotePrintDocument which could
lead to running commands while finshing.

(4)
When getting the location to store the PDF at a command might still be
in progress. This lead to half executed commands and caused issues once
we try to continue after the select-location-activity returns

Bug: 24713704
Bug: 24973884
Change-Id: Ied90fe8dc9bd6ea7f8b3e4ce4f922e477015568d
2016-02-08 17:29:26 +00:00
Philip P. Moltmann
cf5b777c13 Cancel print job if PrintActivity was finished before spooler could be
connected.

This can happen if finish() was called immediately after onResume() and
before PrintSpoolerProvider.onServiceConnected.

There is actually a small issue left. If the connection to the spooler
gets destroyed before it was ever connected the print job does not get
canceled. In this case it will stay "created" until the next reboot and
then it will not get recreated.

Bug: 26428518
Change-Id: I1b8696f326b842160e4db77b985577a1c8978def
2016-02-02 11:28:46 -08:00
Philip P. Moltmann
56190d5e4b Merge "Also search in description when filtering printers." 2016-02-02 16:36:36 +00:00
Philip P. Moltmann
e93cf151fb Merge "Allow the PDF Printer to "print" non-locale-default paper sizes." 2016-02-02 16:34:48 +00:00
Philip P. Moltmann
18fc58f13d Merge "UI improvements for the print spooler" 2016-02-01 23:42:05 +00:00
Philip P. Moltmann
2fbd43ea27 Merge "Update summary when printer changes" 2016-02-01 23:37:29 +00:00
Philip P. Moltmann
76855d322b Merge "Init and clean up printer registry independat of state." 2016-02-01 22:49:51 +00:00
Philip P. Moltmann
51dbc8ec6a Init and clean up printer registry independat of state.
The printer registry is created not in sync with the states or the
activity life-cycle. It might not be initialized when stop is called as
we might have a very quick

create -> start -> stop -> finish

without time for the print subsystem to initialize.

Bug: 21749058
Change-Id: I991029a7fd0ad162c1144ff03438707f16bf0b02
2016-02-01 13:56:45 -08:00
Philip P. Moltmann
c2f913d09b Only update UI when bound
If the PrintActivity gets destroyed (e.g. due to low memory) it gets
re-created when the PrintToPDF activity returns in onActivityResult. In
this case onActivityResult is called right after onCreate and before the
UI is bound. This resulted in a NullPointerException when accessing the
unbound UI elements.

Bug: 21749058
Change-Id: I44e625e8c4f10432591d0afcf7825d7e0dbee6f5
2016-02-01 13:03:44 -08:00
Philip P. Moltmann
17332cb2a7 Update summary when printer changes
The new printer might not support the currently selected paper size
hence the printer update changes the paper size.

Change-Id: Ie3864d87df425383b4c37f325c8fbea12f6f6051
2016-01-29 15:17:00 -08:00
Philip P. Moltmann
443075ab97 UI improvements for the print spooler
- gray out printer icons of unavailable printers
- Increase touch target of more into button
- Use same info icon as in the Settings
- Align text correctly in destination drop down
- In general use same layout as generic list-item (as much as possible)
- remove unnecesary color file

Change-Id: I8b0339df0cb6a5130b5530f21c4ef86cb75a683b
2016-01-29 10:49:29 -08:00
Philip P. Moltmann
0b953a24c7 Size recyclerview correctly.
Bug: 26769843
Change-Id: I00715ab028f8da10b74db11aaef08843a8cc009f
2016-01-28 13:12:43 -08:00
Philip P. Moltmann
e33b954165 Merge "Check parameters for callers of IPrintManager" 2016-01-26 22:52:58 +00:00
Philip P. Moltmann
b18cacfcad Merge "Carry over orientation when updating the printAttributes with the capabilities of the printer." 2016-01-26 18:24:15 +00:00
Philip P. Moltmann
e58d8ff1fb Also search in description when filtering printers.
Bug: 26780192
Change-Id: Icd95e7e4daee21bd5904d3a271f306864cf47631
2016-01-26 10:15:14 -08:00
Geoff Mendal
93f18cefca Import translations. DO NOT MERGE
Change-Id: Id69e1f05426df237d87764464acd6997ed22cff8
Auto-generated-cl: translation import
2016-01-25 05:40:21 -08:00
Philip P. Moltmann
dc5765eb0c Carry over orientation when updating the printAttributes with the capabilities of the printer.
Bug: 19194758
Change-Id: Iaa9897bc730d8cefa63bed8a5ad02e0a5dc89c71
2016-01-22 09:39:41 -08:00
Philip P. Moltmann
4959caf149 Allow the PDF Printer to "print" non-locale-default paper sizes.
The MediaSizeComparator already sorts the media sizes correctly.

Bug: 12675943
Change-Id: I6fa4b1a8885a60704bc175ec849ea483ffb4bcd8
2016-01-21 15:10:29 -08:00
Philip P. Moltmann
76d7e3ee70 Check parameters for callers of IPrintManager
- Propagate nullness and non-null-ness up and down from the interfaces.
- Add non-CTS print tests for IPrintManager binder.

Change-Id: I0c310d9cea8aefba5ce386931521ffaf19712bbb
2016-01-21 13:27:30 -08:00