835 Commits

Author SHA1 Message Date
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
Philip P. Moltmann
5462e88c02 Treat empty strings similar to null-strings when composing the subtitle in the SelectPrinterActivity.
Change-Id: Ia0ee353df56b2f835f1ac291dc69eb3747425e6b
2016-01-20 13:55:38 -08:00
Geoff Mendal
2874739bf6 Import translations. DO NOT MERGE
Change-Id: I9339fe99c83fe70cec438b7d36abe36116ed0a8a
Auto-generated-cl: translation import
2016-01-20 05:47:05 -08:00
Geoff Mendal
82ec4e9949 Import translations. DO NOT MERGE
Change-Id: I22202310da38844825b48d612c8097ea559b71d7
Auto-generated-cl: translation import
2016-01-18 05:50:11 -08:00
Philip P. Moltmann
c2ad22663b Clean up API for PrinterInfo.
- Make immutable
- Check parameters
- Check state while unparcelling

Change-Id: I13959845ca508936331488506380e894f49abf25
2016-01-14 12:48:31 -08:00
Geoff Mendal
3e3a451f79 Import translations. DO NOT MERGE
Change-Id: I488d48ed5a95fb2764dd2129fc512fa1c2db5fdb
Auto-generated-cl: translation import
2016-01-13 05:37:19 -08:00
Philip P. Moltmann
e978af63e6 Merge "Do not add far favorite printers more than once." 2016-01-11 20:22:40 +00:00
Philip P. Moltmann
fcb51b8270 Merge "ApprovedServices might be null, handle the case:" 2016-01-11 20:22:10 +00:00
Philip P. Moltmann
8d978ba1e7 Merge "In rare cases the printing client app might have been dieded before remotePrintDocument.start(). In this case the print spooler should not crash." 2016-01-11 19:41:55 +00:00
Philip P. Moltmann
f7b5018028 Merge "Display toast when print services are disabled." 2016-01-11 19:41:25 +00:00
Geoff Mendal
d7483de165 Import translations. DO NOT MERGE
Change-Id: I519c2c15b3ae10ec47a76de7afff6fea223ba1c9
Auto-generated-cl: translation import
2016-01-11 05:41:24 -08:00
Philip P. Moltmann
0d1e622000 ApprovedServices might be null, handle the case:
Bug: 26454066
Change-Id: I909d84d08a1f6d29f486e8ea6097e782b054864e
2016-01-08 16:26:44 -08:00
Philip P. Moltmann
9b99d76a71 Do not add far favorite printers more than once.
The favorite printer list contains a printer multiple times as it might
have been used at different locations. Hence it can be that a printer is
in the favorite printer list multipe times but never considered close.

Hence we go into the second loop and add it multiple times as we never
add it to alreadyAddedPrinter.

Change-Id: I4ca8a6a5a05f43645a0b2c891a55df2ccce05ad4
2016-01-08 16:20:12 -08:00
Philip P. Moltmann
f6114c4f1e In rare cases the printing client app might have been dieded before remotePrintDocument.start(). In this case the print spooler should not crash.
Change-Id: Ica1b46fadf6bccbd28e8f9c928f5d504cccff792
2016-01-08 14:49:56 -08:00
Philip P. Moltmann
1f46779f5e Display toast when print services are disabled.
Change-Id: Id1ebcbbf39eb558bc15c7c69c03fe8124b9c79d7
2016-01-08 14:03:01 -08:00
Philip P. Moltmann
8141bdfa56 Store which print services are disabled instead of which are enabled
This make services that appreared while the print manager was not active
by default enabled.

In the case we upgrade from pre-N we convert the enabled-list into a
disabled-list.

