summaryrefslogtreecommitdiff
path: root/core/java/android/app/ClientTransactionHandler.java
Commit message (Collapse)AuthorAgeFilesLines
* Enable forced focus for resumed split screen activitiesMariia Sandrikova2022-12-251-1/+2
| | | | | | | | | This is needed because some game engines wait until they get focus before drawing the content of the app so they are blacked out when they are resumed and do not have focus yet. Bug: 203398248 Test: atest FrameworksCoreTests:ViewRootImplTest#whenDispatchFakeFocus_noFocusAfterwards Change-Id: I5675b32fbb9f60a7373fadbce379d571168436e7 Merged-In: I5675b32fbb9f60a7373fadbce379d571168436e7
* [3/n] Camera Compat: Refresh activityMariia Sandrikova2022-12-211-0/+3
| | | | | | | | | | Introduce RefreshCallbackItem that allows to "refresh" activity by going through "stopped -> resumed" or "paused -> resumed" cycle. This allows to clear cached values in apps (e.g. display or camera rotation) that influence camera preview and can lead to sideways or stretching issues persisting even after force rotation in DisplayRotationCompatPolicy. Using "stop -> resumed" cycle by default due to higher success rate confirmed with app compatibility testing. But introduce ADB commands that allow trying both. Bug: 218352945 Test: atest WmTests:DisplayRotationCompatPolicyTests Change-Id: Iaca54b197937147f93d52297543b106fd5b97322
* Ensure isInPictureInPicture result in onPauseHongwei Wang2022-08-191-2/+2
| | | | | | | | | | | | | | | We use to set Activity#mIsInPictureInPictureMode to be true when app requests Activity#enterPictureInPictureMode and therefore when they receive the onPause callback, Activity#isInPictureInPictureMode can be true. With the new auto-enter-pip API, this code path is no more relevant and here we add extra info to PauseActivityItem to set the same flag when WM puts the Activity into PiP mode due to auto-enter. Video: http://recall/-/aaaaaabFQoRHlzixHdtY/yXi24xi6TgYGhoqB31Oov Bug: 239618513 Test: follow the reproduce steps in bug, see video Test: atest PinnedStackTests Change-Id: I81ece7d3aad8eb868d95f106f6825612e0741a19
* Move fixed-rotation-related display information into configEvan Rosky2022-01-261-5/+0
| | | | | | | | | | | | | | | | | | | | Augment the "apparent" display information in configuration from just the display bounds (maxBounds) to also include the display rotation and cutout. Like maxBounds, these will be expected to always be set as basically "the display that this configuration was built against". This heavily simplifies fixed-rotation since now we don't need to deal with the "are we overriding?" question and also don't need extra activity servertransactions. The configuration is also in sync (since it is the source of truth used by resources). Additionally, this means that even the current legacy fixed-rotation model should work with in any mixed-rotation situtaion, not just fullscreen. Bug: 202201326 Test: atest DisplayTest Change-Id: I6232f74c74324b70b1b0c9f46448c509c2694310
* Store pending override config instead of creating ActivityClientRecordChilun2021-12-281-21/+4
| | | | | | | | | | | | | | | | | | Create ActivityClientRecord early in preExecute may cause NullPointerException. If two LaunchActivityItem using the same token and the 1st postExecute() comes after 2nd preExecute(), the corresponding launching activity will be removed and cause 2nd execute() get NullPointerException. Since the only use case to get ActivityClientRecord in preExecute() is just to use it to store the pending override config. We can directly store the latest pending override config from preExecute() in ActivityThread instead of creating ActivityClientRecord. Bug: 201668069 Test: atest TransactionExecutorTests atest ActivityThreadTest Change-Id: If350e942254e54c9ec90bc63a6e50eb67d038183
* Fixes the flicker when transfer splash screen view to clientwilsonshih2021-10-051-4/+3
| | | | | | | | | | | | | Use applyTransactionOnDraw to ensure all transaction happen during the same frame, including - hide the starting window. - reparent the remote SurfaceView to client. Bug: 198593932 Test: continues launch test app several times then verify with winscope to ensure there is no flicker anymore. Change-Id: I03c600afdc477ca0c8064b215f2b361468db9f3c
* Create ActivityClientRecord early in preExecuteChilun2021-05-261-3/+20
| | | | | | | | | | | | | | | | | We can guarantee that LaunchActivityItem will queue before ActivityConfigurationChangeItem. But ActivityConfigurationchangeItem#preExecute() still has the opportunity to execute before LaunchActivityItem#execute(). And at this time, ActivityClientRecord has not been created. This CL create ActivityClientRecord early in LaunchActivityItem#preExecute() and store in a new list of ActivityThread. Thus others can guarantee to get the ActivityClientRecord in preExecute(). Bug: 187691892 Test: atest TransactionExecutorTests Change-Id: Ib40270345223c5c6e76333803faf98937c5527f9
* Add Activity#onPictureInPictureUiStateChanged and PictureInPictureUiState.Ben Lin2021-04-151-0/+4
| | | | | | | | | | | This adds a new API on Activity such that app developers can get signals when certain PiP UI states change, e.g. stash/unstashed. The idea is that when PiP is stashed, the activity will get a signal to do anything they wish, such as pausing/resuming video-like contents. Bug: 182409584 Test: atest PinnedStackTests#testPictureInPictureStateChangeCallback Change-Id: I308f3f1c3af8d1a54b63311fb3beaee77d6c7922
* Customizable exit splash screen animation.(2/N)wilsonshih2021-02-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce new APIs to customize exit splash screen animation. - SplashScreen This can be used for Activity to handle the exit splash screen animation. - SplashScreen#OnExitAnimationListener When receive onSplashScreenExit, the splash screen view will be on top of the activity. - SplashScreenView The view object which represents the view of current starting window. There are two APIs for developer to control it: - getIconView: get the icon view object. - remove: remove the view and release resources. If an Activity create a OnExitAnimationListener and set on SplashScreen, the core will request a copy of SplashScreenView from Shell, then send the parcelable information to client to reconstruct the view on top of the DecorView, then call onSplashScreenExit to let the listener able to operating this view. Bug: 73289295 Test: build/flash, check splash screen starting window. Test: atest StartingSurfaceDrawerTests ActivityRecordTests WindowOrganizerTests Test: atest CtsWindowManagerDeviceTestCases:SplashscreenTests Change-Id: I9f77fb4471bcf37a7f74d6c18a345ca56c05b716
* Send ActivityOptions to clientRiddle Hsu2021-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | This removes getActivityOptions from server side. So 2 binder transactions from Activity#performCreate and performStart can be eliminated. The remote animation in ActivityOptions is also separated to another field of ActivityRecord, so when consuming the options, the remote animation won't be affected. Bug: 65202329 Bug: 132432864 Bug: 175409544 Test: WmTests:ActivityRecordTests#testTakeOptions ObjectPoolTests#testRecycleStartActivityItem CtsTransitionTestCases:ActivityTransitionTest CtsUsageStatsTestCases:ActivityTransitionTest Change-Id: I600a9a478a3e596e58b0a8120cfa8b9f32598b47
* Revert "Revert "Introduce ActivityTransactionItem and reduce null checks""Chilun Huang2020-09-181-24/+30
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fd2be2c17882c7db2833ed35c2b4da975801e527. Reason for revert: Reland the CL This class is used for activity-targeting item to inherit, which encapsulate null checks of activity client record. This patch also change signature of ClientTransactionHandler#handle* and reduces null checks. In addition, add some null pointer checks after getActivityClient(). Also fix a typo in performStopActivityInner() and performDestroyActivity(). Bug: 127877792 Bug: 164982975 Test: atest frameworks/base/core/tests/coretests/src/android/app/servertransaction Test: atest ActivityThreadTest ActivityThreadClientTest Test: atest TransactionExecutorTests#testActivityItemNullRecordThrowsException Test: atest TransactionExecutorTests#testActivityItemExecute Test: atest CtsAppTestCases:LocalActivityManagerTest Change-Id: Ida612f1c8af7ecd7a04e69ade461403b8711508a
* Revert "Introduce ActivityTransactionItem and reduce null checks"David Srbecky2020-08-171-30/+24
| | | | | | | | | This reverts commit 9b1e955021ce4ce8c09b26c5fb38a2bb9c5a2d6d. Reason for revert: Breaks many tests Bug: 164982975 Change-Id: I86e7b158ae593aab6d73950bbb2b9dc6a7d5093c
* Introduce ActivityTransactionItem and reduce null checksCharles Chen2020-08-101-24/+30
| | | | | | | | | | | | | | | This class is used for activity-targeting item to inherit, which encapsulate null checks of activity client record. This patch also change signature of ClientTransactionHandler#handle* and reduces null checks. Bug: 127877792 Test: atest frameworks/base/core/tests/coretests/src/android/app/servertransaction Test: atest ActivityThreadTest ActivityThreadClientTest Test: atest TransactionExecutorTests#testActivityItemNullRecordThrowsException Test: atest TransactionExecutorTests#testActivityItemExecute Change-Id: Idc0e9f583fc04e3a9043c28e83475acc65710731
* Send fixed rotation adjustments to the associated clientRiddle Hsu2020-05-111-0/+5
| | | | | | | | | | | | | | | | | | | | | So the real information of display can be adjusted according to the adjustments for the application started with fixed rotation transform. The enabling adjustments may be sent in different ways: - Launch activity The information is bundled with LaunchActivityItem. - Resume activity or update non-activity window Send a standalone FixedRotationAdjustmentsItem. The disabling adjustments (null) are always sent by FixedRotationAdjustmentsItem. Bug: 147213487 Test: AppConfigurationTests#testRotatedInfoWithFixedRotationTransform TransactionParcelTests#testFixedRotationAdjustments Change-Id: I5238888a5c8352db83fc12749f4de2bfabf46026
* Move PIP/MW mode callbacks to be on the client sideHongwei Wang2020-04-301-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now infer the PIP/MW mode change from the new configuration. Note also that both - Activity#isInPictureInPictureMode - Activity#isInMultiWindowMode infer the current state from the configuration rather than querying against the WM. Also in this CL: - When in removePinnedStackInSurfaceTransaction, keep the pinned stack hidden till the windowing mode is set to fullscreen, this is to surpress the attempt to set the activities to be started in reparenting - When in ActivityRecord#shouldBeVisible, should take account the force hidden flag, which is not actually in use before Bug: 144097203 Bug: 142282126 Bug: 138329093 Test: atest ActivityLifecyclePipTests \ ActivityLifecycleSplitScreenTests \ ActivityLifecycleTopResumedStateTests \ PinnedStackTests \ SplitScreenTests \ ActivityTaskManagerServiceTests \ RecentsAnimationTest \ AssistantStackTests \ StartActivityTests \ ActivityVisibilityTests \ MultiDisplaySecurityTests \ MultiDisplaySystemDecorationTests Change-Id: Ibe032b5e50ba5c6d6bc44ebb54d07ac974ebe656
* Use START/STOP messages to update visibilityAndrii Kulian2020-01-081-6/+2
| | | | | | | | | | | | | | | | | | Activity visibility messages simply move the activity to STOPPED or STARTED state. We can use the lifecycle messages to do the same and simplify the logic/remove duplicated code. This CL also removes the option to send STOP message without making the client invisible and actually calling onStop(). This option caused a mismatch of the state between server (STOPPED) and client (PAUSED). Also, in cases when the device was going to sleep, STOP message was always followed by SLEEP message, which called onStop() anyway. Bug: 137329632 Bug: 129750406 Test: AM/WM CTS and unit tests Change-Id: I487575520ce301bb2f65519f0c0a30b6b9edac0c
* Add #onPictureInPictureRequested to Activity and ATMjorgegil@google.com2019-12-201-0/+3
| | | | | | | | | | | | | | | Allows vendors to signal that an activity should enter picture-in-picture if possible. Additionally, removes the need for an Activity to go through onPause to enter picture-in-picture. Apps can now override this new API and enter PIP from there instead of relying on #onUserLeaveHint. Bug: 143365086 Test: atest FrameworksCoreTests:android.app.activity.ActivityThreadTest Test: atest CtsWindowManagerDeviceTestCases:PinnedStackTests Test: atest WmTests:ActivityTaskManagerServiceTests Change-Id: Ib7ae9d1a7055ceed73e9643982033de9d4ad7350
* Defer top process state for VMRiddle Hsu2019-04-151-0/+2
| | | | | | | | | | | The top state will make JIT compilation easier to be triggered. To reduce the impact of startup time, if there is launching activity, the top state will be deferred to apply until idle or 1s timeout. The cold launch time of Contacts, Phone, Calculator are reduced ~15ms. Test: AppLaunchTest Bug: 123043091 Change-Id: I8a235e18ea6b508c9aa192445c9ea22d9d12f177
* Remove custom lifecycle transitions for onNewIntent callbackLouis Chang2019-04-081-2/+1
| | | | | | | | | | | Rebased from ag/3785659. This CL switches to using post-execution state resolution for new intent delivery. Also removes some unnecessary code needed for old logic. Bug: 65236456 Bug: 77974794 Test: atest ActivityLifecycleTests Change-Id: I734ad50de498cd2a6b9514c8ef6cb1eeb08e4ec5
* Report top resumed activity state changeAndrii Kulian2019-01-251-0/+10
| | | | | | | | | | | | | | | | | | | | | | Some system resources can only be accessed exclusively by a single client at a time. Previously there was only one resumed activity in the system at any point, so apps were usually trying to obtain such access in onResume. With multi-resume this is no longer a good place to do so, because: - onResume may be called for activity that is not on top; - top resumed status may be switched between different resumed activities in multi-window mode by tapping on them. This adds a separate callback to inform apps about top resumed state gain and loss events. The following rules apply: - both callbacks can only be delivered between onResume and onPause; - top resumed state loss always follows top resumed state gain; - the callbacks are optional, activity can go from onResume to onPause without obtaining top position. Bug: 117135575 Test: atest CtsActivityManagerDeviceTestCases:ActivityLifecyclePositionTests Change-Id: I45797afe47b166b22cfb75b64132b22d3fb4ecc7
* Drop stale activity configuration updates.Garfield Tan2019-01-101-0/+4
| | | | | | | | | | | | | | | | This CL introduces sequence number to activity configurations and use that to compare their staleness. Always use the last reported activity configs for Activity#onConfigurationChanged() and drop all requests that are older than the processed one. Fixes: 120189873 Test: Manually verify that number of configuration changes drops during drag-resizing with a crafted app that needs 250ms to perform one configuration change. go/wm-smoke too. atest FrameworksCoreTests:ActivityThreadTest atest WmTests:ActivityRecordTests Change-Id: Ie0fd15458517470542a689b51283f4d1ed2ad4cc
* Improve transaction loggingAndrii Kulian2018-07-251-0/+2
| | | | | | | | | | Add more detailed conditional logs to transaction executor on the client side for easier debugging. This will print out transaction callbacks and final state requests, as well as target activity names. Test: Manual Change-Id: I14ab1a34985975bfd8c1f90b9c5945e354f79446
* Skip execution of transactions on a destroyed activityRiddle Hsu2018-07-121-0/+5
| | | | | | | | | | | | | | An Activity may not yet create on client side, there is another launch request with flags to clear task, then a destroy transaction is scheduled. If client side keeps blocking until destroy timeout, the token on server side will be removed. When client begins to handle the first creation, it will report its activity token to server that causes IllegalArgumentException because there is no matched ActivityRecord. Bug: 32375307 Test: atest FrameworksCoreTests:TransactionExecutorTests Change-Id: I1b7e0c2863b13091c3fd50df602ff31ae02ff38d
* Preserve custom activity intent on relaunchAndrii Kulian2018-05-021-1/+2
| | | | | | | | | An activity can have a custom intent set via Activity#setIntent(). This was lost in ag/3305584 Change-Id: I88f3e164d2cf7f6c62989bba05cd84b9b83befc3 Fixes: 73181785 Test: ActivityThreadTest#testCustomIntentPreservedOnRelaunch
* Don't require post-execution state for onActivityResultAndrii Kulian2018-04-201-1/+1
| | | | | | | | | | | | According to the documentation, onActivityResult() should be called immediately before onResume(). This, however, was not always the case in previous releases and fixing this caused some app compatibility issues. This CL removes required post execution state for ActivityResultItem. Bug: 77695691 Test: ActivityLifecycleTests Change-Id: Id8c02e9b49f9758aac616e37948570722d802de8
* Remove temporary logging.Bryce Lee2018-04-131-8/+0
| | | | | | | | | | | | This changelist reverts the following CLs that added temporary logging: d946f86f124fca87c757100e49ba7d5b206c8a44 a33c13df134ee3618c72e70a69433a27b934702f e7b2f6920bcb4a989da4798a72fcc61d0572dd60 Fixes: 71506345 Test: presubmit Change-Id: Icfc016a752e5ac2bfb1537be67cda1c4ea3e6442
* Don't finish activity on duplicate resume requestAndrii Kulian2018-03-291-1/+3
| | | | | | | | | | | With ActivityLifecycler infrastructure duplicate resume situations are limited to double-relaunch scenario and there shouldn't be any incorrect resume requests. This means that there shouldn't be any reasons to finish activity when trying to resume it. Bug: 77240441 Test: android.app.activity.ActivityThreadTest Change-Id: I70a3fcbff72954ff673b2020be3134be367cd823
* Use transaction for local activity relaunchAndrii Kulian2018-03-261-0/+17
| | | | | | | | | | | | | | | | | | | | To know that onPostCreate callback should be executed we should use TransactionExecutor for the entire transaction. It will fill PendingActions object during the launch and the callback will be triggered after onStart. This CL changes local activity relaunch to use Lifecycler infrastructure. We should immediately execute local recreate requests, because if we wait until the scheduled message to be handled, we may already be in a different state and final state request in the scheduled relaunch transaction will already be obsolete. Bug: 72029061 Bug: 64610483 Bug: 76088057 Bug: 73747058 Test: ActivityLifecycleTests Change-Id: Ia53ecd199c83d030932c4493064e58568805f2a5
* Don't throw exception for duplicate stopAndrii Kulian2018-03-191-2/+12
| | | | | | | | | | | | | | | | A double stop request is possible when display is being locked. An activity may receive a "sleep" message followed by "stop", both of which try to move it to stopped state. An example when this happens: a keyguard is set up and the screen is being locked. The keyguard will occlude the activity, which causes a transition to paused state and, eventually, to stopped state. A "sleep" message can be sent sometime before "stop" message and will ignore that activity is in the process of becoming stopped. Change-Id: I09e2c26004664b6e73ac5c2b6fe88bdf8271cf34 Fixes: 74967786 Test: FrameworksCoreTests:ActivityThreadTest
* Don't throw exception for duplicate resumeAndrii Kulian2018-03-121-3/+10
| | | | | | | | | | A double resume request is possible when an activity receives two consequent transactions with relaunch requests and the second is one is omitted. We still get two resume requests for the final state. Fixes: 74074327 Test: FrameworksCoreTests:ActivityThreadTest Change-Id: I8bb8594948a17b7fbf595a49026ff33b54b66049
* Fix extra pause report from clientAndrii Kulian2018-02-271-2/+1
| | | | | | | | Activity pause is now reported from PauseActivityItem. Fixes: 73020245 Test: Pause activity, check logs. Change-Id: Iabfb1b1b51dec259f1928607ef7c321b54a93286
* Improve AM lifecycle event logsAndrii Kulian2018-02-211-2/+3
| | | | | | | | Add missing lifecycle event logs and provide more detailed reasons. Test: Open and switch between apps, observe lifecycle event logs Change-Id: I403c8d84afec9c950ea3a8fc88600cf554e015f4
* Merge "Improve temporary logging around activity destruction."TreeHugger Robot2018-02-091-1/+1
|\
| * Improve temporary logging around activity destruction.Bryce Lee2018-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | This changelist improves logging for capture details around b/71506345. These modifications are intended to be reverted once the root cause has been found. Bug: 71506345 Test: manual Change-Id: I1dd5eba710e81bf78632359d4ee4c047fefa5da6
* | Switch activity relaunch to lifecyclerAndrii Kulian2018-02-081-0/+34
|/ | | | | | | | | | | | | | | | | | | This is needed to be able to relaunch an activity and eventually bring it to stopped state while it is not visible. Before this relaunch request put activity in resumed state in the end. With lifecycler both relaunch and request to move to stopped state can be done in a single transaction to client. Also fixed extra relaunch request to activity which was sent before it was even started. It happened because we were waiting for another activity to pause before actually scheduling the launch, and in activity-paused callback we were ensuring config first. This led to configuration update for not-yet launched activity and relaunch message was sent first. Bug: 64610483 Test: android.app.servertransaction tests Change-Id: Ib89c20cd0fdff209319d4819023c3cdd641a72c7
* Revert "Minor LoadedApk refactoring."Todd Kennedy2018-01-301-1/+1
| | | | | | | | This reverts commit 7541ca4d1aa48e3110187a83a8dccbfa72084148. Change-Id: I2a6aa5038870c32c4145436f0463092c9b82dd23 Bug: 71501570 Test: manual
* Add more logging to Activity Lifecycler.Bryce Lee2018-01-171-0/+8
| | | | | | | | | | | This changelist introduces temporary logging targeting an issue where lifecycle transactions are executing for non-existent client records. Additional details are retained and exposed in this case to help better understand what is happening. Bug: 71506345 Test: manual Change-Id: Ibfdbbd5ef0c465294709383405403aa0d3508ecb
* Minor LoadedApk refactoring.Jeff Hamilton2017-12-141-1/+1
| | | | | | | | - Rename varaibles holding LoadedApk to make the code easier to read. - Move resource creation into LoadedApk, consolidating the logic. Test: manual Change-Id: I6bdc70482fbbb346ff694ada528ded18d3a63ef7
* Add transaction executorAndrii Kulian2017-12-051-18/+28
| | | | | | | | | | | | | | | | | This adds TransactionExecutor class, that takes care of executing a multi-stage ActivityManager client transaction in correct order. First it executes all callbacks, while also making sure to transition to the right pre- and post-execution state if requested. In the end it cycles to the final requested lifecycle state. This also switches activity launch process to use lifecycler - it initializes activity launch and sets final desired state in the same transaction. Bug: 64797980 Test: android.app.servertransaction.TransactionExecutorTests Change-Id: I306f9396fab263682f580cc8c924a3cedb40ef89
* Add basic lifecycle transaction containersAndrii Kulian2017-11-211-0/+114
This adds basic containers for holding some messages to a client, that are related to activity lifecycle. Each transaction can hold a list of callbacks and a final lifecycle state. Some requests from ActivityManager to client that target activities are now switched to use transactions. Scheduling, preparing and executing a request is moved outside of ActivityThread class to corresponding transaction items. Bug: 64797980 Test: Existing AM CTS tests pass Change-Id: I96df20787b3d792f655c9500e8a71032264d02cd