Commit Graph

393 Commits

Author SHA1 Message Date
Yein Jo
4440afb935 Fix SpringAnimation class cast exception.
this is a hot fix for the regression caused by ag/20171590, may need more investigation to properly handle it.

Bug: 255723033
Test: Failing Tests
Change-Id: I129f69d2979405b33c8b46430c7b1ec8559105aa
2022-11-01 01:29:17 +00:00
Shan Huang
80c44686c2 Add AndroidX SpringAnimation library to core.
This allows core libraries (such as predictive back progress animation)
to use spring animation.

Files in androidx/dynamicanimation/animation that are not copied over:

FlingAnimation.java - Unused atm
AnimationHandler.java - Replaced with the framework AnimationHandler
FloatPropertyCompat.java - Replaced with FloatProperty
FrameCallbackScheduler.java - Unused in framework AnimationHandler

Test: m -j
Bug: 238475284
Change-Id: Ifdf847da0aa2a6cf57e18f9ac7c91bb0fe3b12c2
2022-10-17 20:45:41 +00:00
Steven Terrell
063ae10a70 Use System Property to Control Animator Pausing
This change sets the default behavior of animator pausing by checking if
a system property is set and useing that value if present else it
defaults to true. This should allow the use of build properties to be
able to toggle the behavior.

Bug: 233391022

Test: Manual, adding logging to verify the values being set by the call
      to the sysprop library.

Ignore-AOSP-First: Testing internal change, will cherry pick to AOSP.
Change-Id: Ib1b34585c564bf4f310441c6856412a798022900
2022-06-06 18:26:16 +00:00
Chet Haase
506ca2410e Disable debug logging in AnimationHandler
LOCAL_LOGV should be set to false

Bug: 232914479
Bug: 233391022
Test: Manually tested to ensure logging is not happening
Change-Id: Ie14cf3c0bacb50dd1e7422dc378d5195e4d9bec5
Merged-In: Ie14cf3c0bacb50dd1e7422dc378d5195e4d9bec5
2022-05-23 20:31:19 +00:00
Chet Haase
161732cf18 Allow system to disable behavior of pausing animators for bg apps
This change adds a static method which can be called to disable the
default behavior of pausing infinite animators when an app's windows
are all in the background. This could potentially be used for
global behavior of a system property to disable this behavior system
wide.

Bug: 232937493
Bug: 233391022
Test: Added new cts test to AnimatorLeakTest to verify behavior
Change-Id: Idf4957e3968253228096671fde89f820311883e3
Merged-In: Idf4957e3968253228096671fde89f820311883e3
2022-05-23 20:31:19 +00:00
Chet Haase
b99cc5b4c8 Pause animators when app is not visible
Because animators are not tied to the lifecycle of any UI
elements, it is possible for an app to go into the background
and for the animators to continue running. Ideally, the app would
track the lifecycle of the activity/etc and pause or disable the
animators, but it is common for this to not happen, causing the
animators to continue spinning when the app does not need them.
The animators are not causing as much work as for a foreground
activity (since they do not cause any re-rendering), but they cause
work nonetheless by keeping Choreographer awake to continue pulsing
frames.

The ideal fix would be to introduce new API for animators that
tied them to lifecycle concepts (View, Activity, etc). But that kind
of fix would only be available for future versions of the platform,
and does not address existing app code. A workaround for the current
situation is to address the most egregious problems; infinite animators
running on backgrounded apps.

The fix here is exactly that: when an app's visible surface (either an
activity or, for Wallpapers, a WallpaperService) is backgrounded,
a request is sent to pause animators for that surface. When that surface
comes to the foreground, a request is sent to resume those animators.
Since all animators are handled on the same thread for the same process,
in AnimationHandler, we should only ever pause animators when *all*
surfaces for a process are not visible (and resume them when *any*
surface becomes visible). Also, to mitigate any issues with thrashing
animator state for apps which become only transiently backgrounded,
we delay pausing for some time.

Bug: 228598053
Bug: 233391022
Test: new AnimatorLeak CTS test, plus manual testing for activities
    and wallpapers

Change-Id: I8b9f841cc80babb972244c724968a5c085a06b69
Merged-In: I8b9f841cc80babb972244c724968a5c085a06b69
2022-05-23 20:31:19 +00:00
Sally
e85fe22d45 Add @FloatRange to DurationScaleChangeListener.onChanged
Test: builds
Bug: 224543281
Change-Id: Idd10b488dc3baea0e1644e5b2a165866274100d6
2022-03-14 20:22:47 +00:00
Sally
60442cb1b8 Add API to read and listen to duration scale changes for animations
Developers and accessibility services can remove animations by
changing the duration scale to zero. Physics-based animation
libraries like AndroidX's dynamic animations aren't duration-based,
but they need to know the duration scale to remove animations.

