Commit Graph

6846 Commits

Author SHA1 Message Date
Josh Gao
ca46512d0a FileBridge: fix fd ownership mismanagement.
This patch switches everything over to ParcelFileDescriptor, but the
important part of the change is changing FileBridge.getClientSocket to
return a ParcelFileDescriptor. Previously, it returned a raw
FileDescriptor that was closed by FileBridge, and the only non-test
caller of that function was taking it and constructing a
ParcelFileDescriptor from it, which would also attempt to close the fd,
leading to an fdsan abort.

Bug: http://b/162811367
Test: atest FileBridgeTest
Test: treehugger
Change-Id: I724ea7601bb072c98895f68abc08bb0e339d1db0
(cherry picked from commit 4c392e8057)
2020-11-06 13:12:51 -08:00
Charles Chen
2fb8485fbb [RESTRICT AUTOMERGE] Revert "[RESTRICT AUTOMERGE] Revert "Require permission to create trusted displays"" am: c947b10f99 am: 1e0cf0c900
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12816011

Change-Id: I40987bec1e53324e4036ffe4325c6dc8328c29da
2020-10-16 18:56:16 +00:00
Charles Chen
1e0cf0c900 [RESTRICT AUTOMERGE] Revert "[RESTRICT AUTOMERGE] Revert "Require permission to create trusted displays"" am: c947b10f99
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12816011

Change-Id: I174d70795eae849ca346fb79528e418a5003f76a
2020-10-16 18:39:01 +00:00
Charles Chen
c947b10f99 [RESTRICT AUTOMERGE] Revert "[RESTRICT AUTOMERGE] Revert "Require permission to create trusted displays""
This reverts commit ae03031efe.

Reason for revert: Merge the reverted patch by accident.

Bug: 162627132
Change-Id: Ic2f072730050cb47926cec6ed24af7ef9e5e7055
2020-10-13 01:14:25 +00:00
Charles Chen
f0daa2119f [RESTRICT AUTOMERGE] Revert "Require permission to create trusted displays" am: ae03031efe am: 6c079ef0b5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12716107

Change-Id: I306a382fa9ae3b9abc096c343316365c6a6ce8dd
2020-09-29 06:36:04 +00:00
Charles Chen
6c079ef0b5 [RESTRICT AUTOMERGE] Revert "Require permission to create trusted displays" am: ae03031efe
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12716107

Change-Id: If1a42b8cd7cab0c97f45fc3f452dbe4bc054cf41
2020-09-29 06:17:52 +00:00
Charles Chen
ae03031efe [RESTRICT AUTOMERGE] Revert "Require permission to create trusted displays"
This reverts commit f21c885ca7.

Reason for revert: Have regression b/168268396.
Needs to pull out from Nov. builds.

Bug: 162627132

Change-Id: I29fa3937d1655a0cc7591abcfa2067f4fb2b2bcb
2020-09-29 03:21:52 +00:00
Riddle Hsu
6bb2b9c716 Make process level rotated config and display metrics consistent
The application may get Resources instance from Resources.getSystem()
and context.getApplicationContext().getResources(). Since fixed
rotation is introduced that allows an activity to start in a different
rotation than the current display, when using getConfiguration() and
getDisplayMetrics() of these Resources instances, the orientation
and metrics need to be the same as current display is rotated.
Otherwise the app may show unexpected UI layout.

Although it is not recommended to use global resources/config for
activity. One of the goal of fixed rotation transform is to simulate
the app is started in a rotated environment, so this CL makes the
configuration and display metrics of system resources are consistent
with application and activity for compatibility.

About WindowProcessController and ActivityStackSupervisor:
 The process configuration passed to LaunchActivityItem may be
 associated from activity. if the sequence number of configuration
 is overridden by activity, the configuration may be ignored when
 launching the activity because the sequence number isn't larger
 than the previous process configuration. Although there will be a
 ConfigurationChangeItem later to update correct state, the app may
 get the intermediate state with old configuration and metrics.

About ResourcesManager and DisplayAdjustments:
 There are 2 new fields appWidth and appHeight added to
 DisplayAdjustments#FixedRotationAdjustments because the display
 metrics from Resources.getSystem() is independent from activity
 configuration. Only window manager knows the rotated size, so
 the values need to send to client and then ResourcesManager takes
 the adjustment to change the global display metrics.

About WindowToken:
 When fixed rotation is applied on the token, send the
 FixedRotationAdjustmentsItem first so the later configuration
 change can pick the adjustment at ActivityThread. And because the
 registration of activity configuration only occurs on add/remove
 activity, if it is only switching to another existing activity in
 different orientation, the process configuration still needs to
 be updated.

