Commit Graph

14589 Commits

Author SHA1 Message Date
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
TreeHugger Robot
6c440de7a4 Merge "Consolidate start new input scenerios" into rvc-dev 2020-07-10 18:42:06 +00:00
Chavi Weingarten
ab3d80c98d Merge "Reparent bounds layer if surface was replaced." into rvc-dev 2020-07-10 16:49:33 +00:00
Ming-Shin Lu
d43b75cf0e Consolidate start new input scenerios
As CL[1] we introduced WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR start
input reason to ignore start new input when the focused view is
same as current served view and the input connection remains the same for
prevent additonal onStartInput / onFinishInput callback to
InputMethodService.

The main idea in the CL is good but how to judge whether the input connection
remains the same is not accurate.

CL[1] only checking if IMM#mServedInputConnectionWrapper self and its
input connection instance is stil exists, that breaks the following cases
to start new input:

Case 1:
- When device screen off / on to go back to focused app, this case will
  fit WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR use case, so
  IMM#mServedInputConnectionWrapper won't be deactivate and clear, this
  makes wrong when user taps IME picker dialog to switch IME, will hit
  again WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR and never start new
  input for new IME.
  Actually, in InputMethodManager has an ad-hoc check mRestartOnNextWindowFocus
  to start new input when device screen off / on case and switching IME,
  we should not ignore start input since that will conflict with the above
  case.

Case 2:
- As served view is now tracked by ImeFocusController which is per-window
  based instance from the IME focus handling refectoring CL[2],
  but InputMethodManager instance is still per-display based, so
  IMM#mCurrentTextBoxAttribute might be changed when the same app clinet has
  multiple IME focusable window focus changed, because focusing to the next
  IME focusable window will start new input connection and changes
  IMM#mCurrentTextBoxAttribute, so when focusing back to the
  original window, the served view in the original window's
  ImeFocusController will same as focused view, in that case if we didn't
  check if IMM#mCurrentTextBoxAttribute is really aligned with the given
  focused view, will mis-judge start new input timing and caused user can't
  type because the input connection state is obsoleted.

Those cases can be addessed by using new introduced method
IMM#isSameEditorAndAcceptingText, if the focused view is not aligned
with same editor or the editor is inactive, we should start new input
for Case 2, that also can fix Case 1 that we previously ignored starting
new input when switching IME.

Beside, we also found CL[3] leverages
InputMethodManager#mRestartOnNextWindowFocus to start new input when window focus
changed, since originally this ad-hoc check is only used to re-start input
for Case 1.
As we re-visited the necessary start new input scenerio is only when:
   - Device screen off -> on
   - Switching IME
   - the input connection obsoleted
     (this also includes when window focus changed)

As the result, we can remove all unnecessary logics in IMMS
instroduced by CL[1] and remove unnecessary
InputMethodManager#mRestartOnNextWindowFocus from CL[3], and preserve
the behavior is almost same as Q.

[1]: I2da99ae67b9ce4051dec0c0f0e975ebe6e1ab118
[2]: Ib455704fe1e9d243f93190a84f230210dbceac2a
[3]: I8d4fff94ba9313b773bc27fcbd019cc88580d3e9

Fix: 160391516
Bug: 158624922
Bug: 152373385

Test: atest FocusHandlingTest
Test: atest InputMethodServiceLifecycleTest
Test: manual for case 1
     0) pre-install 3rd party IME app
     1) launch message app and taps Search bar to focus.
     2) turn off screen
     3) turn on screen to back to focused app
     4) press IME switch icon from nav bar
     5) choose next IME, expect the IME should be changed.
Test: manual for case 2
    0) Sample app with 2 activites, each activity the layout has
       EditText
    1) Launch activity A, focus EditText
    2) Launch activity B and focus EditText
    3) Press back key to back to activity A
    4) Verify if typing with keyboard is workable.

