summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
Commit message (Collapse)AuthorAgeFilesLines
* Per-app override sandboxing View API to Activity boundsOleg Blinnikov2023-02-241-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some applications assume that they occupy the whole screen and therefore use the display coordinates in their calculations. This can lead to shifted or out of bounds UI elements in case the activity is Letterboxed or is in split-screen mode. OVERRIDE_SANDBOX_VIEW_BOUNDS_APIS change id forces the packages it is applied to sandbox View API to Activity bounds for: android.view.View#getBoundsOnScreen android.view.View#getLocationOnScreen android.view.View#getWindowVisibleDisplayFrame android.view.View#getWindowDisplayFrame This sandboxing is happening indirectly in android.view.ViewRootImpl through android.view.ViewRootImpl#getWindowVisibleDisplayFrame, android.view.ViewRootImpl#getDisplayFrame respectively. Application developers can opt-out of this treatment by using the following configuration in their manifest: <application> <property android:name= "android.window.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS" android:value="false"/> </application> The difference between this CL and the previous attempt in commit:Ia064d26b46402a04056f498a1ed5c090a6d1b965 is that in the current CL the window bounds are found with windowConfiguration.getBounds(), which is subtracted from displayFrame to make the latter appear as occupying the whole screen without letterbox or multi-window mode. getBounds also takes compatScale and overrideScale into account so no additional scaling is needed. This compat change is taking effect only in non-system processes, this important because all compat changes are enabled for the system process. For example this compat change may impact ANR dialog created within the system process, but it does not require this compat change to be enabled. Test: atest CtsWindowManagerDeviceTestCases:CompatChangeTests Bug: 234799838 Change-Id: If69772bea750380e9f127cea31141a5f953c4e30 Merged-In: If69772bea750380e9f127cea31141a5f953c4e30
* Revert "Per-app override sandboxing View API to Activity bounds"Oleg Blinnikov2023-02-021-10/+3
| | | | | | | | | This reverts commit 1fa3b3821e158574570330f28ee25a4d7fd37f61. Reason for revert: b/267507947 Change-Id: Ie8924e59b04b3044391c6929380a1db212c871b0 Merged-In: I460488c6307cae25abeee6045b712a1af453834a
* Per-app override sandboxing View API to Activity boundsOleg Blinnikov2023-02-011-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some applications assume that they occupy the whole screen and therefore use the display coordinates in their calculations. This can lead to shifted or out of bounds UI elements in case the activity is Letterboxed or is in split-screen mode. OVERRIDE_SANDBOX_VIEW_BOUNDS_APIS change id forces the packages it is applied to sandbox View API to Activity bounds for: android.view.View#getBoundsOnScreen android.view.View#getLocationOnScreen android.view.View#getWindowVisibleDisplayFrame android.view.View#getWindowDisplayFrame This sandboxing is happening indirectly in android.view.ViewRootImpl through android.view.ViewRootImpl#getWindowVisibleDisplayFrame, android.view.ViewRootImpl#getDisplayFrame respectively. Application developers can opt-out of this treatment by using the following configuration in their manifest: <application> <property android:name= "android.window.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS" android:value="false"/> </application> Test: atest CtsWindowManagerDeviceTestCases:CompatChangeTests Bug: 234799838 Change-Id: Ia064d26b46402a04056f498a1ed5c090a6d1b965 Merged-In: Ia064d26b46402a04056f498a1ed5c090a6d1b965
* Introduce a way to debug relayouts and slow measures/layoutNicolo' Mazzucato2023-01-301-5/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This cl introduces a way to debug 2 different but related things: (1) Which classes suffer from long measure and layout pass (2) What caused those classes to be re-measured/re-layout In the current form, only sysui sets the flags to enable the above based on some sysprop. (1) is enabled by `adb shell setprop persist.debug.trace_layouts 1` for all classes in sysui process (note: the process needs to restart). The ideal workflow is to first enable this to spot which are the main classes have long measure/layout slices. Once those are identified (e.g. class X) (2) `adb shell setprop persist.debug.trace_request_layout_class X` enables requestLayout tracing for class X. At this point, every time requestLayout is called on that class, both an instant event (visible in perfetto) and the stacktrace (in logcat) is output. After recording at perfetto trace with (2) enabled, it's possible to aggregate data with an SQL query in ui.perfetto.dev: For example, with the following we can have the most common relayout reasons: ``` SELECT count(*) cnt, msg FROM android_logs WHERE msg LIKE "requestLayout %" GROUP BY msg ORDER BY cnt DESC ``` The following helper bash function makes the above more efficient: trace_class_layouts() { adb shell setprop persist.debug.trace_layouts 1 adb shell setprop persist.debug.trace_request_layout_class $1 adb shell am force-stop com.google.android.apps.nexuslauncher adb shell am force-stop com.android.systemui } Then, use `trace_class_layouts X` and record a perfetto trace. To reduce the overhead, several strings are cached when the view is attached to the window. However, it should be noted that enabling this can have an impact on performance and should only be used for debugging purposes. Test: record a trace after enabling options Bug: 266090955 Merged-In: I89a518d4f3c69c13cdced0f70d8a1e2793bc923a Change-Id: I89a518d4f3c69c13cdced0f70d8a1e2793bc923a
* Enable forced focus for resumed split screen activitiesMariia Sandrikova2022-12-251-0/+16
| | | | | | | | | 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
* Merge "Fix view does not show fill dialog" into tm-qpr-devTYM Tsai2022-09-221-1/+8
|\
| * Fix view does not show fill dialogTYM Tsai2022-09-191-1/+8
| | | | | | | | | | | | | | | | | | Sometimes, views may not be visible for the user immediately after laid out, so add flag for do the evaluation once the view is visible. Bug: 234429643 Test: Manual, check the fill dialog is appeared Change-Id: I6b96b68ffc4a4b1ee5f5056848c5c4996d21ae73
* | Don't reset translation callback with other stateMark Punzalan2022-08-161-1/+0
|/ | | | | | | | | | | | | This fixes issues with Views that have their own custom ViewTranslationCallback. Bug: 236678324 Test: atest CtsTranslationTestCases Test: manual - Verified on chat app that uses their own custom ViewTranslationCallback; old and new messages are translated Test: manual - Spot-checked translation on a few other chat apps Change-Id: If4194bc8cde73a9cebb7b56594f6982855374410
* Don't clear translation state on temporary detachment.Mark Punzalan2022-05-261-1/+3
| | | | | | | | | | | | | | | | | | | | Change I97cc418a8 broke translation on apps which use ListView; messages were re-translated with the animation even while on-screen. A new message arrival triggers a re-layout which causes the temporary detachment, which caused translation to be cleared, and the views get translated again later. The solution is to NOT clear translation in the case of temporary detachment. When Views are actually recycled (e.g., by ListView and RecyclerView), the detachment is permanent/non-temporary. Bug: 232178488 Test: atest UiTranslationManagerTest Test: Manual - Verified scrolling and new messages arriving when translation is enabled. Tested on apps that use ListView and RecyclerView. Change-Id: Ibf1be58219c43252e00b06d4c9e27def5bd36fc2
* Remove preferKeepClearAreaForFocusDelay, turn it into a flagRobert Horvath2022-05-191-31/+6
| | | | | | | | | | | | | TV PiP repositioning in response to keep clear area changes will be debounced in SystemUI, so the client side delay in setting a keep clear area with focus becomes obsolete. Instead the config is turned into a flag for whether focused views should automatically be marked as keep clear areas. Bug: 231309309 Test: atest KeepClearRectsTests Change-Id: I0ac61e671bb75e22a95b400c9bd8d84004379e43 Merged-In: I0ac61e671bb75e22a95b400c9bd8d84004379e43
* Merge "Fix memory leak with RenderNodeAnimator" into tm-devNader Jawad2022-05-111-0/+5
|\
| * Fix memory leak with RenderNodeAnimatorNader Jawad2022-05-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Update View logic to cancel all RenderNodeAnimators when it is detached from a window. Updated HWUI Animation logic to enable a cancellation flag to cancel all animators operating on a RenderNode whenever the staging parameters are pushed to RenderThread Fixes: 229136453 Test: Added core test to RenderNodeAnimatorTests Change-Id: Id674e8474757bfc8dfe30394dde29da49d139bfc
* | Merge "Fix return value in View#getUnrestrictedPreferKeepClearRects" into tm-devGalia Peycheva2022-05-111-1/+1
|\ \
| * | Fix return value in View#getUnrestrictedPreferKeepClearRectsGalia Peycheva2022-05-101-1/+1
| | | | | | | | | | | | | | | | | | Bug: 232052675 Test: m Change-Id: I8e1bb15276f8e3bf19e78f1f8b9fe2b98c4f843e
* | | Merge "Reset translation state when views disappear." into tm-devMark Punzalan2022-05-061-1/+21
|\ \ \
| * | | Reset translation state when views disappear.Mark Punzalan2022-05-051-1/+21
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Views may be re-used (e.g., as in ListView and RecyclerView) so we need to ensure they don't have the translated text when they appear again. RecyclerView seems to recycle translated views even when `hasTransientState() == true` which is the case when views are translated. This should be fixed separately. Bug: 223700458 Test: atest CtsTranslationTestCases Test: atest CtsContentCaptureServiceTestCases Test: atest CtsAutoFillServiceTestCases Test: manual - New messages are translated correctly even if views are re-used. Messages are translated correctly when scrolled onto the screen and stay translated while on-screen. Change-Id: I97cc418a801c006c857e971110ab811ad383343e
* | | Merge "Fix Autofill dialog does not work" into tm-devAhaan Ugale2022-05-051-10/+11
|\ \ \ | |/ / |/| |
| * | Fix Autofill dialog does not workTYM Tsai2022-05-041-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apps have only one chance to get Autofill dialog support, it requires attaching the autofillable view before the Activity has finished laying out. This change moves the doing request to the view being laid out, that is the same timing with what Autofill is doing about the view is auto focused but under different conditions. Bug: 226674898 Test: atest android.autofillservice.cts.dialog.LoginActivityTest Change-Id: I9018b8db8673e3b917a303476666ae766fbe7891 Merged-In: I9018b8db8673e3b917a303476666ae766fbe7891
* | | Merge "Fix re-registering PositionUpdateListener" into tm-devRobert Horvath2022-05-041-0/+1
|\ \ \
| * | | Fix re-registering PositionUpdateListenerRobert Horvath2022-04-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nulls out `info.mPositionUpdateListener` after unregistering the Listener, allowing a new PositionUpdateListener to be registered later. `addPositionUpdateListener` was only called if `info.mPositionUpdateListener` is non-null. The Listener is first created and registered if the system needs to keep track of the View's bounds (eg. if it is marked as a keep clear area). If the system no longer needs to keep track of the View's bounds, the Listener is unregistered, but wasn't set to `null`. When the system later needs to receive updates about the View's bounds again, the listener failed to be re-registered because it was non-null. Bug: 226583836 Test: Manual, check position updates of View Change-Id: Ia494e84843a9954e368d76a000f5f725e3a58df1
* | | | Merge "Add a description to the params of keep clear rects APIs." into tm-devMateusz Cicheński2022-05-031-0/+4
|\ \ \ \
| * | | | Add a description to the params of keep clear rects APIs.Mateusz Cicheński2022-04-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should make it more clear that the rects passed to these methods are in local coordinate system of the view. Bug: 183746978 Test: n/a Change-Id: I1cce8d9707a9a861da802d52c6027768b8af930d
* | | | | Merge "Removed extraneous comment delimiter from the ↵TreeHugger Robot2022-05-021-2/+0
|\ \ \ \ \ | |_|_|_|/ |/| | | | | | | | | getDefaultFocusHighlightEnabled method." into tm-dev
| * | | | Removed extraneous comment delimiter from the ↵joneckenrode2022-04-251-2/+0
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getDefaultFocusHighlightEnabled method. Test: Built API docs Bug: 230035680 Signed-off-by: joneckenrode <joneckenrode@google.com> Change-Id: I25a36c218442a528a4caae08d4ae2d704793a7b7
* | / / Revised API docs of overloaded getGlobalVisibleRect methods and ↵joneckenrode2022-04-261-17/+74
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | getLocalVisibleRect method. Fixed punctuation of "x and y coordinates" in getLocationOnScreen, getLocationInWindow, and getLocationInSurface. Test: Built API docs Bug: 172571756 Signed-off-by: joneckenrode <joneckenrode@google.com> Change-Id: I45f21521350accba4227f6d328e53c52ffcce80a
* | | Merge "Revised API documentation of getLocationOnScreen, ↵Jon Eckenrode2022-04-251-11/+23
|\ \ \ | | | | | | | | | | | | getLocationInWindow, and getLocationInSurface to include multiple-screen behavior and remove mentions of "global" coordinate space." into tm-dev
| * | | Revised API documentation of getLocationOnScreen, getLocationInWindow, and ↵joneckenrode2022-04-251-11/+23
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | getLocationInSurface to include multiple-screen behavior and remove mentions of "global" coordinate space. Test: Built API docs Bug: 172573956 Signed-off-by: joneckenrode <joneckenrode@google.com> Change-Id: If2200f9daebaa7eb106340bcc5707c20a3df34e6
* | | Merge "Advise use of InputDeviceListener when using pointer capture" into tm-devTreeHugger Robot2022-04-251-1/+7
|\ \ \ | |_|/ |/| |
| * | Advise use of InputDeviceListener when using pointer capturePrabir Pradhan2022-04-141-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | InputDevices can be reconfigured when pointer capture changes, but the app will be notified via InputManager when the updated device information is available. This races with the onPointerCaptureChange callback, so advise the use of InputDeviceListener in the pointer capture documentation for developers to get around this. Bug: 226425883 Test: None Change-Id: I7aeb23722dc40b8fd37cb9667a4f23a336e8b5f1
* | | Merge "Auto append password hint for TextView" into tm-devTYM Tsai2022-04-211-0/+11
|\ \ \
| * | | Auto append password hint for TextViewTYM Tsai2022-04-201-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some TextViews are made as password via input type but does not contain autofill password hint. This change auto append a hint for autofill to identify. Bug: 219844915 Test: atest android.autofillservice.cts.dialog.LoginActivityTest Change-Id: Ifd18c56ffe788a601821d178ace41413f9e0454e
* | | | Merge "Use device config to control hints allow list for fill dialog" into ↵TYM Tsai2022-04-211-2/+2
|\| | | | |_|/ |/| | | | | tm-dev
| * | Use device config to control hints allow list for fill dialogTYM Tsai2022-04-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the performance consideration, we don't prefer to trigger a FillRequest for autofill dialog at the Activity starting. We only do that if one of the fields is a password or contains the allowed AutofillHints for fill dialog. Bug: 219844915 Test: set device config, check whether do a fill request at starting Change-Id: I8cc8c99d1f0e716ad293fa612f65aa2a8d23b028
* | | Change node bounds procedure based on SufaceFlinger Callbackryanlwlin2022-04-121-2/+2
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The attachInfo from ViewRootImpl is not reliable for DisplayArea manipulation or windowless window. To fix this problem, we use the transform matrix of InputWindowHandle, which could transform the bounds from window coorindate to screen coordinate. We also transfrom the bounds to logical display coordinates with the associated display matrix. Besides, we also record the magnification spec of the window, which could get the bounds before magnification. We use this value to decide the property 'visibleToUser'. Bug: 200797785 Test: atest android.accessibilityservice.cts WindowInfoTest atest com.android.server.accessibility Change-Id: I0917b04fe8b027fb2bd932a6f0604ba1449ebc66
* | Merge "Scribe: fix handwriting is not initiated in WebView" into tm-devHaoyu Zhang2022-04-061-1/+1
|\ \
| * | Scribe: fix handwriting is not initiated in WebViewHaoyu Zhang2022-03-301-1/+1
| |/ | | | | | | | | | | | | | | | | | | View#getHandwritingArea mistakenly returned a non-null Rect even for view's which never calls setHandwritingArea. As a result, handwriting is not properly initation for views other than EditText. Bug: 227278641 Test: atest android.view.inputmethod.cts.StylusHandwritingTest Change-Id: I45700f2684a2f4138f73eaa843d3019e6c26d2f6
* | Merge "Revised the API documentation of the getLocationOnScreen, ↵Jon Eckenrode2022-04-041-13/+41
|\ \ | | | | | | | | | getLocationInWindow, and getLocationInSurface methods of View." into tm-dev
| * | Revised the API documentation of the getLocationOnScreen, ↵joneckenrode2022-03-311-13/+41
| |/ | | | | | | | | | | | | | | | | getLocationInWindow, and getLocationInSurface methods of View. Bug: b/172573956 Test: Built API docs Signed-off-by: joneckenrode <joneckenrode@google.com> Change-Id: If9c74f7f8b71111f38d020d8e776f4da67e0c62e
* / Add View.findOnBackInvokedDispatcherVadim Caen2022-04-011-0/+18
|/ | | | | | | | | | To make it easier for developer to migrate away from KEYCODE_BACK without having to walk up the view hierachy in order to find an OnBackDispatcher, introduce findOnBackInvokedDispatcher. Bug: 227301455 Test: android.view.cts.OnBackInvokedDispatcherTest#testGetDispatcherOnView Change-Id: I7f3e76df596d306fa26d72df8115d5b15d7ac564
* Prevent ArrayList allocation for prefer keep clear areasRobert Horvath2022-03-241-3/+12
| | | | | | | | | This avoids creating an ArrayList if there are no keep clear areas, returning early with an empty or singleton list where possible. Bug: 222567277 Test: android.view.ViewShowHidePerfTest#testVisibleToInvisible Change-Id: Id718a37ea8aa4fcf4edbaade532cea826b15adf0
* Fixes for a11y selectionSally2022-03-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | - TextView should request focus before performing selection on non-editable text, since selection requires focus. On the a11y service side, input focus should not matter when selecting non-editable text. - Remove clickable and long-clickable states, since these are present due to TextView#setTextIsSelectable. - Make UI controller changes consistent between SET_SiELECTION and SET_TEXT. Using SET_SELECTION means the action mode menu won't pop up and the left/right selection handles won't appear. Interactions between multiple EditTexts were previously inconsistent - Delete some obsolete javadoc Bug: 218357385 Test: builds and install: highlighting is consistent between SET actions. highlighting works when selecting text in TalkBack, without the service needing to purposely put input focus, atest AccessibilityTextTraverssalText Change-Id: I67986020aa112d45bd670f77b2b415617226c094
* Merge "Prevent NPE for onKeyDown and onKeyUp" into tm-devArthur Hung2022-03-151-2/+2
|\
| * Prevent NPE for onKeyDown and onKeyUpArthur Hung2022-03-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We expected `onKeyDown` and `onKeyUp` should be used for the key event delivery from input, but some apps may misuse it and pass a null key event, that would cause app itself crash if it didn't override onKeyDown and onKeyUp properly. To prevent this, we swap the conditions that first check the confirm key code then access the other states of the key event. Bug: 219708835 Test: manual Change-Id: I612ca560d768134bdcaa688c83217738b5254b5a
* | Fix: Handwriting only initiate for the first timeHaoyu Zhang2022-03-141-2/+1
|/ | | | | | | | | | | | Handwriting initiator accidentally changes the View's handwriting area. As a result, it stops working after startHandwriting is called for the View once. This CL fixed the issue by not exposing the internal handwriting area Rect object in the View. Bug: 222117485 Test: manually tested Change-Id: I5cb6231361fbd7566edddb1aebf7b99330c3a8d8 (cherry picked from commit b1ba2dae29761f9b81e2bd652ade3dc92036e718)
* Mark focused Views as keep clear areasRobert Horvath2022-03-021-11/+46
| | | | | | | | | Mark/unmark Views as keep clear areas as they gain/lose focus with a small delay. Test: atest KeepClearRectsTests Bug: 218494300 Change-Id: I33c89b5d2ed6707f95eca8ec4b5604c9193aec05
* Keep custom keep-clear Rects if preferKeepClear is setRobert Horvath2022-03-021-5/+6
| | | | | | | | | | | Since ViewParents can be set to not clip their children, custom keep clear areas can extend beyond the bounds of its hosting View. If preferKeepClear is set, add the View's bounds as a keep clear area, but also keep the custom Rects. Bug: 221073574 Test: atest KeepClearRectsTests Change-Id: I85a4e4a223fbba787c5afebf2689a031243808d4
* Merge "Add SystemApi to set unrestricted keep-clear rects" into tm-devGalia Peycheva2022-03-021-0/+64
|\
| * Add SystemApi to set unrestricted keep-clear rectsGalia Peycheva2022-02-281-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | This CL allows applications to choose whether to set restricted or unrestricted keep-clear areas by adding a dedicated SystemApi for unrestricted keep-clear areas - View#setUnrestrictedKeepClearRects. The SET_UNRESTRICTED_PREFER_KEEP_CLEAR_AREAS permission is now only checked for keep-clear areas from that API Bug: 221094507 Test: atest CtsWindowManagerDeviceTestCases:KeepClearRectsTests Test: atest WindowStateTests#testUnrestrictedKeepClearAreas Change-Id: I89ca3149117b4d457c5521d617880870706d7793
* | Make pane logic consistent with documentationSally2022-02-181-4/+23
| | | | | | | | | | | | | | | | | | APPEARED and DISAPPEARED events should be sent when a title is first given and nulled respectively, following the Javadoc. Test: Manual, atest AccessibilityPaneTest Bug: 133131221 Change-Id: I41cd2548aa949c7ce320e228c2b07ef04ea0298b
* | Use isAggregatedVisible for pane eventsSally2022-02-181-1/+1
| | | | | | | | | | | | | | | | | | When the pane title changes, the view may not be actually visible on screen. Check parent visibility before sending a pane event. Bug: 133131221 Test: manual check to ensure we don't receive title event, atest AccessibilityPaneTest Change-Id: I8bad8f742cc3e8f4d906c2b6fe80a3516c900ef1