About ActivityThread:
 The code flow for a rotated activity (DA = display adjustments):
 - Launch new activity
    handleLaunchActivity: override app DA
     handleConfigurationChanged: adjust global display metrics by DA
     performLaunchActivity
      createBaseContextForActivity: override activity DA
 - Resume existing activity
    handleFixedRotationAdjustments: override app and activity DA
    handleConfigurationChanged: adjust global display metrics by DA
    handleResumeActivity

Also some minor corrections:
- Fix wrong display metrics adjustment that xdpi and ydpi should
  not be swapped because they are physical attributes.

Bug: 167564038
Test: atest DisplayAdjustmentsTests
      AppConfigurationTests#testRotatedInfoWithFixedRotationTransform
      WindowProcessControllerTests#testProcessLevelConfiguration
      DisplayContentTests#testApplyTopFixedRotationTransform

Change-Id: I60bedc7e09f54683d5e857ccc51402d5d144cd9e
Merged-In: I60bedc7e09f54683d5e857ccc51402d5d144cd9e
2020-09-24 15:09:51 +08:00
Heemin Seog
ae42535e1a DO NOT MERGE Ensure mapping between internal and public insets
Bug: 166149440
Test: manual (flash automotive device with all system bars and show/hide
insets using WindowInsetsController), atest InsetsStateTest
InsetsStateControllerTest

Change-Id: I500b2fb0129739c6fc609561377d90cca6e45f7e
2020-09-18 09:48:08 -07:00
TreeHugger Robot
452d7391a7 Merge "Require permission to create trusted displays" into rvc-dev am: 2c0137794d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12287404

Change-Id: Ibbf44a9eafc66e8591156e10ac1049cbe4f2a760
2020-09-04 10:40:09 +00:00
TreeHugger Robot
c2b395c713 Merge "Require permission to create trusted displays" into rvc-qpr-dev 2020-09-04 10:04:13 +00:00
Tiger Huang
677078e872 Make display frame compatible
The display frame is used to limit the windows boundary. The frame is
the same as the parent frame in most cases if the window is not
attched. However, if a window doesn't have any layout related
window/sysui flags and the soft input mode is not ADJUST_RESIZE, the
display frame doesn't need to be inset by IME (but the parent frame
does).

Fix: 163435784
Test: atest ViewRootImplTest DisplayPolicyLayoutTests
Merged-In: Ia61933120027642d1f0e0a490546071ca2b6c853
Change-Id: Ia61933120027642d1f0e0a490546071ca2b6c853
2020-09-02 11:38:21 +00:00
Andrii Kulian
ef7b1333f0 Require permission to create trusted displays
Bug: 162627132
Test: atest VirtualDisplayTest#testTrustedVirtualDisplay
Test: atest
frameworks/base/packages/SystemUI/tests/src/com/android/systemui/bubbles
Test: atest DisplayTest
Test: atest VirtualDisplayTest#testTrustedVirtualDisplay
Test: atest VirtualDisplayTest#testUntrustedSysDecorVirtualDisplay
Test: adb logcat -b events

Change-Id: Id06b2013ef5fdeadf321f14f8b611c733031d54d
Merged-In: Id06b2013ef5fdeadf321f14f8b611c733031d54d
2020-09-01 05:24:41 +00:00
Andrii Kulian
f21c885ca7 Require permission to create trusted displays
Bug: 162627132
Test: atest VirtualDisplayTest#testTrustedVirtualDisplay
Test: atest
frameworks/base/packages/SystemUI/tests/src/com/android/systemui/bubbles
Test: atest DisplayTest
Test: atest VirtualDisplayTest#testTrustedVirtualDisplay
Test: atest VirtualDisplayTest#testUntrustedSysDecorVirtualDisplay
Test: adb logcat -b events

Change-Id: Id06b2013ef5fdeadf321f14f8b611c733031d54d
Merged-In: Id06b2013ef5fdeadf321f14f8b611c733031d54d
2020-09-01 13:22:29 +08:00
Charles Chen
b2444cbef5 [RESTRICT AUTOMERGE] Make a context dervied from an UI context as an UI context
fixes: 165833103
Test: atest StrictModeTest ContextAccessTest
Test: atest InputMethodServiceTest InputMethodServiceStrictModeTest

Merged-In: Ia97e1a0cc290be516d2618148600238b3273c54c
Change-Id: Ia97e1a0cc290be516d2618148600238b3273c54c
2020-08-26 11:47:08 +08:00
Tiger Huang
23c75281ef Update requested state after applying pending frames
When there is an insets animation, we will stop updating insets source
frames until the animation is done. The previous logic didn't update the
frames within the requested state while the animation is done. And the
frames was relied by InsetsPolicy while playing transient bar animation.
If the frames don't match the display, the insets would be wrong, and
the animation wouldn't be played correctly.