Change-Id: I1ef3d341af9d473d94d52fd1890deafbae2bc9e1
2020-07-11 00:42:17 +08: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
chaviw
c1dcac9568 Reparent bounds layer if surface was replaced.
In a normal case, the app will get either a visibility changed to
false or stopped from system server to indicate that the content
should be cleaned up. In those cases, it will request a relayout
to WM, which will notify VRI that the surface is gone. Since the
VRI surface is removed, the SV and bounds layer will get notified
that they should be destroyed. On the next relayout, the VRI will
get a new surface and notify SV and the bounds layer to create
new surfaces.

The scenario in the bug happens when VRI receives a visibility change to
false, but doesn't process the information fast enough. By the time it
calls relayout, WMS is in the state where the client is visible again. This
time the relayout will return a valid surface so the SV and bounds layer
will not get cleaned up. The reason this causes issues is VRI now has a
new main surface. The bounds layer is parented to the old layer that's been
deleted so it's not parented to anything. The SurfaceView is a child of
the bounds layer so it also renders offscreen.

The reparent needs to be done on the client side since WMS won't
reparent the children to the new surface if it thinks the app is
closing. WMS gets the signal that the app is stopping, but on the client
side, it doesn't get stopped since it's restarted quick enough. WMS
doesn't want to keep around old children since they will leak when the
client creates new children.

This change will reparent the bounds layer to the new VRI surface. It's
possible WMS will take care of this in certain cases where the app
isn't stopped. But for those cases, the reparent will not have
any effect since the bounds layer will be correctly parented.

Fixes: 159545768
Test: Can no longer repro black SV in maps
Test: Test app with SV and delay in onPause no longer has the same issue
Change-Id: I616652e1cc4380ebbcb386586d8d5889fcc19497
2020-07-10 00:32:46 +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
TreeHugger Robot
276abcb6b3 Merge "ViewRootImpl: Call surface destroy callback after layout pass" into rvc-dev 2020-07-09 16:32:33 +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
Vishnu Nair
019e08fdbb ViewRootImpl: Call surface destroy callback after layout pass
If a requestLayout happens on a child view after the measure
pass, before the layout pass then the child view will not layout.
This can happen if a view calls requestLayout during measure
or during SurfaceView surface destroyed callback.

This fix addresses the second scenario by moving the callback
to after the layout pass.

Bug: 159183008
Test: Repro steps in bug
Test: go/wm-smoke
Change-Id: Ie2794a3751c99cabf6e07445c91159e35eeb1729
2020-07-08 12:44:47 -07:00
TreeHugger Robot
0ef33bcb35 Merge "Revert new logic around FLAG_ALT_FOCUSABLE_IM" into rvc-dev 2020-07-02 13:28:33 +00:00
Adrian Roos
69947c0671 Revert new logic around FLAG_ALT_FOCUSABLE_IM
This broke several apps because it means certain NON_FOCUSABLE windows
are now layered wrong w.r.t the IME, and also no longer get IME insets.

Originally, this was introduced because the IME target was used to
compute which window gets control, but this is now computed based on
the window actually connecting to the IME as reported per IMMS.

Reverts I941571c97145d77b0a59d030cf2a8c8318f3b59f.

Bug: 143898978
Bug: 140641950
Bug: 145812508
Bug: 141738570
Bug: 144619551
Fixes: 159438771
Test: atest WindowStateTests
      atest FocusHandlingTest
      atest WindowManager_LayoutParamsTest
      Also manually using steps:
      1. Launch gmail compose activity
      2. start typing in receipient field
      3. verify that even thoug the suggestions popup
         window w/ FLAG_NOT_FOCUSABLE becomes the
         IME target, control and insets still work.