Expose the scale through ValueAnimator to avoid requests for
Context which may not be fulfilled by the developer.

Unhide test API getDurationScale and handle callbacks on the main
thread.

Test: atest ValueAnimatorTest
Bug: 221303983
Change-Id: I3134e0bf007df046a9a2aa0f9d866c27c7989e68
2022-03-10 21:23:17 +00:00
Alan Viverette
ad5658bb16 Nullability annotations for animation and graphics
I inferred nullability annotations in Jetpack based on the guaranteed
behavior of the platform, so now I'm propagating those inferences back
to the platform as annotations.

Test: nullability presubmit checks
Fixes: 206801689
Change-Id: If969bbe8a2263a3dd6cc1497a01354648a8795e9
2022-02-03 17:03:47 -05:00
Jorim Jaggi
09e25c5cdc Add option to trace animation fraction
In order to investigate animation value skipping directly from
traces when needed.

Bug: 210125581
Change-Id: I6febb148de12bb586344d29e4713ac7e523714ea
2021-12-13 14:37:03 +01:00
Jeff Sharkey
fab0ab3c9c Improve OWNERS coverage across frameworks/base/.
As general background, OWNERS files expedite code reviews by helping
code authors quickly find relevant reviewers, and they also ensure
that stakeholders are involved in code changes in their areas.

Some teams under frameworks/base/ have been using OWNERS files
successfully for many years, and we're ready to expand them to cover
more areas.  Here's the historical coverage statistics for the last
two years of changes before these new OWNERS changes land:

-- 56% of changes are fully covered by OWNERS
-- 17% of changes are partially covered by OWNERS
-- 25% of changes have no OWNERS coverage

Working closely with team leads, we've now identified clear OWNERS on
a per-package basis, and we're using "include" directives whenever
possible to to simplify future maintenance.  With this extensive
effort, we've now improved our coverage as follows:

-- 98% of changes are fully covered by OWNERS
-- 1% of changes are partially covered by OWNERS
-- 1% of changes have no OWNERS coverage

This specific change is automatically generated by a script from
detailed ownership information confirmed by team leads.

Bug: 174932174
Test: manual
Exempt-From-Owner-Approval: refactoring with team leads buy-in
Merged-In: I9789c97c1de8e5d962b48c29c57d82fe83729eba
Change-Id: I9789c97c1de8e5d962b48c29c57d82fe83729eba
2020-12-08 08:36:27 -07:00
Mathew Inwood
5d123b6775 Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
2020-11-04 09:45:53 +00:00
Xin Li
628590d7ec Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Lais Andrade
b491f9871c Change variable name fix from 'endingListener' to 'endListener'
Follow up aosp/1382536 by correcting the term used while renaming
a few variables and methods from AnimatorSet.

BUG=162536543

Change-Id: I9b914663790664b3f0de7774864207e90ce3f7a1
2020-08-03 14:04:00 +00:00
Lais Andrade
e89e18b7a2 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

#inclusivefixit

BUG=162536543

Change-Id: Ieda6c7d61cfe8ddba1b0d80c8b87d82a9895fa31
2020-07-31 10:26:14 +00:00
Jorim Jaggi
6d5c801c78 Use separate thread if app doesn't listen to animations
There is no need to introduce jank risk and run the inset
animations on the main thread if the app doesn't listen to
animation events. In that case, move the animations onto a
separate thread.

Bug: 118118435
Test: Inspect systrace
Change-Id: Ib6e4b4ce8e9dd8e27761ced6eb8d7700b6236a32
2020-03-11 22:58:59 +01:00
Automerger Merge Worker
b615fa46c9 Merge "Use new UnsupportedAppUsage annotation." am: 70129fc863 am: fe3063fb71
Change-Id: Iea82f97f0ba766ce3f435630175aea48ca47f12f
2020-01-09 16:15:31 +00:00
Artur Satayev
d9b11b058c Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I8789f8499d4dca08580672e9e45ed9a7026dd686
Merged-In: I8789f8499d4dca08580672e9e45ed9a7026dd686
2020-01-09 13:56:05 +00:00
Artur Satayev
c895b1b450 Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I8789f8499d4dca08580672e9e45ed9a7026dd686
2019-12-18 16:37:37 +00:00
Artur Satayev
79aff5c601 Merge "Add @UnsupportedAppUsage to test apis that are known to be used by apps." am: a98026f7aa
am: 59318bab67

