History log of /frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2fa010cf5bf76af826776ada8a35cf8fe2945b64 15-Oct-2013 Svetoslav <svetoslavganov@google.com> Update the message for unavailable printers.

If a printer disappears or we do not get its capabilities, we
show the user a message that the printer is unavailable. This
message was appended after the printer name but they tend to
be very long and the user does not see that the printer is not
available due to ellipsis. Now we append the message after the
subtitle which tends to be much shorter.

bug:10983508

Change-Id: Ib3f7ad3bd82ff6decd49dc45461fb5131338e8c2
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
9d843e09caa8c32a3fec22bb66cba8e6d4dfa5b1 14-Oct-2013 Svetoslav <svetoslavganov@google.com> Layout may be called with invalid print attributes.

If a print service reports a printer with no capabilities and then
removes and adds the same printer again with no capabilities we can
call layout with invalid attributes. While the print service should
not do that we must not crash. The reason is that the print dialog
code was lacking a check whether something changed before handling
the change of the current printer. This resulted in calling layout
even though we still do not have the printer capabilities resulting
in passing bogus print attributes to the app.

bug:11216402

Change-Id: Icb9161930a70a7f9ead589a0ab0b4eb35091666f
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
7ff610ee029d990a6b9b6d8c90a79fe79fbd8368 13-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> The print dialog in bad state after pressing back from prnt to PDF.

When selecting print to PDF and then pressing back to return from the
storage UI activity, the print dialog was in a state where nothing
is selected.

bug:10983508

Change-Id: I9c14b5fa18e812104ade6a2eacd626b5f7387111
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
89ed9fcf9b2fe061626c910701a35f1ea576a370 12-Oct-2013 Svetoslav <svetoslavganov@google.com> Putting the cursor at the end of the copies and range inputs.

bug:10983508

Change-Id: I767876fada2f28b00283ed9140fca1a40729f38f
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
02dded1a63bb5ae2968fb9df0c29bad115416a28 11-Oct-2013 Svetoslav <svetoslavganov@google.com> Adding timeout if the current printer or its capabilities disappear.

If the current printer becomes unavailable or its capabilities
go away we are scheduling a timeout to declare the printer as
unavailable.

bug:10983508

Change-Id: Iab85cfd35fc0cecc3dd4abac6232347f9da18fb0
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
54adee86af495311fc9ef62d65e035605043413f 11-Oct-2013 Svetoslav <svetoslavganov@google.com> Print spooler not starting.

1. In my previous change I fixed a typo in the Java constant with
intent action to launch the print dialog but failed to updated
the print spooler manifest.

2. Removed dead code - the user id is no longer needed since the
spooler is an app that runs per user. Every user has its spooler.
This code was not referenced from anywhere.

3. Added a default icon to the print spooler.

4. Fixed a bug where if the print history is empty the UI goes
to the all pritners activity.

bug:11059554

Change-Id: If74c23b418a8c67620ba14435ee7f3b2c4527099
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
f22a767e872ec8f5c2531a88819e0f4574c78fe3 11-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Added UI for errors during layout and write." into klp-dev
caff38821ad81389b5baf2053ba851c38272ec63 09-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Added UI for errors during layout and write.

1. If an error happens during layout or write we show an error
message with the string provided by the application which
has an OK button to retry or tap outside to cancel.

2. Updated the targed and min SDK version for the PrintSpooler.

bug:11127269

Change-Id: I4301cf3716119b1e33b95347a8451fc1c128343b
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
7bfbbcb04bf4ba8f3069b2df136f708c9849bacf 10-Oct-2013 Svetoslav <svetoslavganov@google.com> Refactor how the print dialog activity is started.

1. Before the print job activity was started asyncronously with
respect to the print call on to the print manager. This was
creating a situation where the starting activity may finish
before the print dialog appears which may lead to an orphaned
print document adapter with no data to print (as the UI is
is gone), or strange behaviors where the print dialog starts
on as a separate task.

To address this the pending intent for starting the print
dialog is not started by the print spooler since we cannot
call into it synchronously as we have to start its process
and bind to the spooler service which leads to jankyness in
the client app. Now the pending intent is created by the
print manager service in the synchronous print call so
from an app's perspective calling print starts the activity.

The side effect of this design is that the print dialog
activity may start before the system is bound to the spooler
service. In such a case the print activity cannot start
poking the print spooler state as the system registers
callback to observe the spooler state. To address this
the print spooler activity disables the UI and also binds
to the spooler service which happenes immediately after it
is started. As soon as the print dialog binds to the
service it starts the UI.

2. Fixed an bug in the printer adapter of the print dialog that
was leading to a crash if the only item in the adater is the
all pritners option and it is selected.

3. Piping the package name that started the printing so we can
pass it to the storage UI as a hint to open the last location
the app used.

bug:11127269

Change-Id: Ia93820bdae0b0e7600a0930b1f10d9708bd86b68
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
3aa2e2b3ab21fda7045fbe2bb142e7a6830340e5 11-Oct-2013 Svetoslav <svetoslavganov@google.com> Fixing jank when transition from print dialog to generating one.

