Commit Graph

48 Commits

Author SHA1 Message Date
Jeff Sharkey
2ab510ee24 Merge "Add RequiresFeature annotation." 2018-02-16 20:45:41 +00:00
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
Tor Norbye
cd81e71542 Add OWNERS file for the annotations package
Change-Id: I7d4aee38ac79aea239d0d208ed0abba7174a9101
2018-02-15 11:13:27 -08:00
Jiyong Park
3b0867ec3a Make SystemApi retained at runtime
SystemApi annotation is now retained at runtime in order for the
CtsSignatureTest to extract the list of System APIs from the device and
compare it with the known list of the APIs. Until now, the test only
ensured that the known list of the APIs exist in the device, but didn't
ensured the opposite. In order words, it was possible for device
manufacturers to revive the APIs that were once deleted. This will
become a problem when SystemAPIs will be allowed to non-system partitions
such as vendor. An apk in the vendor partition which is using the
revived-but-officially-deleted System API will break when the system
partition is replaced with the Generic System Image (GSI) built from
AOSP, which doesn't have the deleted API. (Running CTS on GSI is part of
the Treble compliance tests)

The overhead of retaining this annotation at runtime is small, because
the relationship from an entity (a class, a field, a member, etc) to the
annotation is recorded as a 4 byte offset field [1].

[1] https://source.android.com/devices/tech/dalvik/dex-format#annotations-directory

Bug: 70832217
Bug: 67891551
Test: measure the size increment before and after. framework.jar was
increased by 2964 byte.

Change-Id: I679b19ac5ce57d33ce59e32b3b1753f8a1962e11
2018-01-02 21:41:29 +09:00
Jeff Sharkey
8439ac08b1 Start accepting Executors instead of Handlers.
After discussion in API council, our new best-practices are to have
developers provide an Executor to dispatch callbacks/listeners on,
instead of the previous guidance of using a Handler.

Define Context.getMainExecutor() to easily obtain an Executor
associated with the main thread of application.  This allows new
APIs to require a @NonNull Executor.  Also define a new
@CallbackExecutor auto-doc annotation that explains background and
points developers at new Context method above.

Test: cts-tradefed run commandAndExit cts-dev -m CtsContentTestCases -t android.content.cts.ContextTest#testMainLooper
Test: cts-tradefed run commandAndExit cts-dev -m CtsContentTestCases -t android.content.cts.ContextTest#testMainExecutor
Bug: 70348426
Change-Id: I536892bcd80fcfba1bb1ddf67648c08a26d7ddd2
2017-12-13 13:59:04 -07:00
Jeff Sharkey
27674aedc0 Merge "Add auto-doc support for @StringDef." 2017-12-11 16:47:13 +00:00
Tor Norbye
f740c7ea08 Switch @IntDef from long to int, and add @LongDef
This CL mirrors changes made to the android.support.annotation version
of IntDef, to keep the usage and semantics identical (though the
internal version of @IntDef and @LongDef are of course hidden and not
part of the SDK.)

Test: These annotations have source retention and therefore have
no runtime impact; the change was compiling the SDK.

Change-Id: Idaf47e8d983c88be1bd8f938615c86611014b45a
2017-12-08 20:54:50 -08:00
Jeff Sharkey
5db9a91135 Add auto-doc support for @StringDef.
Behaves pretty much the same as @IntDef, but now supports "suffix"
in addition to "prefix" when matching constants.

Test: manual docs output looks sane
Bug: 70406696
Change-Id: I35064b0f9f36f1f13ccdb40302d818a004014f15
2017-12-08 17:33:40 -07:00
Tor Norbye
b10cde243a 67002586: Create @NavigationRes + Lint check
Bug: 67002586
Test: Tested in lint
Change-Id: I9c497a56bd6a57cc559e053cc2f41342a6dd6c33
2017-09-27 12:30:02 -07:00
Tor Norbye
3f1ccec743 64123323: Allow marking fields with @TargetApi(XX)
Test: Tested as part of lint
Change-Id: I52dcc0ea788ed916d23be4d7c9fb76755a1aa6b8
2017-08-03 20:02:31 +00:00
Matthew Gharrity
cb43616ad1 Enable thread annotations for parameters
This allows us to indicate that an argument (especially a lambda or
method reference) will be invoked on a separate thread. This will be
used to improve interprocedural thread annotation checks.

