Commit Graph

130 Commits

Author SHA1 Message Date
Jeff Sharkey
98af2e4fec Add RequiresFeature annotation.
Certain APIs require that a device have a specific feature to operate
correctly, so start annotating them.

Test: builds, boots
Bug: 72284763
Change-Id: Ie2f30284bdfdb6acc4067f434eba3b5433837606
Exempt-From-Owner-Approval: simple annotations
2018-02-16 20:45:22 +00:00
Jeff Sharkey
45c97df89d Move more folks to FileUtils.copy().
Also extend API to accept a "count" argument of exactly how many
bytes to copy, and return the actual number of copied bytes.

Improve docs.

Test: bit FrameworksCoreTests:android.os.FileUtilsTest
Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java
Bug: 71932978
Change-Id: I8d255e4f97462838c02a8ecb6d2d221188c4eff0
2018-02-01 16:01:55 -07:00
Jeff Sharkey
ce8db99114 Add more IntDef prefixes for auto-documenting.
Test: builds, boots
Bug: 70177949
Exempt-From-Owner-Approval: annotation-only changes
Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
2017-12-13 20:05:36 -07:00
Colin Cross
6584e5e650 Merge "Remove unused AIDL files" am: d0abc863f4 am: 43f665c95e
am: 3dbbd3d3a9

Change-Id: Ida23b5013fa6a3e1fd6ba3e5a699f798f29b4b84
2017-12-05 01:10:14 +00:00
Colin Cross
43f665c95e Merge "Remove unused AIDL files"
am: d0abc863f4

Change-Id: Ia6d798f6acf3930945cac488db81ccec3792648d
2017-12-05 00:06:29 +00:00
Colin Cross
4e1b9c199d Remove unused AIDL files
These files show up in a glob for all AIDL files, but are not listed
in AIDL files to be built, and have no references in codesearch
except for one unused import.

Bug: 70046217
Test: m checkbuild
Change-Id: I7d6a3bb19d2e16b5f09473f3058afcf5b4edd9b6
2017-12-04 11:14:25 -08:00
Philip P. Moltmann
c0a128dc2b Dump print manager as proto
Test: incident_report print. Having no entries
Change-Id: I3c7d611e44c0d3bf8e00775b1708bd82a334121a
2017-07-25 11:32:24 -07:00
Philip P. Moltmann
6870033d37 Enforce permission for print system APIs
The permission is preinstalled as we want to leave the PrintSpooler
unpriviledged.

Test: Checked that Settings, PrintSpooler and BuiltInPrintService still
      behave as expected.
Fixes: 62350107
Change-Id: Id33896f2899533f2d05cafa926df29cf1c6bfa77
2017-07-14 16:16:13 -07:00
Philip P. Moltmann
26b21c4f6b Document what ALL_PAGES returning from onWrite means
Bug: 37802299
Test: Doc only change
Change-Id: I816e22b11951f9800eac988a5d86d96b9afa8912
2017-06-16 15:13:17 -07:00
Svetoslav Ganov
2dcedc1276 Ensure only test print services enabled - framework
Test: cts-tradefed run cts-dev -m CtsPrintTestCas

bug:62232727

Change-Id: I1050272586d1c03dc1b1dfdb8b10e258912a249b
2017-06-07 18:50:05 -07:00
Jeff Sharkey
d86b8fea43 Annotate @SystemApi with required permissions.
Most @SystemApi methods should be protected with system (or higher)
permissions, so annotate common methods with @RequiresPermission to
make automatic verification easier.

Verification is really only relevant when calling into system
services (where permissions checking can happen on the other side of
a Binder call), so annotate managers with the new @SystemService
annotation, which is now automatically documented.

This is purely a docs change; no logic changes are being made.

Test: make -j32 update-api && make -j32 offline-sdk-docs
Bug: 62263906
Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
2017-06-05 13:27:11 -06:00
Philip P. Moltmann
7e01895e69 Return inet addr for discoverable printers
... by extending the RecommendationInfo to store the inet addresses not
just the count. Thankfully the recommendation plugins already contained
all the printers, not only the count.

Also expose the print service state as system APIs as they will be used
by the default print service.

Bug: 35765644
Test: Ran AddPrinterActivity on network that had printers to discover
Change-Id: I929a177adb75f6848848ba30a472cf0343d2e67e
2017-04-06 11:54:53 -07:00
Philip P. Moltmann
8f6feec73f Allow print services to read advanced options.
Test: Ran adjusted test that is subitted along side
Change-Id: Ic662c6a6e56c3184611b30947fd715b57df196c0
Fixes: 28913410
2016-10-04 17:19:33 -07:00
Philip P. Moltmann
c49bf6a63b Fix doc for default print document content type
Since Kitkat the default was always 0 == document.

