summaryrefslogtreecommitdiff
path: root/core/java/android/os/Handler.java
Commit message (Collapse)AuthorAgeFilesLines
* SystemService post-completed user eventAdam Bookatz2022-01-241-0/+4
| | | | | | | | | | | | | | | | | | | | Introduces a new SystemService stage that indicates that user events (user-switch, user-starting, user-unlocked) have completed. This can be used by services for non-urgent tasks that must be completed after the event in question, but can be delayed until later. As long as they happen close enough in time, only a single event will be sent (per user) which will contain information about all the onUser-completion events it represents. TODO: Also trigger the call when the user-switch UX has completed (rather than waiting for the hard-coded delay). First we need to find an appropriate signal for "switch UX is complete". Test: atest UserControllerTest Test: manual confirmation using VoiceInteractionManagerService Bug: 197344658 Change-Id: Id8e6ce8e9c46f86d48d0a76085123c0c3dd1f2ea
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-2/+2
| | | | | | | | | | | | | | | | | | | 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. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-2/+2
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-2/+2
| | | | | | | | | | 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 Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Merge "Add method in Handler to remove messages with equal object" am: ↵Automerger Merge Worker2020-03-171-0/+31
|\ | | | | | | | | | | 36216f6f23 am: ed0ddab0d7 Change-Id: I36e853e01d6e9f657a931b1a64eadf1e0d82c456
| * Add method in Handler to remove messages with equal objectfengjinlan2020-03-171-0/+31
| | | | | | | | | | Change-Id: Ibae80f5008df54f4ac8544abb4cc5863ea3db86d Signed-off-by: fengjinlan <fengjinlan@xiaomi.com>
| * Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-131-1/+1
| | | | | | | | | | | | | | | | | | 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: I534e3fd1305e2f4af076986770033478448a665c Merged-In: I534e3fd1305e2f4af076986770033478448a665c
* | Use new UnsupportedAppUsage annotation.Artur Satayev2019-12-181-1/+1
| | | | | | | | | | | | | | | | 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: I534e3fd1305e2f4af076986770033478448a665c
* | Merge "Deprecate implicit Handler constructors" am: 560c3ebe1e am: 080ddd5dfdCharles Munger2019-11-191-7/+27
|\| | | | | | | | | | | am: 952dd95b46 Change-Id: Ia2de7c065ec5b8941087cd5c02eb9589f72c27b8
| * Deprecate implicit Handler constructorsCharles Munger2019-11-151-7/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These have been the cause of bugs in the past, such as b/10150258, because it's not always obvious or guaranteed that a calling thread will always have a looper, or that it's actually the looper you want. Specifying the looper explicitly, even if it's just Looper.myLooper(), makes the code clearer. Since callback APIs generally should have Executor variants added, it might be nice to also deprecate the constructors or options that rely on the calling thread's looper, but since I don't have an inventory of all those I'm starting with this. Bug: 144042891 Test: No behavior changes Change-Id: I0e7ba80d6b89a866ea715c790dd602ef728bf5bd
* | Integrate pooled lambda with systrace.Felipe Leme2019-09-261-0/+4
|/ | | | | | | | | | | | | | | | | | | | Looper traces handler calls by calling Handler.getTraceName(), which when used with PooledLambda ends up showing just: "android.os.Handler: com.android.internal.util.function.pooled.PooledLambdaImpl" That name doesn't help understand what's the real bottleneck, and even worse, could let people think it's the PooledLambda who's causing it. Which this change, it will display names like: com.android.server.appop.AppOpsService$Lambda com.android.server.wm$Lambda Fixes: 141172840 Test: manual verification (neither PoolLambda nor Message have unit tests) Change-Id: I80d2158a50a644b10f3724fb42a4a9c2aee63ae9
* Add @UnsupportedAppUsage annotationsAndrei Onea2019-03-151-0/+9
| | | | | | | | | | | | | | | | For packages: android.os 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: I4ece0a3f37f88fc2508cb965092aed7cabc61819
* Add nullability annotations to Handler's public APIJake Wharton2019-03-081-45/+44
| | | | | | Fixes: 126702574 Test: none Change-Id: I396665e0971c6dc8eabbcfa32dee07bcdce13061
* Make ContentCapture calls directly from the UI thread.Felipe Leme2019-02-041-0/+5
| | | | | | | | | | | | Most calls are bufffered anyways, so by not using a handler we save time spent on getting a pooled lambda and posting to the the handler. The only "expensive" operation is flushing, but it makes a oneway binder call so it might be fine (and if necessary, we can optimize it later). Bug: 123307965 Test: atest CtsContentCaptureServiceTestCases Change-Id: I7182c8e193f58fa000396fdb3003e771214bf79b
* Rename WorkSource methods on Binder and IPCThreadState.Olivier Gaillard2018-11-151-1/+1
| | | | | | | | This change only renames methods, there is no behavior changes except using the new restore methods instead of clear. Test: unit tests Change-Id: I35ae966461657e2e2a67e916d752b9ee53381c83
* Add work source uid collection to LooperStatsMarcin Oczeretko2018-09-201-0/+2
| | | | | | | | | | | | | | Add ThreadLocalWorkSourceUid and Message.workSourceUid which will store the UID which caused, directly or indirectly, the Message to be enqueued. This was needed because using Binder.getCallingUid() does not give us enough data since quite a few Binder services call Binder.clearCallingIdentity() when processing the call. Test: UT and manual Change-Id: I35af3a9ca5193477070990b41ff5d9c52f420069
* docs: fixed typo am: 9b5c03973ekopriva2018-09-131-1/+1
|\ | | | | | | | | | | am: 05f984a1a8 Change-Id: I8b70d412c1d422be5cbc8e041acc3fe340617181
| * docs: fixed typokopriva2018-09-101-1/+1
| | | | | | | | | | | | | | | | | | Test: make ds-docs Bug: 36942287 Change-Id: I6931817127a7b98a4b97e0e18cf4d654231c32f9 Exempt-From-Owner-Approval: Docs-only change
* | Un-@hide Handler.hasCallbacks.Jake Wharton2018-05-181-2/+0
|/ | | | | | | | You can post messages with an int or int+Object, query if they're posted, and cancel them. With a Runnable, however, prior to this change you could only post and cancel them. Bug: 37015636 Test: existing Change-Id: Icb9ba40ebb32fb962cec8a88e2222f68fe629057
* Add factory methods for async HandlersAdam Powell2018-03-191-1/+38
| | | | | | | | | | | | | Message.setAsynchronous is already public and this makes working with posted messages that do not interact with UIs quite a bit nicer. Added as factory methods for better integration with support shims as well as generally encouraging the use of the handler callback instead of subclassing for working with custom messages. Bug: 73124158 Change-Id: I1210e7dc524fdf771e7af19297d5a822fdbd502c
* Use PooledLambda in print codeEugene Susla2018-02-231-0/+17
| | | | | | | This replaces the usage of handler message types with PooledLambda Test: atest CtsPrintTestCases Change-Id: I19b01278b67b5fe18d48a2e0bb8300bbe1413a63
* Fix magnification button toggle offEugene Susla2018-01-231-1/+2
| | | | | | | Fixes: b/69307379 Test: Ensure attached bug no longer reproduces. Ensure magnification using a11y button otherwise works as expected Change-Id: Ie4e966eb8cfcc9d3f37ae7252b951381ef1fb7c7
* Add overload to postDelayed which accepts a token.Jake Wharton2018-01-031-0/+28
| | | | | | | | This adds overload parity with postAtTime. Test: none Bug: 71546743 Change-Id: I50936c7ffd5e8512dc865863fe8d4c9fb228a8a9
* Fix Handler.Callback.handleMessage javadoc.Pavel Grafov2017-07-121-3/+4
| | | | | | | | | | Currently arguments and return value annotations are applied to the whole interface and aren't rendered at all: https://developer.android.com/reference/android/os/Handler.Callback.html#handleMessage(android.os.Message) Test: nothing to test. Change-Id: I8cb44f7a6c339971b770e9bf769efee8294b4d28 Bug:36127602
* Work on issue #36891897: Need to ensure foreground services...Dianne Hackborn2017-06-141-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | ...can't hide themselves Tune the policies for when we tell about apps running in the background after their services have stopped. - If it ran while the screen was on, the time we require for it to be running is much shorter (a couple seconds) as well as the time we tell about it having run (with another tunable for the minimum time we tell about this). - If it has only run while the screen is off and stops a sufficient amount of time before the screen goes on (currently a second) then we will not show anything when the screen goes on. - If it stops when the screen turns on, we will make sure the user sees about it for a short period of time (currently 5 seconds). Also includes some improved debug output about handler message queues. Test: manual Change-Id: Iab438410d7182b2dfe4f9c1cce7069b26b34834c
* Unbind from service on app killed and dedup association requestsEugene Susla2017-03-241-0/+18
| | | | | | | | | | | | | | 1. Listen to calling package binder death stopping the scanning on that. 2. Don't restart scanning when a request with the same values was made. Bug: 30932767 Test: 1.: - Using a test app start scanning and kill the app. - In debug mode ensure that DeviceDiscoveryService#stopScan gets triggered 2.: - Start scanning and rotate the device while device chooser is visible - Ensure no visible loss of state is happening Change-Id: If126a2c963da90172a956fbd88e6b3dcd7ac8b01
* Automatically trace messages on shared loopers.Jeff Sharkey2016-04-071-1/+13
| | | | | | | | | | | | There are a handful of looper threads in the system_process that are shared by dozens of different internal services. To help track down what these operations are, tag the processing of each message with a string that tries describing where it originated from: the class name of the Handler, and the message number or class name of the Runnable. Bug: 28046299 Change-Id: I409ec43fea8daaae4fd70df05d4fed929a7249ae
* Make Message.setAsynchronous() public.Jeff Brown2014-11-111-3/+3
| | | | | | | | | | | | | | | | | There are many cases in real world applications where it is desirable to continue processing messages on the Looper even when most other messages have been suspended by a synchronization barrier pending completion of the next drawing frame on vsync. Internally the framework is able to mark certain messages as being independent of these higher level synchronization invariants by flagging them as asynchronous. This change exposes the existing function and improves on the documentation so that it is clearer what is meant by asynchronous. Bug: 18283959 Change-Id: I775e4c95938123a364b21a9f2c39019bf37e1afd
* Add new sendingUid field to Message.Dianne Hackborn2014-06-281-0/+1
| | | | | | | This tell you where the message came from when it was delivered through a Messenger. Change-Id: I86a5f521c8ae919b45872dd76b61e83447f397ab
* Document that Handler.postDelayed uses uptimeMillis() based counting.David Christie2013-12-191-0/+5
| | | | | | | | -Make it clear that delay may be longer than requested. -Potentially help developers avoid power bugs (e.g. releasing after delay). Bug: 12015795 Change-Id: I8034466f6307f64bfcad985948c1dc06872297d3
* Add javadoc to Handler.Callback.handleMessageKristian Monsen2013-06-051-0/+3
| | | | | | | Describing param and return value. There is a public bug for this at: https://code.google.com/p/android/issues/detail?id=6464 Change-Id: Ia917cd4e047b629e6511bf12a91a5e953da8ae2e
* Fix change of behavior in Looper.quit().Jeff Brown2013-04-181-5/+10
| | | | | | | | | | | | | | | | | It seems some applications rely on Looper.quit() terminating the loop immediately without processing all messages. Rather than risk breaking them, make the safer behavior optional. Also take care to properly drain the message queue before quitting so that all of the Message instances are recycled. This may help release storage sooner in case the Looper doesn't get GC'd promptly and its remaining queue of undelivered messages sticks around. Improve docs on runWithScissors. Bug: 8596303 Change-Id: I8cbeb6f7a5f6b8e618b5109f87a03defc1486b9f
* More improvements to the display manager.Jeff Brown2012-08-311-7/+29
| | | | | | | | | | | | | | | | | | | | | | | | | Added more complete support for logical displays with support for mirroring, rotation and scaling. Improved the overlay display adapter's touch interactions. A big change here is that the display manager no longer relies on a single-threaded model to maintain its synchronization invariants. Unfortunately we had to change this so as to play nice with the fact that the window manager wants to own the surface flinger transaction around display and surface manipulations. As a result, the display manager has to be able to update displays from the context of any thread. It would be nice to make this process more cooperative. There are already several components competing to perform surface flinger transactions including the window manager, display manager, electron beam, overlay display window, and mouse pointer. They are not manipulating the same surfaces but they can collide with one another when they make global changes to the displays. Change-Id: I04f448594241f2004f6f3d1a81ccd12c566bf296
* Run with scissors.Jeff Brown2012-08-291-0/+81
| | | | | | | Add a useful (if somewhat dangerous) method which will help replace similarly dangerous code patterns in a few different places. Change-Id: If1295f7ab9652c906ce718d94eb7914d143e1939
* Make it easier to create asynchronous Handlers.Jeff Brown2012-08-251-43/+75
| | | | | | | | | | | There are potentially very many Handlers owned by services that should not be blocked by barriers introduced by UI traversals occurring on the same thread (if that ever happens). Add some convenience constructors to make it easy to switch these Handlers over to being async. Bug: 7057752 Change-Id: I64d9bffe81e7c52ada4cfad4e89d4340153f4688
* Make all messages in KeyguardViewMediator asynchronous.Jeff Brown2012-08-141-19/+46
| | | | | | | | | We don't want these messages to get blocked by UI traversals. Added a convenience for creating Handlers that always send asynchronous messages. Change-Id: Id568e87fcb8b169e8c52c5fe1dc76a4a5771570b
* Fix Javadoc.Jeff Brown2012-04-301-1/+1
| | | | | Bug: 6418632 Change-Id: Ib17218c413cbdf26bab19ccd873de33e67dd3397
* Prevent WebView from crashing when detached from the windowRomain Guy2012-04-231-3/+13
| | | | | | | | | | | | | Bug #6365056 WebView enqueues a functor in the hardware renderer to handle animations and this functor is called at a later time by the hardware renderer. However, the functor was not removed from the queue when WebView was removed from the window. This could cause the hardware renderer to attempt to execute an invalid functor and lead to a crash. Change-Id: I9d38e80f3fdc5e29d4d0cdfa1e893c251a954508
* Improve MessageQueue sync barrier implementation.Jeff Brown2012-02-161-4/+4
| | | | | | | | | | | | | | | | | Instead of acquiring and releasing a barrier using an up/down counter, we post a message to the queue that represents the barrier. This is a more natural representation of the barrier and better matches what we want to do with it: stall messages behind the barrier in the queue while allowing messages earlier in the queue to run as usual. Refactored the MessageQueue a little bit to simplify the quit logic and to better encapsulate the invariant that all messages within the queue must have a valid target. Messages without targets are used to represent barriers. Bug: 5721047 Change-Id: Id297d9995474b5e3f17d24e302c58168e0a00394
* Fix for bug 5115066 Handler override of toString() hides derived class nameKristian Monsen2011-08-091-1/+1
| | | | | | Dynamically getting the class name. Change-Id: I3140bee67ee2e5a1790e53cf4dfc240d3bb25218
* Fix issue #5061083: Handler.removeCallbacksAndMessages...Dianne Hackborn2011-07-211-3/+6
| | | | | | | | ...implementation doesn't match documentation Fix the documentation. Change-Id: I995b88e0f510973eb7d815ae895059e325c30e10
* Add new ViewDebug APIs to profile the event queue.Romain Guy2011-07-151-0/+15
| | | | Change-Id: I225bf288780b0244f459316e2765cfa29cd22c89
* Correct the PackageManager.checkSignatures documentation.Chris Palmer2010-09-101-1/+1
| | | | | | | Make the documentation match the current behavior since change ID Ibdeff170bd386d723f774136b18e0ad59d9cdabb. Change-Id: I9d24800ba98f14cb278f029cdf37a086394d1747
* SharedPreferences$Editor.startCommit()Brad Fitzpatrick2010-08-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a fire-and-forget save method (startCommit) to the SharedPreferences.Editor, which is the way most people use it anyway. This commit adds the implementation. The previous commit added the interface and docs: previous change: Idf9934b445da1fb72b79f0192218b47c0a7f5a34 git commit: edf32d01316bd3432c023f17747461b08ae36375 In addition, this change: -- adds a generic "runPendingWorkFinishers" mechanism to ActivityThread to wait on async operations that are still in flight and use it for this. -- ties runPendingWorkFinishers into Activity.onPause, BroadcastReceiver, and Service. -- makes sSharedPreferences keyed on name, not File, to avoid unnnecessary allocations -- documents and guarantees what thread OnSharedPreferenceChangeListener callbacks run on -- makes a few things in frameworks/base use startCommit(), notably Preference.java (which was ignoring the return value anyway) Change-Id: I1c8db60ad45643226fe6d246d3e513eeb7bd0ebd
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+594
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-594/+0
|
* Code drop from //branches/cupcake/...@124589The Android Open Source Project2008-12-171-9/+55
|
* Initial ContributionThe Android Open Source Project2008-10-211-0/+548