Change-Id: If451276b1a8c485ec88965d8d30ec8fd3836620f
2020-07-02 11:14:10 +02:00
Charles Chen
8deb612a14 Merge "Revert "Revert "Enable IMS and its config context to obtain UI component""" into rvc-dev 2020-07-01 23:21:51 +00:00
Rob Carr
9464091e72 Merge "SurfaceView: Clean up deferred-destroy-surface from UI thread" into rvc-dev 2020-06-29 21:42:03 +00:00
Charles Chen
ba4ffa4a6d Revert "Revert "Enable IMS and its config context to obtain UI component""
Test: atest StrictModeTest
Bug: 157027563
Bug: 159795597
Change-Id: I2a1b3fefa0bd82eeaa507c08fc4a79fc9f4391c5
2020-06-29 14:27:08 +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
Robert Carr
9a808a2ee2 SurfaceView: Clean up deferred-destroy-surface from UI thread
We utilize mTmpTransaction without locking from the main thread. The
callback info inside the transaction stores an sp to the SurfaceControl.
If we apply the Transaction from two threads independently we may
implicitly call reset() on the same sp instance twice in an overlapping
fashion. While the reference count is itself atomic, that wont stop us
from decrementing it twice here, when we only had one reference.
This leads to an early free and a crash later.

Bug: 159333209
Test: Existing tests pass
Change-Id: I898bef0b6b8c1cf34891410bbadf63fe2f840697
2020-06-26 18:47:28 +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
TreeHugger Robot
b5d9c88ddd Merge changes I74d8f555,I7521a5a1 into rvc-dev
* changes:
  Prevent ANR if window is stopped
  Isolate batched input scheduling logic.
2020-06-26 10:40:27 +00:00
Siarhei Vishniakou
48f110ec7b Prevent ANR if window is stopped
When an activity is stopped, there could still be some pending events in
the inputconsumer due to batching. Those events are supposed to be
handled when choreographer's 'CALLBACK_INPUT' occurs, but this will
never happen if the window is stopped.

There are two possible ways these events can occur:

1. The last input event happens before onStop, but at that point,
choreographer will already stop sending callbacks. The solution to this
is to add a call to "consumeImmediately" inside setWindowStopped.