Initially we show the print dialog and when the user presses print
we show a generating dialog with an indefinite spinner and a cancel
button. The transition between the two UIs which are really different
layouts show in the print activity is animated. In the middle of
the animation from print to generating UI there was a jump of the
content and an undesired window animation kicking in. This is a
side effect of changing the activity to floating so now changing the
container size was causing window resize and hence animation. Fun!

bug:10983508

Change-Id: I7d88e073c55863b945cdb50822401592f32d44c3
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
ebec46847d4bbd72161fb32282ab7a68effa00a7 09-Oct-2013 Svetoslav <svetoslavganov@google.com> Sometimes the print button not enabled and an accessibility fix.

1. Sometimes the print button is not enabled after selecting a printer
from the all printers activity. This was happening after a printer
was selected, we had to do a layout due to changed print attributes
(because of the new printer's capabilities), and the content did not
change. In this case we did not call the updateUi function which
enables the print button after layout is completed.

2. The accessibility code in the all printers activity was not checking
whether accessibility is on and doing some unnecessary work - not sending
events though but still. Further, the delayed runnable that was
doing the accessibilty announcements was not removed when the activity
was paused.

bug:10983508

Change-Id: Ib263116a3e21e4c75a25aa051cecbd9194417319
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
69b91e0ecb8cef95c030f5076779e07d363a45f2 08-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Show unavailable printers disabled and grayed out.

1. If a printer is not available it has to disabled and grayed out.

2. Cancle a print job if the app does not provide the requested pages.

3. Fix current printer selection flicker when the print dialog is
showing up. Often the current printer is initially set to the user's
favorite and then it is changed back to the PDF one.

bug:10983508

Change-Id: I8d53eb992cf1c92675ec09f61b2ec272b962fa68
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
56ddf1ffa5b7bd3b8d4b8b7d5c68d7e0e99e5e15 06-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Polish print dialog accessibility.

bug:10983508

Change-Id: I7391e06b661caac18d04ae279639ff447701f151
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
24c686b8b56950d5a1881cc660e53816d47e5e03 06-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Update all printers activity's empty state and avoid selected printer flicker.

1. Updated the empty state of the all printers activity to show no printers message
if the user is searching and there are no matches and a searching for printers
message if the user is not filtering the printers list.

2. Adding the fake PDF printer after the historical printers are loaded to avoid the case
where we select the PDF printer and immediately after that the most used printer is
selected resulting in an undesirable UI flicker.

3. Fixed a bug where if the most used printer which is initially considered unavailable
is reported by the print service as available but the UI is not properly updated
leaving the user in no way to click on the print button.

bug: 10983508

Change-Id: I60fdb7761332850fd5b9ffc0cb572a6213024dba
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
5ab717f21a2dbcd78fb37d40e31393d129743599 05-Oct-2013 Svetoslav <svetoslavganov@google.com> Print UI tweaks.

1. The refresh button in a print notification was using
wrong asset.

2. If the page count is unknown, just not show the page
count instead unknown.

bug:10983508

Change-Id: I15f1fcbff60fe1f30d37868864da41550bb14487
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
7be27acac922b5ea66ec6b464ded6f057bd6f1e5 30-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Print attributes hint not honored.

1. Initially we have a single printer, the fake PDF printer, and
wait for printers to be discovered. This printer was handling
only a couple of media sizes. Hence, if the app provides a
media size hint and the PDF printer does not support it, we
were essentially ignoring the suggested media size since it
was not supported by the selected printer and we fell back to
the default paper size for that printer. The fake PDF printer
should support all predefined media sizes.

2. The list of available paper sizes was shown in the order they
are added ignoring the current locale. It is much better user
experience if the media sizes used in the current locale are
shown at the top and all others after that. Also the media
sizes for the current locale should be alphabetically ordered
so the user can quickly find the desired one.

3. The orientation was reset on media size or printer change.

bug:10564537

Change-Id: Iaa0d42242730ce69cea3effd4d0f4bc087068804
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
39e71de6b49d1cb67ce30b411cede8d4f40dc765 03-Oct-2013 Svetoslav <svetoslavganov@google.com> Print UI tweaks as per UX request.

1. Limit the width of the dropdown of the printers list.

2. Add icons the the list in the all pritners activity.

3. Update the empty state view for the all printers activity.

bug:10983508

Change-Id: I19effcf32770fdda278009a060b5170a3f29988e
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
4e4874bb71ddebc80fd10b7b3f0ec6b13aca25ec 02-Oct-2013 Svetoslav <svetoslavganov@google.com> Sometimes printer selection from all printers activity does not work.

1. Sometimes selecting a printer from the full printer list does not
work if the selected printer was not in the initial drop down list
of the print dialog.

The reason was that there is a race. We use loaders in the print
dialog activity and the all printers one. When these loaders are
stopped we stop printer discovery since we do not want to keep this
potentially expensive process on going if the activity is paused
because say the user decide to press home and start playing his
favorite game while the printers dialog is up. As a result the
loader does not get printer updates until it is started.

The loader of the print dialog activity is stopped while the user is
selecting a printer from the all printers activity whose loader is
getting discovered recent printers. Now when the user selects a printer
the loader of the print dialog activity is started but may not get
the latest printers by the time onActivityResult is called with the
selected printer. Now we cache the selected printer id and if the
loader reports it we select that printer.

2. In the print dialog we show only a few of the discovered printers.
If the user selects a printer from the all printers activity that
is not in the initial list we shuffle the adapter data to make sure
the selected printer is in the shown subset. Now if the printers
change, i.e. the printers loader reports new result we were not
respecting the reshuffling made before so the short list of
printers changes yet again.

bug:11034216

Change-Id: I54fe3619e3328b65839d9f4b02309699eae7f8eb
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
c783f6738f0f6d2cb57702cfbc9219c59a3410a3 28-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Adding a timeout for waiting to get the selected printer's capabilities." into klp-dev
6be4c76441ecdc11ee4db7211edc421d26a78f1f 27-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Adding a timeout for waiting to get the selected printer's capabilities.

A print service may choose to provide only the printer info and then when
it is requested to start tracking the state of the printer, the service
should provide the printer capabilities. If the capabilities are not
received within ten seconds we mark the printer as unavailable and stop
tracking it.

bug:10748639

Change-Id: I9171cb5dc116fd321c23a8e4ab55109448e2fc6a
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
c335eb411503154cf475903eb6c5c67575769112 27-Sep-2013 Svetoslav <svetoslavganov@google.com> Printers in the list of printers change position.

1. The printers in the printers list of settings change position if
they are updated. The settings app is using hidden platform APIs
the this change fixes.

2. Enable ProGuard for the PrintSpooler.

3. Added icons on the list of printers so the user knows which
print service used the printer. Now the user can know when
he is using cloud print and maybe incurring data costs vs
local printer discovered by a vendor plug in.

bug:10955751

Change-Id: I292f48b424cb561218fdb424d0388f4d786d8339
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
0ce3e8743c9127a688f007eed17a5ed18081d0fc 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Choosing default paper size for the "Save to PDF" fake printer

Change-Id: I1e2eb73fd1eb3b1e9812155b69b94cba261243c2
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
3adc49c6780633b8bccc3b5b8dca10788c2288bc 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Disallow range selection if the document has unknown page count." into klp-dev
ab051baea5560e0c71397771e53bd74d4a36024d 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Page range validation edge case handling.

The regular expression for validating range input was missing a
coupe of edge cases.

bug:10906805

Change-Id: Ie793588ecb6697aff3d8d85124a8faeda58c69e5
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
b0e68fdc9cb6ba292adc4590f406d921abea08d5 21-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Disallow range selection if the document has unknown page count.

bug:10741878

Change-Id: Ibf2272125e81f14ede3fdfec86aee10b908ade01
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
2a708617dfdc0b6dbf9b39baebbdc55d19aa7728 25-Sep-2013 Svetoslav <svetoslavganov@google.com> User should not be able to select unavailable printers.

1. If the printer is unavailable we should not allow the user
to select it. Rather, show it grayed out.

2. Some string changes requeted by translators.

bug:10917222

Change-Id: I370f05f9c8e70e3f077db7eb02cf48e19a59925d
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
5dfccc3c0d142765b04f9cd8b2513a6b9db22426 24-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "The current is printer not refreshed when selected." into klp-dev
307a0d4db23d8d9705fb2d87d304cb7e9a90f476 24-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> The current is printer not refreshed when selected.

Every time a printer is selected we have to refresh it by telling
the print service to stop tracking the previously selected printer
if such and start tracking the current one. As a result of start
tracking the print service has to give us the capabilities too. A
previous patch caused a regression and we do not refresh printers
when needed.

bug:10898968

Change-Id: I9d5413e324fdb8856ef61849d36a161470eb204d
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
a4f6409c974363a6bb1eddd5c88048d88e868640 21-Sep-2013 Svetoslav <svetoslavganov@google.com> Page ranges not correct in come cases.

1. The algorithm that determines whether a page range contains
another one had a bug and in some cases misbehaved.

2. When print is pressed we do a final layout and if nothing
changes and we have the requeted pages we skip the final
write. However, in this case we did not update the print
job with the pages to be printed but we have to since in
the previous write we did not ask for all selected pages,
rather for the first one to be shown as a preview. Now if
we have all pages and nothing changed we update the print
job pages.

bug:10530142

Change-Id: I10fb62ae5ae07b8e54d547fd4dca555a12451bc5
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
5559c368a96c56d55c581c88d9978c59c5212bf1 20-Sep-2013 Svetoslav <svetoslavganov@google.com> PrintDocumentAdapter contract not followed on print.

1. Layout was not called after pressing the print button if the
print attributes did not change. This is not correct since the
previous layout calls were for preview purposes and the one
after pressing print is not for preview. Hence, we always have
to do this layout.

2. After layout we decide whether to ask the app to write some
pages. We ask for a write if we do not have the pages selected
by the user or the document changed (if the page count changed,
the document type changed, or the app told us that the content
changed). We were not computing correctly whether the document
changed since we compared the size but the document info the
app passes in after a layout does not have the size yet. We set
the size after a write. So for layout purposes we should ignore
the size. We only care if the page count, document type, or
content changed where the latter is reported by the app in
the layout callback.

3. We were not updating the PrintJob after setting the data
size of the printed document.

4. Disabled debugging.

bug:10835370

Change-Id: Ic3b2871b4e954cdf610f8cf806de5fc6588a6bec
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
6811f4e92cbb64e72a0d13eb9b99b5894bd59c76 19-Sep-2013 Svetoslav <svetoslavganov@google.com> Move PdfDocument to android.graphics.pdf

1. Move PdfDocument to android.graphics.pdf.

2. Changed the PdfDocument as per API concil request.

3. Updated the documentation.

bug:10461180
bug:10552565
bug:10681585
bug:10552336

Change-Id: I08e15b34cf37bb064248c887e6f59808019cafe8
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
f0c48a72fd8476afd063d4ef593b473b8cf9a9d0 18-Sep-2013 Svetoslav <svetoslavganov@google.com> Fixes in the page range selection and verification logic.

1. Typing a range where the start is greater than the end was
leading to a crash.

2. Typing the same single range, e.g. "2,2", was leading to a crash.

3. If two ranges are non-overlapping but consecutive they were
not merged

4. Typing multiple times a digit that is less than the page count,
e.g. page count "2" and typing "11", was not caught by the input
verification.

bug:10812904

Change-Id: I754715b5d792a1a6c3a4f9f644edfa9aea7ac127
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
0cfebec522539722f294a99bc32437b5d9e4b27d 17-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Print pooler crashes for some page ranges." into klp-dev
c3484024e1117b518f06b39c406ba20f961d592e 17-Sep-2013 Svetoslav <svetoslavganov@google.com> Print pooler crashes for some page ranges.

1. The print spooler fails to parse page ranges that end with
a dash, e,g, "1-", which are however valid inputs since the
user can continue typing to end up with a well-fromed range.

2. After a layout we are asking for the first selected page
to be written emulating print preview, thus increasing the
changes that apps will correctly implement the APIs.

bug:10743632

Change-Id: Ia74172d4fa6bce6ad93a0bc53da1aaa3fe8bef42
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
2fbd2a7f070f246ddafd9de94efa9a98861e9136 17-Sep-2013 Svetoslav <svetoslavganov@google.com> App UI freezes when printing. API clean up.

1. The UI of a printing app was freezing a little when calling the print
method since the print manager service was waiting for it to bind to the
print spooler which generated the print job id (and the initial print
job info really). Now the print manager service is responsible for job
id generation and does not not wait for the print spooler to spin. Hence,
the app UI is not blocked at all. Note that the print manager initiates
the binding to the spooler and as soon as it completes the spooler shows
the print UI which is hosted in its process. It is not possible to show
the print UI before the system is bound to the spooler since during this
binding the system passes a callback to the spooler so the latter can
talk to the system.

2. Changed the print job id to be an opaque class allowing us to vary the
way we generate print job ids in the future.

3. The queued print job state was hidden but the print job returned by the
print method of the print manager is in that state. Now now hidden.

4. We were incorrecly removing print job infos if they are completed or
cancelled. Doing that is problematic since the print job returned by
the print method allows the app to query for the job info after the
job has been say completed. Hence, an app can initiate printing and
get a print job whose state is "created" and hold onto it until after
the job is completed, now if the app asks for the print job info it
will get an info in "created" state even though the job is "completed"
since the spooler was not retaining the completed jobs. Now the spooler
removes the PDF files for the completed and cancelled print jobs but
keeps around the infos (also persisting them to disc) so it can answer
questions about them. On first boot or switch to a user we purge the
persisted print jobs in completed/cancelled state since they
are obsolete - no app can have a handle to them.

5. Removed the print method that takes a file since we have a public
PrintDocumentAdapter implementation for printing files. Once can
instantiate a PrintFileDocumentAdapter and pass it to the print
method. This class also allows overriding of the finish method to
know when the data is spooled and deleted the file if desired, etc.

6. Replaced the wrong code to slice a large list of parcelables to
use ParceledListSlice class.

bug:10748093

Change-Id: I1ebeeb47576e88fce550851cdd3e401fcede6e2b
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
860f8a6b663ca96d30d17da09eca8caf065aae62 14-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Spooler should not crash if print service config activities are not exported.

1. If a print service does not export its activities for settings and
adding printers the print spooler ignores them instead of crashing.
Also if the service is not enabled its activities are now ignored.

2. Added a dedicated permission for a print service to optionally
protect its settings and add printer activities such that only the
system can bind to them.

3. Fixed a crash in the print dialog if its content is detached
from the window and animators are running.

bug:10680224

Change-Id: I20b57d6622a15f9b2352ba78d04c44e67b316a15
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
651dd4e6ee6510caf9f15c51094a11121af17ec2 12-Sep-2013 Svetoslav <svetoslavganov@google.com> Remove unneeded print APIs and update the min margins APIs.

1. Removed unneeded code in Resolution that was storing its
label as resource and package name. We do not have predefined
resolutions, therefore we always persist the label.

2. Renamed the print attribute margins to minMargins to reflect
that these are the minimal margins the printer support. Updated
the docs as well.

3. Renamed the create method of all builder to build.

bug:10727487

Change-Id: Ie72ab8aaa5215b8bd2853885011b3b4efa4deb2e
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
cc65b0c325b88c466763712f76148a6f5b8a5b3f 11-Sep-2013 Svetoslav <svetoslavganov@google.com> Not change the print options on printer change if possible.

If the user selects some print options from the dialog and then
changes the printer to one that has the same capabilities the
selections in the UI should not change.

bug:10631856

Change-Id: Ia76ce58c446815e3498d2f4b4739dee62d11d96a
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
a36285f3f2f74b1d2d5d0336ffe519ab9f6e062a 05-Sep-2013 Svetoslav <svetoslavganov@google.com> Bug fixes in the print dialog

1. Read/write async tasks of the persistence manger used by
the FusedPrintersProvider could be run more that once, so
create a new one every time.

2. The fake printer used to save to PDF should not be added
to printer history.

3. Removed print preview leftover code from the print dialog.

4. Save to PDF was not working on the second consecutive attempt.

5. The fisrt time the orientation change was ignored - regression

Change-Id: I8960ef2cf92dfeeec22fa8751ba8475092b5b65c
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
773f54de3de9bce7b6f915aa47ed686b161d77aa 03-Sep-2013 Svetoslav <svetoslavganov@google.com> Print API updated.

1. Removed the updatePrinters API on PrinterDiscoverySession.
Now re-adding a printer updates it.

2. Added getTrackedPrinters() API to allow a print service to
figure out which printers' state should be tracked by the
service.

3. Removed the APIs on PrintDocumentInfo that describe the
layout of the content as they are not needed. For example,
if the print attributes passed in layout require landscape
mode, the the app should just create a PDF page with the
wider side up and draw its content in portrait. The printer
will then rotate the page.

Change-Id: Idd72c6e9c129e8b17eef1236573a99773f8ff0a2
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
9186d0cb2bd325d9b52da15dbd513937c1e42caa 03-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Bug fixes in the printer dialog activity and fused printer loader.

1. Fused printers loader was not using the discovered printers to update the
historical ones. Now if a historical printer is discovered we update its state
with the discovered, i.e. most recent, information.

2. Fixed a bug in the destination adapter of the print job config dialog that
was leading to a crash if all printers item is selected when there are no
discovered printers.

3. Updated the add printers asset in the all printers screen.

4. Historical printers were not persisted by the print dialog activity.

5. Reduced the number of printers we send per transation to avoid the binder
transaction size limit. Added sending of printers in chunks in a place
this was missing.

Change-Id: I88b54888360bc0e53b06bd260c2b832d0d6454b6
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
d26d4898fcc9b78f4b66118895c375384098205e 28-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print spooler security and some new print service facing APIs.

1. Updated the security mode of the print spooler. Now the spooler
is not signed with the system key, it is not a privileged app so if
it gets compromised (PDF rendering is a potential attack vector)
it cannot access dangerous permissions. Also only the system
can bind to the spooler.

2. Added APIs for asking a print service to start and stop tracking
a given printer. This is need for the case when the user selects
the printer and the print service should do a best effort to keep
the system updated for the current state of the printer.

3. Added APIs for putting a print job in a blocked state. A print
service would report the print job as blocked if for some reason
the printer cannot proceed, e.g. 99 pages are printed but there
is no paper for the last one. The user has to add more paper
and the print service can resume the job.

4. Changed the read/write APIs to use ParcelFileDescriptor instead
of FileDescriptor since the latter does not have a clean API for
detaching the wrapped Linux file descriptor when one wants to
push it to native.

5. Added API for getting the size of the printed document so the
print service can avoid handling big filed over cellular network
or ask the user if needed.

6. Now the print services that are preinstalled on the system image
are automatically enabled.

Change-Id: Ia06c311d3d21cabb9e1368f13928e11cd0030918
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
aec1417ca9eb63209668ac17da90cf8a07c6076c 27-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print APIs update.

1. Added scale to fit and scale to fill fitting modes.

2. Added APIs for a print app to specify which constraints imposed
by the print attributes were satsified during a layout so they
are not handled by the printer again, e.g. if the content is to
be in landscape the the app generated such content the printer
should rotate the content again.

3. Added some printer statuses.

4. Added a helper class that generates PDF documents with correct
size based on the passed in print attributes.

5. Exposed a ctor for PageRange which was hidden by mistake and apps
could not create page ranges. Added API for changing the printer
status.

Change-Id: If1334a61d2d931027b98075f653018d456b1b768
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
44720af55a8fdf991929983dad5d53c02851dd1e 21-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print UI bug fixing and printer discovery refactoring.

1. Added support for selecting a printer from the all printers activity
that is not in the initial printer selection drop down. The user
initially sees a sub set of the printers in the drop down and the
last option is to see all printers in a separate activity. Some
of the printers in the all printers activity are not shown in the
initial drop down.

2. Refactored printer discovery by adding (private for now) printer
discovery app facing APIs. These APIs are needed to support multiple
printer selection activities (print dialog and all printers activities)
and also the settings for showing all printers for a service.

Now multiple apps can request observing for printers and there is
a centralized mediator that ensures the same printer discovery
session is used. The mediator dispatches printer discovery specific
requests to print services. It also aggregates discovered printers
and delivers them to the interested apps. The mediator minimizes
printer discovery session creation and starting and stopping discovery
by sharing the same discovery session and discovery window with
multiple apps. Lastly, the mediator takes care of print services
enabled during discovery by bringing them up to the current
discovery state (create discovery session and start discovery if
needed). The mediator also reports disappearing of the printers
of a service removed during discovery and notifies a newly
registered observers for the currnet printers if the observers are
added during an active printer discovery session.

3. Fixed bugs in the print UI and implemented some UX tweaks.

Change-Id: I4d0b0c5a6c6f1809b2ba5dbc8e9d63ab3d48f1ef
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
269403b032f965ff3847eb982c2f697229dc5a92 15-Aug-2013 Svetoslav <svetoslavganov@google.com> Implemented advanced printer selection and API refactoring.

1. Added past printer history tracking and merging favorite printers
with discovered printers.

2. Added save as PDF support.

3. Added all printers activity with search capability and optional
add printers chooser (if any print service provides add printers
activity)

4. Refactored the printer discovery session APIs. Now one session
can have multiple window discovery windows and the session stores
the printers found during past discovery periods.

5. Merged the print spooler and the print spooler service - much
simpler and easier to maintain.

Change-Id: I4830b0eb6367e1c748b768a5ea9ea11baf36cfad
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
66160bb881470a691005c8ad4e9c31c41fd5f810 13-Aug-2013 Svetoslav <svetoslavganov@google.com> Partial implementation for the favorite and available printer tracking.

1. Added a dedicated class that keeps track of the user's favorite printers
based on past usage. We keep the last 50 uses and assign a decreasing weight
to older historical use records. The printer whose records' sum is the
largest is considered the favorite for the user and so on.

2. Factored out the printer discovery logic from the print job config activity
into a separate available printers provider class. It encapsulates all the
logic to communicated with the remote print services to discover printers,
keep track of added, updated, and removed printers.

3. Preliminary scetch of the printer chooser acitivty that will show all the
printers.

Change-Id: I5524665f2a9a565f186db85214d5e41a44f4812e
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
55daead3c53a83ac300d76200dd4144f154e07d3 12-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Fix the build

Change-Id: Icf3b339f7b300cc8673443fa8afd38ce78964683
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
798bed6cc7d273e72b0253288605db9cd2b57740 11-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Refinement of the print service APIs.

1. Factored out the printer discovery APIs of a print service in a
dedicated session object that is created by the print service on
demand. This ensures that added/removed/updated printers from
one session do not interfere with another session.

2. Updated the app facing APIs to pass in a document info along
with a printed file. Also exposed the print file adapter so
apps that create a temporary file for printing can intercept
when it is read by the system so the file can be deleted.

3. Updated the print service documentation.

Change-Id: I3473d586c26d8bda1cf7e2bdacb441aa9df982ed
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
695c7fa7a320f1e5b4b56aa7ed6a64c6220f6502 08-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print UI polish based on UX feedback.

1. Refreshed the print UI based on UX redlines.

2. Implemented tap outside cancel for the print job config activity
which is full-screen but pretends to be a dialog.

Change-Id: I5afc7cd40c696109d70af31536898cfcad91b2ab
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
32c5eb3bf89938ba2221e67362571628e1efd520 07-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Update the print job dialog and added notification assets.

1. Update the transition between the print job edit dialog and the
generating print job dialog. Now the former shrinks into the
latter.

2. Added most of the notification assets.

Change-Id: I84f35df5cb4f71b86a103c16ab87fd4d108b055b
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
14db9654f6c31e94fe9272776f1f1b8602a17fdc 06-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print UI polish (a.k.a. just the next iteration))