Test: n/a
Change-Id: I035733f8bfb1ba47f0995f38783681d105661dc5
2017-07-24 14:27:37 -07:00
Jeff Sharkey
ec68b46bc8 Merge "Annotate @SystemApi with required permissions." into oc-dev am: c1406978a4
am: 7a2e4a8486

Change-Id: Ib629e25dbf047c110feaf03e4ff744b5c6df9aeb
2017-06-06 15:48:24 +00: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
Tor Norbye
6413795bbb @IntDef and @StringDef must have source retention
They reference constant references, not constant values,
and this cannot be expressed in the .class file for
annotations; the data is instead extracted at build time
into external annotation data files.

Test: Manual

Change-Id: I06b366ba8815d1da40e6cbf906ebae09899c1b8e
2017-05-12 15:58:38 -07:00
Jeff Sharkey
30e06bb668 Even more auto-doc work.
Update docs based on what new lint detector found.  Add new @IntDef
to parameters or methods returning constants or flags, and add
@RequiresPermission to methods mentioning permissions.

Test: make -j32 offline-sdk-docs
Bug: 37526420
Change-Id: I7f640f7883fcb66b911a52ae93b83f77306571ec
2017-04-24 13:20:46 -06:00
Jeff Sharkey
910e081216 More auto-doc work.
Add support for AnyThread, CallSuper, and UiThread.

Another related CL started documenting @RequiresPermission, so remove
duplicated information in existing APIs.

Suppress auto-doc on a handful of classes that are already
well-documented.

Test: make -j32 offline-sdk-docs
Bug: 37526420
Change-Id: I791437dccec0f11d5349a23b982ba098cb551af8
2017-04-21 16:35:08 -06:00
Jeff Sharkey
6503bd8e33 Auto-generate docs based on annotations.
We have a handful of annotations that we've been sprinkling across
the platform APIs, such as @Nullable, @NonNull, @IntDef, etc.  It
would be really helpful to surface these contracts to developers
through the SDK docs.

This change allows annotations like those mentioned above to declare
the following new javadoc fields:

@memberDoc: docs to append to a field or method definition.
@paramDoc: docs to append to a @param definition.
@returnDoc: docs to append to a @return definition.

This change also builds a docstring to describe the list of all
constants listed in an @IntDef annotation.  Sadly AnnotationDesc
only passes along raw constant values, so we need the help of the
new "prefix" annotation argument to help find the field names.

Test: builds
Bug: 37526420
Change-Id: I4cfc00dd904e5dfa945b406d546e36846b7c0c28
2017-04-20 17:21:41 -06:00
Jeff Sharkey
32ee8eefd7 Create new BroadcastBehavior annotation.
This will be used to help document the expected behavior of various
broadcast actions defined by the OS.

Also add logic to PackageParser that will then yell at developers
whose manifests are making bad assumptions about which broadcasts
they'll receive.

Test: builds, boots
Bug: 35925551
Change-Id: I059c2bf8aa3ce53d9ff18dcc263db7620cd14bd6
2017-03-08 20:19:31 -07:00
Romain Guy
95b52fd187 Make Half look like and behave like a boxed instance
Bug: 35765416
Test: HalfTest
Change-Id: I7ef52428f8b4e2c05b91d7eb37cc4cb5ecc5c6b9
2017-02-26 09:37:52 -08:00
Clara Bayarri
ed00bfdfae Implement .xml font resource support
This change implements the loading and parsing
of xml type font resources, and makes sure it is
used properly by TextView styles.