2. Input events come in after window has already been stopped. At that
point, the callback we posted in 1. would already have executed (and
found that there's no events). The solution to this is to immediately
consume all input if mStopped=true. We do this by switching to
"unbuffered" mode for simplicity.

This is reproducible via monkey testing, but it's plausible that such
race condition can occur in real world usage.

Test: adb shell monkey --throttle 40 50000
Bug: 159239700
Change-Id: I74d8f55503ef7df2fd01931afb362d68e5026e86
2020-06-25 19:09:53 +01:00
Michael Wright
17761fff2a Isolate batched input scheduling logic.
Having whether something is currently scheduled get modified in the
actual processing logic and away from the scheduling logic makes it
unnecessarily more difficult to reason about.

In this case, we were only checking whether the Choreographer-aligned
runnable was actually scheduled before we'd consume input. When trying
to unbuffer dispatches so that things were no longer
Choreographer-aligned, however, we'd unschedule the that runnable just
before we tried to consume input and hence just before the check . This
meant we never actually consumed the batches until the next one came in
where we would then consume them immediately.  Worse, if another one
never came in then we'd never actually consume the batch.

By removing the scheduling logic from the processing logic we avoid this
situation. Now only the schedule, unschedule, and actual runnable logic
touch their own scheduled state, so that we don't have to consider the
two pieces of logic together except in isolated places.

Bug: 158540186
Bug: 159239700

Test: manual, using app that injects unbuffered dispatch requests either
      at ACTION_DOWN or first ACTION_MOVE
Change-Id: I7521a5a16ed52afc41261f501128b5498ea0602c
2020-06-25 19:08:05 +01:00
Jorim Jaggi
b2410eb4f9 Fix issue in InsetsState.set
Test: InsetsStateTest
Fixes: 159610005
Change-Id: I7e64c4f7d93caae13b43f595a7ec8af901316399
2020-06-25 12:34:03 +00:00
TreeHugger Robot
9e7c46190a Merge "Revert "Enable IMS and its config context to obtain UI component"" into rvc-dev 2020-06-25 00:41:07 +00:00
Alistair Delva
71b8a0456c Revert "Enable IMS and its config context to obtain UI component"
Revert "Verify IMS to get display and WM"

Revert submission 11823238-ims_ui_context

Reason for revert:
Broke the following tests:
android.os.cts.StrictModeTest#testIncorrectContextUse_GetDisplay
android.os.cts.StrictModeTest#testIncorrectContextUse_GetSystemService
android.os.cts.StrictModeTest#testIncorrectContextUse_GetViewConfiguration
But was submitted with a bypass.

Reverted Changes:
I688b46a92:Verify IMS to get display and WM
I172ceb2e1:Enable IMS and its config context to obtain UI com...

Bug: 157027563
Bug: 159795597
Change-Id: Id309faac0ac8f60ee0d92c26767a89f450ddc455
2020-06-24 22:31:53 +00:00
Svet Ganov
4846803547 Address missed comments from previous CL
bug:153826463

Test: atest android.widget.cts.inline.InlineContentViewTest#testReparenting

Change-Id: Iddb1f4d2e0b7043517616d0ec3678a55f9eda34c
2020-06-24 06:39:28 +00:00
Svetoslav Ganov
f8b9ddea71 Merge "Handle reperenting of InlineContentView" into rvc-dev 2020-06-24 06:28:59 +00:00
Svet Ganov
a5b4990d96 Handle reperenting of InlineContentView
When an inline content view is reparented its surface is
getting offset and not being under the view itelf. This is
because the surface views manage the postion of their
surface and are assuming a location based off the window's
surface position. However after a reparenting the inline
content view's surface position becomes relative to that
of the new parent surface view. For example, two surface
views at position (10, 10) being reparented would reslut
in the surface of the parent being at (10, 10) while the
surface of the child being at (20, 20) while both views
would still be at (10, 10).

To address this we are intecepting when an inline content
view's surface is reparented and get a weak reference to
the view that owns the new parent surface. We then position
the inline content view's surface relative to the view that
owns the new parent surface, i.e. we position the surface
such that its location would not change because of the
fact it is being reparented.

While at this make sure the inline content view is marked
as not important for a11y to ernsure the a11y plugins don't
try to click on the view tree in the app's process but
insted on the views in the remote proccess, i.e. on the
embedded view tree.

bug:153826463

Test: atest android.widget.cts.inline.InlineContentViewTest#testReparenting

Change-Id: I2cff4b88d404a740bc447668e948eabccad084d2
2020-06-24 06:27:17 +00:00
Tiger Huang
77190b77f6 Merge "Disable user animations on insets whose visible frame is empty (refined)" into rvc-dev 2020-06-24 04:00:09 +00:00
Charles Chen
8655743001 Merge "Enable IMS and its config context to obtain UI component" into rvc-dev 2020-06-24 03:33:53 +00:00
Joanne Chung
234a31e2f5 Merge "Made AutofillId.withoutSession is testable." into rvc-dev 2020-06-23 22:56:59 +00:00
TreeHugger Robot
e16a6a02a7 Merge "[DO NOT MERGE] Bring back touch events for double tap and double tap and hold." into rvc-dev 2020-06-23 22:24:13 +00:00
Adrian Roos
e658c76b5c Merge "IME animation: hide IME-related navbar icons until perceptible" into rvc-dev 2020-06-23 07:06:48 +00:00
Joanne Chung
24abde551e Made AutofillId.withoutSession is testable.
We add new test in stage-aosp-rvc-ts-dev for R2, we need make this API
testable.

Bug: 156408900
Test: atest android.autofillservice.cts.inline.\
InlineAugmentedWebViewActivityTest

Change-Id: I27d1227f858aac83b3de1cb8ef719edf177524dc
Merged-In: I27d1227f858aac83b3de1cb8ef719edf177524dc
2020-06-23 00:38:40 +00:00
Ameer Armaly
9e83d07824 [DO NOT MERGE] Bring back touch events for double tap and double tap and hold.
Bug: 159168795
Test: atest TouchExplorerTest
Change-Id: I427b98c71ce8a2ac5b9285b2f34c1864f48c4a32
2020-06-22 13:58:51 -07:00
Charles Chen
d2fd037ab3 Enable IMS and its config context to obtain UI component
Test: atest StrictModeTest
Bug: 157027563

Change-Id: I172ceb2e17722a7cba917a6e3a808d7559cad3e0
2020-06-23 03:45:17 +08:00
Taran Singh
296855fe76 Merge "Fix InsetsConsumer leak" into rvc-dev 2020-06-22 18:53:20 +00:00
Tiger Huang
618dbe022f Disable user animations on insets whose visible frame is empty (refined)
Floating IME or fullscreen IME won't cause insets (except the area
overlapped with navigation bar). It doesn't make much sense to let
apps move the IME at these cases.