1. Added a dialog to show a spinner while the app is writing the
printed content.

2. Fixed print job config acitivity leaking.

3. Updated the notifications a bit.

Change-Id: I8314390135a49605ee11ab4ed14b210a29566745
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
55b5f8028a72d1da58835b6766798d781ad92b97 05-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Disable print dialog spinners if there is only one option.

Change-Id: Ic9a46c737b592aeb6f78c962a7f9d53391a2b164
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
835835ee6f913408ac91678d6056896a2c5b25e3 05-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Polish the print spooler loading of stored print jobs.

1. The singleton print spooler isntance is created when the print spooler
service gets a connection to the system and is destroyed when this
connection is removed. Note that if the spooler has work, then the
connection to the system will not be removed.

When the spooler is created, it reads the stored state and notifies the
system which in turn dispatches this to the print services.

When the system connects to the spooler and passes it a connection, we
schedule a delayed check whether there is work for the spooler. We do
not handle this immediately to avoid intermitted spinning on and off
of the spooler process if a client makes a sequence of queries while
the spooler has really no work.

2. Fixed a bug in the NotificationManagerService where adding a notification
and removing it immediately after that does not remove the notification.
The code that is adding a notification is run on a handler thread while
the code to remove it on the calling thread. This creates a race and
erroneous results. Now the removal is also scheduled on the handler.

