diff options
| author | lumark <lumark@google.com> | 2019-07-23 21:18:17 +0800 |
|---|---|---|
| committer | lumark <lumark@google.com> | 2019-08-06 23:22:56 +0800 |
| commit | 3f51e3cfd474fa6bb2a77f397eceeeb8954d2b1f (patch) | |
| tree | 2be009f753cc0c31933673f9cb60d006a4f3276f /core/java/android/app/ActivityView.java | |
| parent | 1234469cda9c0a29bbd9cc89d8758e487e97f2ee (diff) | |
Fix ActivityView surface can't visible for ActivityViewTest
CL [1] introduced ActivityView's surface view set alpha as zero by default.
but SurfaceView ignores alpha value by default.
So to archieve SurfaceView can support alpha value and then introduced CL[2].
with that CL, it will affect ActivityView that can't see the surface because
of this zero alpha value.
Since CLs[1] & [2] are mainly considered for BubbleController to implement
content visiblity with setting surface view's alpha value without
flickering, and in BubbleExpandedView#onFinishInflate has already
called setContentVisibility(false) to set ActivityView's alpha value as
zero before add this view.
So removing ActivityView's default zero alpha value would be fine, since
it may not always the case that need to set zero alpha but need to show
the black rectangle surface for user. (i.e. ActivityViewTest or Android Auto)
Also, refined ActivityView#setAlpha for some stuff to make it clear.
[1]: Ie5aed373996419b059935889b564ca91c2e3cf23
[2]: I86847de59109b2adf12a2c7c50c988c2cbcf0450
Bug: 137937105
Test: manual as below steps
1) make & install ActivityViewTest
2) launch "AV Main" shortcut
3) press "Test ActivityView" -> "Launch test activity"
4) see if launched Acitvity is visible as expected.
Test: atest ActivityViewTest, observe if ActivityView is visible during testing.
Change-Id: Iaf480912f06a6851001a42bf90e4d962c8a88a37
Diffstat (limited to 'core/java/android/app/ActivityView.java')
| -rw-r--r-- | core/java/android/app/ActivityView.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index 415ec64dc126..e8918285777b 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -120,8 +120,10 @@ public class ActivityView extends ViewGroup { mActivityTaskManager = ActivityTaskManager.getService(); mSurfaceView = new SurfaceView(context); + // Since ActivityView#getAlpha has been overridden, we should use parent class's alpha + // as master to synchronize surface view's alpha value. + mSurfaceView.setAlpha(super.getAlpha()); mSurfaceView.setUseAlpha(); - mSurfaceView.setAlpha(0f); mSurfaceCallback = new SurfaceCallback(); mSurfaceView.getHolder().addCallback(mSurfaceCallback); addView(mSurfaceView); @@ -348,9 +350,20 @@ public class ActivityView extends ViewGroup { mSurfaceView.layout(0 /* left */, 0 /* top */, r - l /* right */, b - t /* bottom */); } + /** + * Sets the alpha value when the content of {@link SurfaceView} needs to show or hide. + * <p>Note: The surface view may ignore the alpha value in some cases. Refer to + * {@link SurfaceView#setAlpha} for more details. + * + * @param alpha The opacity of the view. + */ @Override public void setAlpha(float alpha) { - mSurfaceView.setAlpha(alpha); + super.setAlpha(alpha); + + if (mSurfaceView != null) { + mSurfaceView.setAlpha(alpha); + } } @Override |