Fix: 161134197
Test: atest InsetsControllerTest
Merged-In: Id8f3c1956fbfe3ad16f167ff76297dde6c634e81
Change-Id: Id8f3c1956fbfe3ad16f167ff76297dde6c634e81
2020-08-19 20:42:39 +08:00
Tiger Huang
f8175d1a5b Dispatch insets to client if mState is changed
Previous logic in onStateChanged notifies insetsChanged based on the
change of mLastDispatchedState, which can make us dispatch redundant
insets changes to the app.

In this CL, we only notifies insetsChanged if mState is really changed
in onStateChanged -- we use the final mState (after updateState and
applyLocalVisibilityOverride) to compare with the one before changing.

Fix: 161924448
Test: atest InsetsControllerTest WindowInsetsControllerTests
Test: Swipe up to home while IME open and see if there is any jank
Merged-In: Ia536cdf76805caa56ca1b6eaf2b3db83b6ecd94e
Change-Id: Ia536cdf76805caa56ca1b6eaf2b3db83b6ecd94e
2020-08-19 15:32:53 +08:00
Tiger Huang
1a53789bc8 Update requested state after applying pending frames
When there is an insets animation, we will stop updating insets source
frames until the animation is done. The previous logic didn't update the
frames within the requested state while the animation is done. And the
frames was relied by InsetsPolicy while playing transient bar animation.
If the frames don't match the display, the insets would be wrong, and
the animation wouldn't be played correctly.

Fix: 161134197
Test: atest InsetsControllerTest
Change-Id: Id8f3c1956fbfe3ad16f167ff76297dde6c634e81
2020-08-13 14:58:06 +00:00
Nikita Dubrovsky
7094198a26 Merge "Add DeviceConfig flag for drag direction angle threshold for cursor drag" into rvc-qpr-dev 2020-08-11 01:53:10 +00:00
Tiger Huang
b6478edb09 Dispatch insets to client if mState is changed
Previous logic in onStateChanged notifies insetsChanged based on the
change of mLastDispatchedState, which can make us dispatch redundant
insets changes to the app.

In this CL, we only notifies insetsChanged if mState is really changed
in onStateChanged -- we use the final mState (after updateState and
applyLocalVisibilityOverride) to compare with the one before changing.

Fix: 161924448
Test: atest InsetsControllerTest WindowInsetsControllerTests
Test: Swipe up to home while IME open and see if there is any jank
Change-Id: Ia536cdf76805caa56ca1b6eaf2b3db83b6ecd94e
2020-08-06 17:26:57 +08:00
Nikita Dubrovsky
81fa5e436a Add DeviceConfig flag for drag direction angle threshold for cursor drag
Bug: 160786691
Test: Manual and unit tests
  atest FrameworksCoreTests:EditorTouchStateTest
  atest FrameworksCoreTests:EditorCursorDragTest
Change-Id: Ib2e88fbdce4f901772d73bc7ee60483c98e02509
Merged-In: Ib2e88fbdce4f901772d73bc7ee60483c98e02509
(cherry picked from commit 8bac79d651)
2020-08-05 20:15:49 +00:00
Wale Ogunwale
f4fb8c1457 Merge "Prevent exception when surrounding text retrieval" into rvc-dev am: 309cfa3431
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12167896

Change-Id: Idda9ab4bb5dddc617eb61e4b3355567627ca6fd3
2020-07-21 01:24:31 +00:00
Wale Ogunwale
309cfa3431 Merge "Prevent exception when surrounding text retrieval" into rvc-dev 2020-07-21 01:03:03 +00:00
Wilson Wu
0ebe70cb0f Prevent exception when surrounding text retrieval
We use same reference from TextView to set the initial
surrounding text. The actual surrounding text may be
modified before retrieval since the mSurroundingText
is mutable. Use a copy of subText should avoid this
concurrent issue.

Bug: 160390184
Test: atest FrameworksCoreTests:EditorInfoTest
Change-Id: I6082a4cae2fcdc4c529dc14e2e5e7a45ab1aae4d
2020-07-18 00:51:47 +08:00
Wale Ogunwale
1813474cc9 Merge "Remove Type.statusBars from compatInsetsTypes if FLAG_FULLSCREEN" into rvc-dev am: 0b237bb06f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12157384