3. Many small fixes here and there.

Change-Id: I6415c253139fa6616393fbe23c659d031a29e1f6
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
8c43376ea83a67414bd6823a472b76d41160239e 02-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> First cut of the print notifications.

1. Added notifications for a queued print job, for a started print job,
for ongoing canceling a print job, and for a failed print job. The
notifications for queued and started state have a cancel action. The
notification for failed print job has a cancel and a restart action.

2. Propagating failure message from the print service to the notifications.

3. PrintJobConfigActivity was not setting the initial value for the
print job copies and was not updating the UI immediately after creation.

4. Refactored PrintJobConfigActivity to avoid using the hack to avoid
reaction for item selection change in a spinner for an event that
happened before the callback was registered.

5. Removed the label attribute from PrinterInfo and now PrinterId is
composed of the printer name and the service component name. This
is nice since for restarting print jobs we do not need to store
information about the printer except the printer id which is
already part of the PrintJobInfo's data. Also the printer name
is not expected to change anyway.

6. Allowing cancellation of a queued print job. Also no print job is
cancelled without asking the managing print service to do that.
Before we were immediately canceling print jobs in queued state
but it was possible for a buggy print service to not set the
print job state to started before starting to do expensive work
that will not be canceled.

7. PrintServiceInfo was throwing an exception the the meta-data
XML for the print service was not well-formed which would crash
the system process. Now we just ignore not well-formed meta-data.