Fix: 157777145
Test: atest InsetsSourceConsumerTest GlobalActionsImeTest
            ImeInsetsControllerTest
Change-Id: Id70f59be7653beedc02d6c8bc3b1bd50a357f4fe
2020-06-23 00:58:05 +08:00
Taran Singh
531404721f Fix InsetsConsumer leak
Activity was still referred from ImeInsetsSourceConsumer after
ViewRootImpl's mView was destroyed when ViewRoot's surface is cleared
using die signal.
This CL makes sure we still free-up resources at die signal.

Fix: 157955883
Test: atest NexusLauncherTests
Change-Id: Ia48f7b7a8cf6b867ce75b2b7393a60ba73b0c3d0
2020-06-22 15:32:47 +00:00
Adrian Roos
c22eec9d35 IME animation: hide IME-related navbar icons until perceptible
During transitions and while the IME is controlled by the app,
the IME may be "visible" as far as the IME framework is concerned,
but not actually perceptible by the user due to offsets or alpha
applied to the leash.

This may lead to out-of-place navbar symbols for the IME, especially
in gesture nav.

To avoid this, the ImeInsetsSourceConsumer now notifies the IMF of
whether it has made the IME unperceptible to the user.

For now, we ignore the cases where the IME is controlled by something
other than the client window - in that case, we just revert to the
previous behavior of it being always considered perceptible.

Fixes: 158079255
Test: manual, launch email compose activity, observe that back button only indicates once IME appears
Test: atest InsetsAnimationControlImplTest
Change-Id: I4dc9d6513d0559156f7da39244f3fc5ebc952ed4
2020-06-22 16:55:54 +02:00
TreeHugger Robot
70ad33113f Merge "Ignore onStartInput when WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR" into rvc-dev 2020-06-22 14:51:15 +00:00
Ming-Shin Lu
48bfc3165c Ignore onStartInput when WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
CL[1] introduces new WINDOW_FOCUS_GAIN_REPORT_ONLY flows to notify
InputMethodService only reports IME input target to WM when focusing to
the next window and its input connection remains.

Originally in android Q and prior devices, we don't need such report
mechnism but just skip to start new input connection and ignore
onStartInput / onFinishInput for the above use case.

Since starts from Android R, new IME insets control APIs relying on this
mechanism (see CL[2]) to keep the actual IME input target up-to-date.

As we expected there should be no new input connection and additional
onFinishInput when CL[1] landed.

However, in IMMS, startInputUncheckedLocked will be called
to callback additional onStartInput for InputMethodService, which mostly
is not expected, except when focusing the same window after device
turned screen on, we need to start input and callback onStartInput to
align with the behavior of android Q or the prior platform.

Besides, to have more clear code logic and debugging concept of
ignoring onStartInput and onFinishInput only when focused the same editor
with input connection remains, we remove WINDOW_FOCUS_GAIN_REPORT_ONLY
reason and introduced 2 more start input reasons to distinguish the
different behavior:
    - WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
    - WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR

[1]: I45a9814d812ad906f417c24200fd4219959e2423
[2]: I9e8984b7e5aa989a53ece9e2576393f795b9ef94

Fix: 158624922
Test: atest FocusHandlingTest InputMethodStartInputLifecycleTest
Test: manual as below steps:
    1. Use Gboard, Open the emoji keyboard
    2. Swipe down to reveal notification shade
    3. Swipe up to dismiss notifications
    4. Expect the Emoji keyboard is still open without close