Test: run cts -m CtsContentTestCases -t android.content.res.cts.ResourcesTest
run cts -m CtsWidgetTestCases -t android.widget.cts.TextViewTest#testFontResources*

Change-Id: I5a2930b3ba7dad67d9607e9036a5dde6bab0c5a4
2017-01-27 20:16:48 +00:00
Romain Guy
68bd5fdd1a Introduce android.graphics.ColorSpace
This class can be used to define color spaces. A color space has a color model
and a profile connection space (CIE XYZ D50). This implementation can be used
to query various properties of RGB color spaces or perform conversions between
various color spaces (RGB, XYZ and Lab).

Refer to the documentation for more details.

Test: cts-tradefed run singleCommand cts-dev --module CtsGraphicsTestCases --test android.graphics.cts.ColorSpaceTest
Bug: 32984164
Change-Id: Ie2117c1212c1375a7d403d3c1afaf73d7c2e0b47
2016-11-23 18:10:04 -08:00
Romain Guy
5d7e2352e7 Add @HalfFloat annotation for fp16 data types stored in shorts
This CL has a companion CL to add the @HalfFloat annotation to the
support library.

Test: cts-tradefed run singleCommand cts-dev --module CtsUtilTestCases --test android.util.cts.HalfTest
Bug: 29940137
Change-Id: I4e1dc456687c1c026437150e9cc94a54f3264d4e
2016-11-14 09:27:26 -08:00
Tor Norbye
17dd669fc3 Add @AnyThread, @Dimension and @Px
These are already present in the support library.

Change-Id: I1d049370266685ea993fb53108fd7aea96ea71d0
2016-06-28 12:42:37 -07:00
Tor Norbye
a05b650098 Fix @IntDef annotation javadoc
Change-Id: I1a4fc4a1a731fc8732279950dcd8416ab125aed3
2016-01-12 21:33:58 -08:00
Jeff Sharkey
8588bc1ef1 Add flags to requests for package UID/GIDs.
This gives callers the ability to request details for missing
packages.  Also add annotations for userId and appId variables and
start tagging their usage.

Change-Id: I63d5d7f870ac4b7ebae501e0ba4f40e08b14f3f6
2016-01-07 10:33:26 -07:00
Neil Fuller
71fbb81b14 Fix @code escapes
The body of {@code} must not be HTML escaped. This is one of
several changes that fix the source in conjunction with a
doclava fix.

Bug: 25757239
Change-Id: Ib38a0fa2dd2a3d68e467f78a812071e763d7e881
2015-12-02 14:24:11 +00:00
Michael Wright
b2b2c0e7d0 Add new TestApi annotation.
This allows us to build a special jar with methods exposed strictly
for CTS. An @TestApi should not be a public API or a system
API.

Bug: 25608286

Change-Id: Ifbc64bb6958d2deec5b9cf0b944acfd068f0f051
2015-11-25 13:01:03 +00:00
Tor Norbye
dce982733e Merge "b/22228577: Improve @IntDef annotation to handle special values and ranges" 2015-08-03 13:46:06 +00:00
Tor Norbye
8cf2c902c5 b/22228577: Improve @IntDef annotation to handle special values and ranges
(Will be used to for example solve
181789: Incorrect/inconsistent lint + documentation for Snackbar
)

Change-Id: I843a9286b6af6e14640391e6f0261c398d6963fa
2015-07-31 16:42:41 -07:00
Tor Norbye
5fffc1688b Allow @RequiresPermission to be specified on parameters
This allows you to express that the permission requirement
on a method depends on a given parameter; static analysis
tools should then trace the supplied value backwards to
see whether it points to a constant which in turn has been
annotated with @RequiresPermission.

Change-Id: Ifaf3c2517a2c416b00409d646d6ec881c6b7af18
2015-07-05 15:48:27 -07:00
Tor Norbye
63fc151475 Merge "Add @RequiresPermission" 2015-04-23 18:36:33 +00:00
Tor Norbye
f8b833605e Add threading annotations
These describe threading requirements for a given method,
or threading promises made to a callback.