8. Removed unused permissions from the PrintSpooler's manifest.

Change-Id: Iba2dd14b487f56e137b90d1da17c3033422ab5e6
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
55b409a97cf6376399a0940313ea852368727d6f 01-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Iteration of the print sub-system.

1. Added APIs for adding partially initialized PrintInfo objects
enabling light-weight lookps for print serivces that want to
populate the list of available printers without querying each
of them for its capabilities. This includes APIs for the system
to request from a print service to update certain printers.

2. Fixed a bug in PrinterId#equals().

3. Added equals and hasCode implementaion to PrinterInfo. Also
the defaul in PrinterInfo are now an array instead of a
SparseArray - cheaper.

4. Now PrintJobConfigActivity works with partially specified
printers. Specifically, if such a printer is selected the
activity is requesting from the print service to update
the printer. We are currently not handling the timeout case.
It also handles udpated pritners.

Change-Id: I5e83e924ef597c9e22cbd06a971d4f4d3bd3a9c1
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
85b1f883056a1d74473fd9ce774948878f389ab6 25-Jul-2013 Svetoslav Ganov <svetoslavganov@google.com> Iteration on the print sub-system.

1. API changes: Moved copies API from PrintAttributes to PrintJobInfo;
Changed the PageRange list to an array in PrintDocumentAdapter#onWrite;
Added onCancelled method to the layout and write callbacks.