Bug: 26249649
Change-Id: Iae783a8dd19f1a9d75d675710ea4348fdfbd34f3
2016-01-07 09:30:43 -08:00
Philip P. Moltmann
a5fcd5028a Remove debugging from print notification code.
Change-Id: I3f0fb6c68de0b3f4cd0fa67ddf8c405199d6498e
2016-01-07 09:25:49 -08:00
Philip P. Moltmann
a1cdb4bacb Use notification grouping for print notification.
Change-Id: Ifb5bc0f233611a056db511b15379165ac6fe0edf
2016-01-07 09:19:54 -08:00
Philip P. Moltmann
98edbe3e6d Merge "Show indeterminate progress bar when job is queued or started and the progress is not known." 2016-01-04 20:28:27 +00:00
Geoff Mendal
b0d78d487c Import translations. DO NOT MERGE
Change-Id: I57fcb1091c20531411b67a6ff0fab6ba973b8d3a
Auto-generated-cl: translation import
2015-12-28 05:44:56 -08:00
Geoff Mendal
de557669b2 Import translations. DO NOT MERGE
Change-Id: I26b3d71c972ae0f9757845441999564e504f9183
Auto-generated-cl: translation import
2015-12-23 05:37:14 -08:00
Philip P. Moltmann
f25c403337 Show indeterminate progress bar when job is queued or started and the progress is not known.
Bug: 24135025
Change-Id: Id8d365e41573a3ea7018cadeb8d6e857f0dbe1cf
2015-12-22 20:42:57 -08:00
Philip P. Moltmann
98963260dc Prefer printers that have been used physically close to the current
location of the user.

Commonly the users prints on a printer that this near the user current
location. Hence if possible we want to show the user printers that he
used before and that are close to him.

Hence store the location of the previous uses of a printer and prefer
printer that are close to the user.

Unfortunately getLastLocation might not report a usable location and it
will take at least 5 seconds until the first usable location arrives. At
this time the user might have already opened the destionation spinner.
It would be unexpected for the printers to suddenly change under the
users finger. Hence it might be that we did first show the printer
without any location information and then once the location is known we
cannot update thedestination spinner anymore.

The select printer activity does not have this issue, hence in the worst
case the user has to enter this activity to select a printer and by then
the location is usually determined.

This is not ideal but better than before.

Bug: 24133609
Change-Id: Ie7d20cf3d9dd163e57903f8f6ecc0b3fd4f4374e
2015-12-22 19:00:39 -08:00
Philip P. Moltmann
4c95567b5f Merge "Clean up print subsystem" 2015-12-23 02:11:01 +00:00
Philip P. Moltmann
30172e2561 Merge "Close closeguard of PageContentRepository." 2015-12-23 01:28:07 +00:00
Philip P. Moltmann
c43639c306 Clean up print subsystem
- Stop using deprecated APIs
- Fix all public and some internal javadoc
- Add @Decorations to public APIs
- Some minor cleanup, e.g. don't use variables with overlapping names in same scope
- remove unnecessary properties from manifest (they are set by the build
  system)

Change-Id: I0ce8849a516414763fe9de76c3a18ce17d896816
2015-12-22 17:27:27 -08:00
Philip P. Moltmann
bb9f686b40 Allow a print service to specify per printer icons, description and
info-activities

The icon is loaded from the discovery session only when it is displayed
to avoid having to store too many icons in memory.

Also the icons are not maintained in the historical printers. Only if
the printers are available nice icons are shown. A historical printer is
updated with the appropriate properties (including icon) once it becomes
available.

Bug: 24135005
Change-Id: Iec389bab514b024634be8fb5fc8928371cba8740
2015-12-21 09:54:57 -08:00
Philip P. Moltmann
38fdd4f486 Close closeguard of PageContentRepository.
Change-Id: I4ee143e94fde7ac4dbc25e6208caafdab819df31
2015-12-17 11:48:04 -08:00
Geoff Mendal
6f3143de02 Import translations. DO NOT MERGE
Change-Id: Ife17cc8816a60ab0966694d1e4212b70f2340ec7
Auto-generated-cl: translation import
2015-12-16 05:48:19 -08:00
Philip P. Moltmann
a958fc336b Unset is -1 not Nan
Change-Id: I6e7fac4b9f1c3dc6cc88c786db856ddecf3f8538
2015-12-02 15:39:35 -08:00
Philip P. Moltmann
b3078c235e Allow print service to specify progress of print and status
The status has always been there in error cases, it is now also visible
in non-error cases.

If the progress is not set, no progress bar is shown.

Bug: 24135025
Change-Id: Iea23f45d236365433c6f6739597833d236ed6d19
2015-12-01 15:42:49 -08:00