Change-Id: If496067b12df3a0adedc32e4b4005cd1c2d400f3
2015-04-20 15:59:17 -07:00
Tor Norbye
8f506ed28c Add @RequiresPermission
Change-Id: I70f3ce003154069654df10080edea2b85ffaab6b
2015-04-20 15:45:00 -07:00
Tor Norbye
bc2dd79af9 Add @TransitionRes for transition resource integers
Change-Id: I37f523282156c2f87c4d961167d6a980d5f6e34c
2015-03-13 11:19:21 -07:00
Tor Norbye
5b00941a6f Fix @ColorInt javadoc
Change-Id: Icea3a3b4013b4a6b5f9809eec082ea93bc26b079
2015-03-10 19:14:03 -07:00
Tor Norbye
80756e3888 Annotate ARGB integer parameters with @ColorInt
Change-Id: I307f72a382272cf18ddb6b07d9fcb81228568d9a
2015-03-05 16:34:12 -08:00
Tor Norbye
cb59f2afb7 Additional annotations: @CallSuper, @Keep, etc.
These mirror the new support library annotations, but
with source retention.

Change-Id: Ib85ceeb37d596aae8cf12d4f8fede3982552d033
2015-03-05 16:34:11 -08:00
Jeff Brown
d5a5b5a547 Rename PrivateApi annotation to SystemApi.
Change-Id: I97b473884f81ad375d0733e4766afe091dfdd854
2014-06-06 15:16:27 -07:00
Tor Norbye
9940de968e Add resource reference annotations
These annotations allow you to annotate an int parameter or return
value to indicate that the int should correspond to a resource
constant (such a R.string.app_name).

Change-Id: I3a0b2ef0b943bdf9d5a2e1f978ccf3445eed829a
2014-03-27 13:07:00 -07:00
Gabriel Peal
f1e1e77143 resolved conflicts for merge of 74fb97de to master
Change-Id: If28dc21a2ea7e634da130f3c59c17cd63dd5336a
2014-03-25 11:08:19 -07:00
Tor Norbye
bbc75f34e6 Hide NonNull and Nullable.
These should not be used in app code; instead, we will add
class-file retention versions of these to the support
library.

Change-Id: I13275bd28529f5da04d923688655be35c77dbb1c
2013-12-17 08:44:38 -08:00
John Spurlock
6090995951 Remove unused imports from frameworks/base.
Change-Id: Ia1f99bd2c1105b0b0f70aa614f1f4a67b2840906
2013-11-20 11:31:47 -05:00
Tor Norbye
831c5df603 Add @NotNull, @Nullable, and @IntDef/@StringDef annotations
This changeset adds some annotations for recording whether a
method return value or method parameter can be null (@Nullable),
can never be null (@NotNull), or must be an integer enum or flag
using one of the given constants.

Change-Id: Ic932592ea3bac781c1df364447c57042461333c5
2013-08-15 13:19:25 -07:00
Xavier Ducrohet
d2726ba47e Add tools specific annotations to the API.
Those annotations are not runtime retention and have zero impact
on the device builds.

Change-Id: I18d905fccfe18eb621e1411d7ae7ba97910cc727
2012-01-31 15:56:40 -08:00
Xavier Ducrohet
3274b9b7da Add Annotation for optional features.
This is used by the SDK to display available features in the
editors.

Change-Id: I10073d503d1b3dcb92a5dc526cd054285b85fa3a
2009-12-14 17:52:20 -08:00
The Android Open Source Project
9066cfe988 auto import from //depot/cupcake/@135843 2009-03-03 19:31:44 -08:00
The Android Open Source Project
d83a98f4ce auto import from //depot/cupcake/@135843 2009-03-03 18:28:45 -08:00
The Android Open Source Project
54b6cfa9a9 Initial Contribution 2008-10-21 07:00:00 -07:00