2. Refactored the serialization of remote layout and write commands. Now
the commands are serialized by the code in the client instead in the spooler.
The benefit is simple code since the client has to do a serialization to delegate
to the main thread anyway. The increased IPC found is fine since these calls
are quite unfrequent.

3. Removed an unused file: IPrintSpoolerObserver.aidl

4. Added equals and hasCode implementation to PageRange, PrintAttributes,
MediaSize, Resolution, Margins, Tray, PrintDocumentInfo.

5. Added shortcut path for query APIs on PrintJob that return cached values
if the print job is in a uncuttable state, i.e. completed or cancelled. Failed
print jobs can be restarted.

6. PrintJobInfo was not properly serialized.

7. Updated the look of the print dialog to be stable if there is and there isn't
currently selected printer.

8. PrintJobCOnfigActivity now calls onLayout on every print attributes change
but requests a write only on print preview or print button press. Also if the
layout did not change the content and it is already written no subsequent
call is made. Also if the selected pages change and we already have them
no subsequent call to write is made. Also the app is called with print preview
attribute set when performing layout and with it cleared after the print button
is pressed. A lot of changes making sure that only valid actions are enabled
in the activity (looks like a dialog) at a given time frame. The print job config
activity is also hidden after we got all the data, i.e. layout and write are done.