Change-Id: Ic691d764839ecf34daa8b53aa92497e013c9a2a7
2019-11-13 10:40:54 -08:00
Artur Satayev
5a525851a8 Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 15:05:56 +00:00
Artur Satayev
f0b7d0ba51 Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 12:58:29 +00:00
Joshua Baxter
a39ce8b0e6 docs: fix typos
Change-Id: Ifee929d0adaaa94c5026a4b0fdf926489af639b5
test: make ds-docs
bug: 37009580
2019-11-06 21:14:23 +00:00
TreeHugger Robot
6167cf18a6 Merge "Restrict reflection access to ValueAnimator's sDurationScale" 2019-02-06 19:33:36 +00:00
Daniel Santiago Rivera
61fe23a1bc Restrict reflection access to ValueAnimator's sDurationScale
An alternative method, areAnimatorsEnabled() can be used to determine
if animations are turned off or not. Otherwise, reflection access of the
value are not permitted since it is an implementation detail that can
break battery saver mode or user's choice of disabling system-wide
animations.

Bug: 123767751
Test: n/a
Change-Id: I2146613a5921e229f7db641c34732bc1044766fc
2019-02-05 13:13:38 -08:00
Andrey Kulikov
95c1046495 Restrict usage of LayoutTransition.cancel() methods
This is used by androidx.transitions only for the API levels less than 18, so it is safe to restrict it after P.

Bug: 123769438
Test: none
Change-Id: Iaff4d5741c7cf952cbff61c3b580ef1ec0618009
2019-02-04 19:05:37 +00:00
kopriva
c997fc62e0 Merge "docs: fixing errors found with lint check" into pi-dev am: 8c7d2142f6
am: 4d12f4c42b

Change-Id: I96a6dab05b6d4ea40950fe2ddc0948adf1b4e48f
2018-10-09 13:29:04 -07:00
kopriva
4d12f4c42b Merge "docs: fixing errors found with lint check" into pi-dev
am: 8c7d2142f6

Change-Id: Ief137b64e798b4b5bb6be5e6d25a35e08037abe5
2018-10-09 13:18:06 -07:00
kopriva
a1a7848f83 docs: fixing errors found with lint check
This covers directories through /app.

removed unused import in KeyguardManager.java

Test: make ds-docs

Bug: 117494359

Change-Id: Ie2536676ae8d3ab9349aa43dc3e3248b618dd143
Exempt-From-Owner-Approval: Docs-only change
2018-10-09 10:27:35 -07:00
Mathew Inwood
e54e7590d7 Merge "Add @UnsupportedAppUsage annotations" am: 058b566f90
am: 38a6375f99

Change-Id: I92ad1b36f7fbd1ff9b1379ccf7a561158e82029b
2018-08-03 04:29:45 -07:00
Mathew Inwood
38a6375f99 Merge "Add @UnsupportedAppUsage annotations"
am: 058b566f90

Change-Id: I982201ecfc2f257ff5509de10a73549ebe657aff
2018-08-03 04:17:45 -07:00
Mathew Inwood
61beb3399e Add @UnsupportedAppUsage annotations
For packages:
  android.animation

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I6702ce1fb26452971e5eee8da15d5816dd75bb12
Merged-In: If0667154031b254fd632e1332fb65e9b08955755
2018-08-01 14:42:25 +01:00
Mathew Inwood
a228c37ba2 Add @UnsupportedAppUsage annotations
For packages:
  android.animation

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: If0667154031b254fd632e1332fb65e9b08955755
2018-08-01 14:35:45 +01:00
Laura Davis
93fae901a2 Merge "Merge "Docs: fixed variables" into pi-dev am: 116158689c" into pi-dev-plus-aosp
am: bd935bf41a

Change-Id: I7617577dd4fc8dc0944deb76e95142f96dade2a7
2018-06-26 10:09:12 -07:00
Laura Davis
b7ffb5fde5 Docs: fixed variables
Test: make ds-docs

Bug: 25134282
Change-Id: Ic91dd3820a409f0f28e23575090e3fd624a0fac0
2018-06-25 13:05:24 -07:00
Doris Liu
0b2c83643f Remove unnecessary value setting in AnimatorSet seeking
Also fixed seeking in paused state

BUG:68274315
BUG: 68382377
Test: ag/3835109
Change-Id: Ifa6b717a77a34f2152bd0e7ad285556986dd47ff
2018-04-02 17:55:33 -07:00
Jorim Jaggi
c2333b7ef6 Add ability to override global duration scale on ValueAnimator
This is needed as window animations are being ported over to use
ValueAnimator, and thus ValueAnimator need to ability to support
custom duration scales per object.

Test: ValueAnimatorTests
Bug: 64674361
Change-Id: Iea8d673b66e52866929174bbf6ca4a7ae882807b
2017-11-16 00:07:50 +00:00
Doris Liu
290271695d Fix end() for infinite AnimatorSet
BUG: 66880433
Test: repo steps in the bug above