Change-Id: Ie7bbdf01416680dac708e47347d86718aa22336c
2020-07-15 14:03:34 +00:00
Tiger Huang
0f310bdec8 Remove Type.statusBars from compatInsetsTypes if FLAG_FULLSCREEN
In the legacy layout world, if a window has FLAG_FULLSCREEN, then its
stable insets won't be affected by status bar. This CL makes the layout
logic compatible.

Fix: 160593171
Test: InsetsStateTest InsetsControllerTest ImeInsetsSourceConsumerTest
Change-Id: I59717e699470273e2462c1ad864e00bb9a126677
2020-07-15 19:00:19 +08:00
Nikita Dubrovsky
59eed075de Merge "Remove flaky test for cursor drag from presubmit" into rvc-dev am: e50d6658b6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12099133

Change-Id: I3a86a03b24ea84c2383af45b61d4e098f1f8b8ed
2020-07-11 23:19:30 +00:00
Nikita Dubrovsky
e50d6658b6 Merge "Remove flaky test for cursor drag from presubmit" into rvc-dev 2020-07-11 23:08:10 +00:00
Tiger Huang
8e4707ae80 Merge "Update requested state by comparing with source consumer" into rvc-dev am: 894a797421
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12108428

Change-Id: I3de26ac30237f76cd71e0e8639cc4025b754f6ef
2020-07-10 14:03:48 +00:00
Tiger Huang
894a797421 Merge "Update requested state by comparing with source consumer" into rvc-dev 2020-07-10 13:51:37 +00:00
Tiger Huang
ff06666dba Update requested state by comparing with source consumer
If the local state and mLastDispatchedState are the same, the logic in
onStateChanged will skip updating the requested state. This could be an
issue, for example, a new focused window requested to hide status bar,
but status bar has already been hidden by the previous focused window,
so the new focused window will never send the requested state to server.
This can easily happen when an immersive activity is re-created due to
the configuration change.

This CL updates the requested state if any visibility within it is not
the same as the requested visibility of the source consumer, while
receiving controls.

Fix: 160854328
Test: atest InsetsControllerTest
Test: Swipe to show transient bars after rotating an immersive activity
Change-Id: I5d9acb1b59252fa80e66070db86b2555764588da
2020-07-10 18:04:57 +08:00
Adrian Roos
2f07569650 Merge "Fix IME flicker: move hiding the surface into the control target" into rvc-dev am: 895a2e626a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12070682

Change-Id: Ib984a4bc34f0527c809de35919340019a04b017a
2020-07-09 17:12:41 +00:00
Adrian Roos
895a2e626a Merge "Fix IME flicker: move hiding the surface into the control target" into rvc-dev 2020-07-09 17:02:15 +00:00
Adrian Roos
2260ce4daf Fix IME flicker: move hiding the surface into the control target
Fixes a flicker that occurs during transitions between windows.

This happens for two reasons:

1.) Control is immediately transferred to the new window, and the
    previous window didn't get a chance to play the animation.

    This is addressed by adding logic to keep control on the
    exiting window for the duration of the transition - similar to
    what we do with the target for z-ordering purposes.

2.) Upon the input connection being severed, the InputMethodService
    immediately hides its window, preventing any animations whenever
    the input connection changes

    This is addressed by moving hiding of the surface into the
    controlling windows - where upon receiving control, we now
    trigger removal of the IME surface if we don't show it.

Additionally:

- Now ensures that any requests from the ImeInsetsSourceConsumer
  ensure that they come from the window that is currently served
  by IMM.

- Removes the transparancy clause from isImeTargetFromDisplayContentAndImeSame
  to match the updated IME target computation in DisplayContent in [1].

[1]: Iedd5f7407926167f4891ce9b7e9a79e22751e668

Fixes: 153145997
Fixes: 150902448
Test: atest WindowInsetsAnimationControllerTests
Test: atest DisplayContentTests InsetsSourceConsumerTest
Test: Open app with IME, press HOME button, verify IME smoothly animates away
Test: Open Messages, open a thread, open IME. Click search icon, verify IME opens in the search activity
Change-Id: I4910c2a06cc67b0470477b245fc1de54b75f10f9
2020-07-09 14:46:55 +02:00
Charles Chen
a91c84fa14 Merge "Fix NPE when invoking Context#isUiContext" into rvc-dev am: 5c25605da0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12105622

Change-Id: If6d05cfdc4c4c2ee92cca0497f5e07ec8280332d
2020-07-08 17:59:59 +00:00
Charles Chen
5c25605da0 Merge "Fix NPE when invoking Context#isUiContext" into rvc-dev 2020-07-08 17:46:09 +00:00
Nikita Dubrovsky
3df7b0ebab Merge "Change cursor drag threshold from 30 to 45 degrees from vertical" into rvc-dev am: f44a60bd69
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12052997