9. The callback from the print spooler to the system are scheduled via messages
to avoid lock being held during the call. It was hard to guarantee that since a
method holding a lock may be calling one that would like to release the lock
at some point to make the callbacks.

10. Print spooler state is persisted only if something changes in a completed
print job, i.e. not one that is being constructed due the print job config dialog.

11. Fixed a potential race in the RemotePrintSpooler where it was possible that
a client that got a handle to the remote spooler calls into an unbound spooler.
E.g: the client gets the remote interface with a lock held, now the client releases
the lock to avoid IPC with a lock, during the IPC scheduling the spooler has
notified the system that it is done and the system unbinds from it, now the
client's IPC is made to a spooler that is disconnected.

Change-Id: Ie9c42255940a27ecaed21a4d326a663a4788ac9d
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
0d1daa50f6d180c57f92596501e2e5c0b5ef9997 23-Jul-2013 Svetoslav Ganov <svetoslavganov@google.com> Updating the print dialog and its interactinos with the printing app.

1. Added support for reporting the old print attributes during layout.
Now we keep track of the old print attributes, so the app can
compute the delta and decide whether re-layout work is needed.

2. Fixed PrintDocumentAdapter callback interleavings. Layout callbacks
were intermixing with write ones - a mess. Now we make an attempt
to cancel layout and write if they respond to cancellation, otherwise
we wait but do not interleave them.