Change-Id: I9c6236073898f5e62ec80f95a21fd394802fe1dd
2016-07-06 17:18:44 -07:00
Philip P. Moltmann
127c9715b4 Merge \"Merge \\"Do not remove handlers for loaders.\\" into nyc-mr1-dev am: b6ee468b3e\" into nyc-mr1-dev-plus-aosp
am: 1134308842

Change-Id: I80459fe11f37ad937c5855d296a81b2d002370d2
2016-06-27 18:28:25 +00:00
Philip P. Moltmann
00c3659eca Do not remove handlers for loaders.
In rare situations we might trigger a force-load if the handler	is
stopped.

Change-Id: I103744654805dcbe0744b09b5be9da1f505817d3
Fixes: 29581798
2016-06-24 20:13:41 +00:00
Philip P. Moltmann
2e3012624b Add event tracking to print UI.
Bug: 29391676
Change-Id: Iec09ac7296e50329e87268bcb70f5e60d566961c
2016-06-20 11:50:44 -07:00
Philip P. Moltmann
823715d656 Rename 'thousands of an inch' to 'thousandths of an inch'in the docs.
Fixes: 28268203
Change-Id: I4246bc7431d1e0ecb75a6d101ba6ccd548567704
2016-04-21 16:29:43 -07:00
Philip P. Moltmann
c863489e67 Prevent printing from finishing activity.
Bug: 27861927
Change-Id: I00177ca0ec75cc8f7fd422907a2b5827b5db406b
2016-04-20 11:54:00 -07:00
Philip P. Moltmann
0d1407e609 Fix Print CTS tests.
Fixes: 27971210
Change-Id: Ied11b2f1c528fe5e204e683d988b4efbd2562ef0
2016-04-01 12:22:13 -07:00
Philip P. Moltmann
e680a8db52 Make sure PrinterCapabilitiesInfo always have sane values.
Change-Id: I1ae7fe6aabdbe7f9480c4067690338103adaafa2
2016-03-31 10:26:26 -07:00
Philip P. Moltmann
4723f36d3e Make sure PrintDocumentInfo is always sane.
Change-Id: I73cf554d42dc33b7a1f6577088ec53b447f14c8c
2016-03-31 10:26:25 -07:00
Philip P. Moltmann
aa8a4fed07 Make sure PrintAttributes have sane values.
Please note that null and 0 values mean "unset" and that margins
historically allowed negative values.

Change-Id: I1773bc552142345e18c1c31fb25e583d0ed070a2
2016-03-31 10:26:25 -07:00
Philip P. Moltmann
9dcb86a48d Add the print service recommendation service
This service connects through the print manager to the print spooler:

PrintSpooler.AddPrintersActivity <-> PrintManager <-> PrintManagerService <-> UserState <-> RemotePrintServiceRecommendationService <-> PrintRecommendationService <-> PrintRecommendationServiceImpl

Hence there is a lot of mindless plumming.

The actual changes are only in the AddPrintersActivity which is extended
to show another list of services: The recommended services.

The PrintServiceRecommendationService is based on the experimenal print
service stubs provider. This provider was contributed the Android by
Mopria. As this services uses Android own network discovery service most
code from the experimental provider goes away. In fact the only logic
left over is the selections of mdns-txt fields to look at and the
printer vendor configuration.

This relies on the Android MDNS to get fixed (Bug: 27696905). This also
does not deal with how to update the recommendation service.

Bug: 24533249
Change-Id: I6edc6e25fc08a50d478b61c71bb8ea158b08624c
2016-03-30 17:21:07 -07:00
Philip P. Moltmann
456f1e33b8 Merge "Update print preview when option is changed and clear ranges when they layout changes" into nyc-dev 2016-03-30 21:44:19 +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
Philip P. Moltmann
4ef83c4647 Update print preview when option is changed and clear ranges when they
layout changes

Before we updated the print preview when the paper size changed but not
when the page ranges changed. This is not consistent. We always change.

Also if there is a change to the options that changes the layout (i.e.
papersize, orientation, minMargins) then clear the selected ranges as
this does not make sense anymore.

This also fixes a bug that when having pages selected while we reduce
the number of pages in the preview we got a NPE.

Bonus: do not constantly re-update the options UI when range or copies
text is updated.