Change-Id: I76b9d12597161e729ee5dba6a51fff5302158c5e
2020-07-08 16:46:20 +00:00
Charles Chen
3b8e8d7631 Fix NPE when invoking Context#isUiContext
Add null checks in both ContextWrapper and before obtaining
ContextImpl#getOuterContext.

Test: atest ContextTest#testIsUiContext_ContextWrapper
fixes: 160037462
Change-Id: Ic6a71dd9ac4b195d219d6e5431f2f2b199a400fa
2020-07-08 23:58:58 +08:00
Nikita Dubrovsky
2654b6e238 Remove flaky test for cursor drag from presubmit
These tests run fine in isolation (verified both on a physical Pixel 3
and on a Cuttlefish emulator via acloud), but are flaky in presubmits.

Bug: 159764993
Test: Presubmit
Change-Id: Ia27e05543e2647c42e06a684a3ae5c11c074a5fb
Merged-In: Ia27e05543e2647c42e06a684a3ae5c11c074a5fb
(cherry picked from commit 9d296cdd98)
2020-07-07 18:42:42 +00:00
Nikita Dubrovsky
b1ad3b6800 Change cursor drag threshold from 30 to 45 degrees from vertical
Bug: 158948887
Test: Manual and unit tests
  atest FrameworksCoreTests:EditorTouchStateTest
  atest FrameworksCoreTests:EditorCursorDragTest
Change-Id: I6b30c0d6ef9c93fd4fd6aae3004cd6965e9d7be4
2020-07-01 13:14:19 -07:00
Antoan Angelov
2e53c54ab9 Merge "Also skip calling ShortcutManager APIs if work user is locked" into rvc-dev am: 625ada924d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12034926

Change-Id: Icd5e64ff7e9495862edaa1c9548bbff7320d7831
2020-06-29 16:47:11 +00:00
Antoan Angelov
625ada924d Merge "Also skip calling ShortcutManager APIs if work user is locked" into rvc-dev 2020-06-29 16:32:25 +00:00
arangelov
0769484c9a Also skip calling ShortcutManager APIs if work user is locked
Fixes: 159696895
Test: manual
Test: atest ChooserActivityTest
Change-Id: I3e90d5a56551b9952bfcd761c3a19a309d7cbc72
2020-06-29 14:27:29 +00:00
Jorim Jaggi
3f8fc80e42 Merge "Pass in callsite of SurfaceControl constructor explicitly (1/3)" into rvc-dev am: 37cf2279c9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11920862

Change-Id: I25309fc3f8ad0429134d437a26a1d60572ed3e53
2020-06-27 00:14:19 +00:00
Jorim Jaggi
37cf2279c9 Merge "Pass in callsite of SurfaceControl constructor explicitly (1/3)" into rvc-dev 2020-06-26 23:58:17 +00:00
Antoan Angelov
c42ae08374 Merge "Don't call ShortcutManager APIs if the work profile is paused or locked" into rvc-dev am: 054a8e32c1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12000922

Change-Id: I3ce4706ced411401886e457b85652fb73db5bf70
2020-06-26 18:51:47 +00:00
Antoan Angelov
054a8e32c1 Merge "Don't call ShortcutManager APIs if the work profile is paused or locked" into rvc-dev 2020-06-26 18:37:02 +00:00
Jorim Jaggi
d42ab1b938 Pass in callsite of SurfaceControl constructor explicitly (1/3)
Creating a new Throwable (and filling in the stack trace) can take
up to 150us. Since we do this on the critical path when sending
over SurfaceControl via binder multiple times, this is too much.
Instead, add an option to pass in callsite manually.

Bug: 159056748
Change-Id: I46c339c15a07192d61c4c546e46f260684a47120
Merged-In: I46c339c15a07192d61c4c546e46f260684a47120
Exempt-From-Owner-Approval: Large scale refactor
2020-06-26 15:35:23 +02:00
Rhed Jao
566972dcee Tests no screenshot is copied when user consent timed out am: 9516a007c5 am: 04827943d7 am: 38e36756f8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11940429

Change-Id: Ib640bbd061b62b289d2bf4f66b09acfe063c8865
2020-06-25 21:36:44 +00:00
TreeHugger Robot
83eae8840c Merge "Fix issue in InsetsState.set" into rvc-dev am: 2a60031116
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11987763

Change-Id: Iab65d955f9fa3859e70b33532636c88345588ea1
2020-06-25 21:33:35 +00:00