3. Refactored the PrintJobConfigActivity for easier maintenance and
to have a single update UI method that does the minimal amount
of work.

Change-Id: I31ada1a0550882e6185018e6f17f923aed165d15
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
597945fd3a6b52ac70bb9afc5ec8c59039fffd77 18-Jul-2013 Svetoslav <svetoslavganov@google.com> First pass of the print dialog UX

Change-Id: I315a16d7f68c73ca180c76e722847b4b1bdea55b
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
6283608e0bd40548742839f5a8b02f7e5c9c5c7c 17-Jul-2013 Svetoslav <svetoslavganov@google.com> Tweak the print APIs.

1. Adding bundle with metadata to PrintDocumentAdapter#onLayout
with one key for now to specify whether this is for a preview.

2. Cleaned up docs.

Change-Id: I89380781bf3ae41aa89f8a0347d74516a210394c
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
17b7f6e6d4ec9f5e9597bfd283f1c017b6c66275 25-Jun-2013 Svetoslav <svetoslavganov@google.com> Clean up of the print APIs.

1. Fixed a case in which the onPrintCompleted callback may not be invoked.

2. Added string resulrces for the different error messages for failed
printing in OnPrintCompletedCallback

3. Fixed the string comments for the MediaSize constants.

4. Added APIs to create certain print attributes by passing in a
string label instead of resource and package name since in some cases
a print service may be getting already internationalized lables
or it may not know all possible values.

5. Fixed a crash in PrintJobConfigActivity if there is no input or
output tray.

Change-Id: Ie877b7dc669051606394aa290e6d2b979a42db4c
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
a00271533f639c8ed36429c663889ac9f654bc72 25-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Refactoring of the print sub-system and API clean up.

1. Now a user state has ins own spooler since the spooler app is
running per user. The user state registers an observer for the state
of the spooler to get information needed to orchestrate unbinding
from print serivces that have no work and eventually unbinding from
the spooler when all no service has any work.

2. Abstracted a remote print service from the perspective of the system
in a class that is transparently managing binding and unbinding to
the remote instance.

3. Abstracted the remote print spooler to transparently manage binding
and unbinding to the remote instance when there is work and when
there is no work, respectively.

4. Cleaned up the print document adapter (ex-PrintAdapter) APIs to
enable implementing the all callbacks on a thread of choice. If
the document is really small, using the main thread makes sense.

Now if an app that does not need the UI state to layout the printed
content, it can schedule all the work for allocating resources, laying
out, writing, and releasing resources on a dedicated thread.

5. Added info class for the printed document that is now propagated
the the print services. A print service gets an instance of a
new document class that encapsulates the document info and a method
to access the document's data.

6. Added APIs for describing the type of a document to the new document
info class. This allows a print service to do smarts based on the
doc type. For now we have only photo and document types.

7. Renamed the systemReady method for system services that implement
it with different semantics to systemRunning. Such methods assume
the the service can run third-party code which is not the same as
systemReady.

8. Cleaned up the print job configuration activity.

9. Sigh... code clean up here and there. Factoring out classes to
improve readability.

Change-Id: I637ba28412793166cbf519273fdf022241159a92
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
4b9a4d16872bbb50712e007b419ac0b35ff1582d 12-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Print - platform APIs

Related changes:
Skia (inlcude PDF APIs): https://googleplex-android-review.googlesource.com/#/c/305814/
Canvas to PDF: https://googleplex-android-review.googlesource.com/#/c/319367/
Settings (initial version): https://googleplex-android-review.googlesource.com/#/c/306077/
Build: https://googleplex-android-review.googlesource.com/#/c/292437/
Sample print services: https://googleplex-android-review.googlesource.com/#/c/281785/

Change-Id: I104d12efd12577f05c7b9b2a5e5e49125c0f09da
/frameworks/base/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java