Bug: 27830850, 27741420
Change-Id: I7abe4a74b44ac5c5ee54d12cc0c1ca1540793f0e
2016-03-24 16:20:20 -07: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
Jeff Sharkey
f8880561e6 When system server goes down, crash apps more.
Similar to first patch, but now using new "rethrowFromSystemServer()"
method which internally translates DeadObjectException into
DeadSystemException.  New logic over in Log.printlns() now
suppresses the DeadSystemException stack traces, since they're
misleading and just added pressure to the precious log buffer space.

Add some extra RuntimeInit checks to suppress logging-about-logging
when the system server is dead.

Bug: 27364859
Change-Id: I05316b3e8e42416b30a56a76c09cd3113a018123
2016-02-27 17:17:01 -07: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
e33b954165 Merge "Check parameters for callers of IPrintManager" 2016-01-26 22:52:58 +00:00
Philip P. Moltmann
5ddbc2af0c Merge "Correctly deal with non-null ness of PrintJobId." 2016-01-26 18:25:23 +00: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
22f86b4e77 Correct nullability in PrintJob.
Unfoturnately printJobInfo.getId() can be legitimately null. Maybe that
can be fixed, but until this is addressed we have to deal with it.

Change-Id: I2bf816dfde49e85d51523beba2c3401f5a6ee55e
2016-01-21 13:42:37 -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
1c8f1e06a6 Shorten LOG_TAGs to fit in 23 characters as commented on by lint.
Change-Id: Ie9415fc3de642493bc36c0159b773d8ce2436df5
2016-01-20 15:16:48 -08:00
Philip P. Moltmann
cdf2b40034 Enforce non-nullness in PrinterId and exploit it.
Change-Id: Ifdf3b2329548a665d609dd66b738baab5c765b54
2016-01-14 15:59:44 -08:00
Philip P. Moltmann
fdb2b7644f Correctly deal with non-null ness of PrintJobId.
Change-Id: I217885247467e3900b53f8a2ab32306a50351154
2016-01-14 15:37: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
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
b8c1a02adb Fix wrong annotation for PrintInfo.Builder.setStatus
Change-Id: I11fd68497c6229d16c0827f4753f485e9095649d
2016-01-06 21:42:31 +00:00
Philip P. Moltmann
bb36206f08 Rename variable that hides the contatining classes name.
Change-Id: Iad0a9b341a866d33d10b7a389d243e677a65057c
2015-12-22 20:24:58 -08: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
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
Philip P. Moltmann
b4efdb4726 Deal correctly with suggested print attributes
An app might suggest certain attribute for an print job. This patch
fixes

- PrintActivity should not silently overwrite the attributes with
  the default values
- Handle duplex mode in PrintAttributes similar to the other attributes.
  I.e. have an "unset" value (0). This is an API change. But the only
  use case for PrintAttributes was to pass them to print() and thereby
  the PrintActivity. This was broken (see above), hence we are changing
  and API that could have never been used.

Bug: 23629618
Change-Id: I43c25704497c799352fb806126dc93f6db4879f5
2015-11-10 17:09:30 -08:00
Philip P. Moltmann
853a6f564a Add a alert that allows the user to approve a print service when
we print using it the first time.

This warning used to be shown when the print settings app was used
to enable a service.

If two warning as shown for the same print service we automcatially
dismiss all dialogs once one dialog is confirmed. Please note that
we are not confirming the printjob as it is unexpeced to have a
single click to confirm multiple print jobs.

Change-Id: I8bb0a49bac2063c1c55e2f24bd34df2c44e2df89
Bug: 24135353
2015-11-09 09:49:26 -08:00
Andreas Gampe
b95d079c80 am e4bdf3c1: am be549f9b: Merge "Frameworks/base: Fix precedence bug"
* commit 'e4bdf3c1c9e7be06b68cc32f9a492d512bf87528':
  Frameworks/base: Fix precedence bug
2015-03-17 20:56:02 +00:00
Andreas Gampe
869d26fda0 Frameworks/base: Fix precedence bug
Explicit cast has higher precedence than shift.

Bug: 19797138
Change-Id: Ifcf569bf774fbf65ee50c078f736ad167bcc6b8c
2015-03-17 20:31:22 +00:00
Svetoslav
948c9a6393 Add duplex mode support.
This change adds support for duplex printing. The print UI now has a duplex
option which allows the user to choose one of the supported duplex options
by the currently selected printer. The chosen duplex mode is propaged to the
print service that manages this printer.

Change-Id: I807ba9da2723531535c0e1e33f2f4e1b503a54b0
2015-02-04 05:48:48 +00:00