Change-Id: If34b7386b7ff5cd28144e99c37957abddb068e9c
2017-09-26 17:04:36 -07:00
Wale Ogunwale
a5e833e846 Merge "Ensure that we use SF Vsync Choreographer for the PiP transition." into oc-dev am: e1e0db8ca9
am: 90159a2492

Change-Id: I0092411f5b8bef853b55e6ffe7bdf700876f7715
2017-06-13 01:08:25 +00:00
Winson Chung
4a526c1245 Ensure that we use SF Vsync Choreographer for the PiP transition.
- Move the bounds animation onto the animation thread
- Remove existing code referencing the old sf-vsync choreographer
- Add ability for ValueAnimator subclasses to reference a different
  AnimationHandler, which uses a different FrameCallbackProvider with the
  sf-vsync choreographer in the animations that require it
- Ensure that PiP touch events are batched and sent aligned with the
  sf-vsync
- Move GC onto its own thread to not block other BackgroundThread calls

Bug: 36371375
Test: android.server.cts.ActivityManagerPinnedStackTests
Test: bit FrameworksServicesTests:com.android.server.wm.BoundsAnimationControllerTests
Test: go/wm-smoke

Change-Id: I6a41b35a4e4d4d6dbea82c2673452825fe3ffa58
2017-06-12 10:08:58 -07:00
Doris Liu
ba087b09fc Merge "Merge "Better handle non-recommended use and warn against it in JavaDoc" into oc-dev am: 8d06d8cbf1" into oc-dev-plus-aosp
am: 721ecfd21a

Change-Id: Iec199dd0cfe7beace7549d3e16e888458fd0306c
2017-06-07 03:58:45 +00:00
Doris Liu
8d06d8cbf1 Merge "Better handle non-recommended use and warn against it in JavaDoc" into oc-dev 2017-06-07 03:43:13 +00:00
Doris Liu
88bb31b954 Better handle non-recommended use and warn against it in JavaDoc
BUG: 62386748
Test: Follow repro steps in b/62358678. The issue is no
longer reproducible

Change-Id: Ic3cec7c4947296224edb5365d81988d4da7ee5e1
2017-06-07 01:41:34 +00:00
Doris Liu
7d0b3bbf15 Merge "Ensure start delay is properly scaled with duration scale" into oc-dev am: 9057f846ac
am: 4b5d12d25a

Change-Id: I80a1dc2c898a9456b651f6b1375055e6fcb59540
2017-06-01 01:05:17 +00:00
Doris Liu
2ac6547824 Ensure start delay is properly scaled with duration scale
BUG: 62126024
Test: CTS test in the same target branch
Change-Id: Ia396e69e053ccd90cdf37ac0b59c404c9952e497
2017-05-31 18:09:47 +00:00
Chet Haase
367804f1e4 Merge "Fix infinite loop problem in AnimationHandler" into oc-dev am: 163ec051d1
am: 3fb0e7555f

Change-Id: I91064e4baf1333c25d55d06e4373c83243c3e0da
2017-05-31 14:11:47 +00:00
Chet Haase
da9374211f Fix infinite loop problem in AnimationHandler
AnimationHandler.doAnimationFrame() iterates on a list that may be changed
during the course of the lopp, especially when Battery Saver is enabled, or
animators have zero duration, coupled with user code launching new animators
when old ones end.

The fix is to iterate through the old size of the list, and avoid processing
new animators in the current frame.

Bug: 37376806  Keyboard doesn't come up when battery saver is turned on on Android O
Test: manual
Change-Id: I40ca1d849e6f337779c23edbab22d80760c22f9b
2017-05-26 16:56:12 -07:00
Aurimas Liutikas
01e1b8550d Merge "Remove internal listener when cloning" into oc-dev am: a7dde34a81
am: c59f75af1d

Change-Id: Ia44c46f0784c412d71956c9e7f1e17533c991b9c
2017-05-16 16:00:56 +00:00
Philip Quinn
7fb80f7d27 Update the mTotalDuration for each animation in an AnimatorSet.
A cache was introduced in I677bc289f2ba430466f2d90ebc14368cb7b75118 to
optimise calls to createDependencyGraph(), but the update was removed in
If1dc6e8dbc93a4bf5ade8c5b0dcf43d3ee6ba7b5. This patch reintroduces the
update when calculating child animation start/end times to re-enable the
optimisation.

Test: cts-tradefed run cts-dev --module CtsAnimationTestCases
Change-Id: Ie9dad4049c07a151889b57809bf844ab854ff482
2017-05-15 21:36:30 +00:00
Doris Liu
c457547cbd Remove internal listener when cloning
BUG: 38270215
Test:  adb shell am instrument -w
com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ia80d5f8958e320ad7d51ef7a08168763c8988146
2017-05-13 01:39:07 +00:00