summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTiger Huang <tigerhuang@google.com>2021-11-05 00:38:36 +0800
committerTiger Huang <tigerhuang@google.com>2021-11-04 17:26:04 +0000
commit751839bd2a8512efd83c3a60f775f495c272f08d (patch)
treee33a876ea1c2cdae43f2ae6d67ceaac86140fe7a /core/java
parentbef7c4f0ca9245a66765b4313ef312f19b9122d2 (diff)
Make sure mParent is not null before using it
Otherwise, there will be NullPointerException. Fix: 204883084 Test: Run the following code and see if it crashes. ViewGroup v = new FrameLayout(context); v.requestTransparentRegion(v); getWindowManager().addView(v, attrs); getWindowManager().removeView(v); Change-Id: I059e13d2a258cf85dbc1694fb79b6088199de3fb
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/View.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 572a7cdabdc9..f4386099a550 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -20270,7 +20270,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
@CallSuper
protected void onAttachedToWindow() {
- if ((mPrivateFlags & PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) {
+ if (mParent != null && (mPrivateFlags & PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) {
mParent.requestTransparentRegion(this);
}
@@ -25044,7 +25044,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
View parent = this;
- while (parent.mParent != null && parent.mParent instanceof View) {
+ while (parent.mParent instanceof View) {
parent = (View) parent.mParent;
}