Change-Id: I2da99ae67b9ce4051dec0c0f0e975ebe6e1ab118
2020-06-22 12:22:33 +08:00
Taran Singh
4291410118 Animate IME with zero insets
When IME has zero insets, it doesn't map to any side and doesn't have
can't be animated.
IME can have zero insets in following cases:
1. Floating IME
2. Fullscreen IME (in landscape)
3. IME doesn't overlap with IME target window.

In order to animate a type, it must have insets. We can animate IME
from negative insets to zero and vice-versa. This makes zero insets IME a
special case of ISIDE_BOTTOM.
Deprecate SIDE_FLOATING because it shouldn't logically map to a side.

Fix: 153909316
Test: atest WindowInsetsAnimationImeTests#testZeroInsetsImeAnimates
Change-Id: I6d1d3430888db4632cb2f93e9042f692b35ebaeb
2020-06-20 03:51:00 +00:00
TreeHugger Robot
48dc192499 Merge changes I4fdf368e,Ibc6be890 into rvc-dev
* changes:
  SurfaceControlViewHost: Release ViewRoot from finalizer
  SurfaceControlViewHost: Call doDie with true
2020-06-20 00:07:56 +00:00
Robert Carr
7a31b8b1df SurfaceControlViewHost: Release ViewRoot from finalizer
If we don't explicitly go through the doDie process the
WindowManagerGlobal instance will hold the ViewRoot alive
indefinitely. This accidental leak could be very expensive so
we prevent it with a finalizer.

Bug: 157709599
Test: Existing tests pass
Change-Id: I4fdf368eed4b4e43faacd9f62b6d9fddfd9b7ef2
2020-06-19 13:14:00 -07:00
Robert Carr
5409e24105 SurfaceControlViewHost: Call doDie with true
If we pass immediate=false to the doDie without
updating the visibility, we may destroy the hardware renderer
but then try to draw again anyway, and then crash. It seems
theres no reason we can't call immediate=true and
properly shut down immediately.

Bug: 159250432
Test: Existing tests pass
Change-Id: Ibc6be8901be10c0985681d83f4ce16dd1ab54925
2020-06-19 13:10:13 -07:00
Jorim Jaggi
5cc486b1a1 Merge changes Ia7d9514e,I3e9e4f47 into rvc-dev
* changes:
  Yearly Window Manager spring cleaning #2
  Yearly Window Manager spring cleaning #1
2020-06-19 13:58:45 +00:00
Jorim Jaggi
bfa95a71fb Yearly Window Manager spring cleaning #1
- Replace InsetsState ArrayMap with simple array.
- Cache same values in InsetsPolicy.
- Only access Dimmer if dimming

Test: InsetsState test etc.
Bug: 159056748
Change-Id: I3e9e4f473eaa05b2013b7a6d0f37cd9c1fac81dd
2020-06-19 13:18:38 +02:00
TreeHugger Robot
44b233c55d Merge "Fix the context leak in the ContentCapture" into rvc-dev 2020-06-19 06:38:19 +00:00
TYM Tsai
c9f0c232ae Fix the context leak in the ContentCapture
Activity cannot be released because the context be holded by multiple
objects.
* Activity holds ContentCaptureManager.
* ContentCaptureManager holds the context and MainContextCaptureSession.
* MainContextCaptureSession holds the context and ContentCaptureManager.
* The system server holds some binder references to MainContentCaptureSession.
If the system service never released the binder references, then the
activity is also never GC'd.
To avoid the issue,
1. Make the session state receiver of MainContextCaptureSession to be
   static and uses weak reference to MainContextCaptureSession.
2. The direct service vulture may miss to do unlinkToDeath(), do a checking
   while the session destory.

Bug: 143210612
Test: manual check Objects on the meminfo
Test: Activities should be released after a period of time
Test: adb shell dumpsys meminfo com.google.android.dialer
Change-Id: I12037483addb1efe444c74fa189ef6afd15821dd
2020-06-19 12:09:54 +08:00