diff options
| author | Alan Viverette <alanv@google.com> | 2018-01-05 15:33:24 -0500 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2018-02-20 15:11:58 -0500 |
| commit | 6d89f482552067544d67716a469979769cdbe6b8 (patch) | |
| tree | dd36c33af6afde332baef4516092acd9bbcafbef /core/java/android/view/WindowId.java | |
| parent | 85a6db68f1860bbaacc1cc21e29c4f61aabe0abb (diff) | |
Don't end transitions on a detached window, prevent crash in WindowId
A WindowId's token should never be null, but let's avoid getting into
that situation in the first place.
Fixes: 70015590
Test: manual, cannot reliably repro in CTS test
Change-Id: I378ba9ba822ecc445d3b8de265b5ec0d20a12dd3
Diffstat (limited to 'core/java/android/view/WindowId.java')
| -rw-r--r-- | core/java/android/view/WindowId.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/core/java/android/view/WindowId.java b/core/java/android/view/WindowId.java index c4cda2c70f25..12e58f14e4f9 100644 --- a/core/java/android/view/WindowId.java +++ b/core/java/android/view/WindowId.java @@ -16,6 +16,8 @@ package android.view; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -35,6 +37,7 @@ import java.util.HashMap; * that doesn't allow the other process to negatively harm your window. */ public class WindowId implements Parcelable { + @NonNull private final IWindowId mToken; /** @@ -74,8 +77,7 @@ public class WindowId implements Parcelable { } }; - final HashMap<IBinder, WindowId> mRegistrations - = new HashMap<IBinder, WindowId>(); + final HashMap<IBinder, WindowId> mRegistrations = new HashMap<>(); class H extends Handler { @Override @@ -163,10 +165,9 @@ public class WindowId implements Parcelable { * same package. */ @Override - public boolean equals(Object otherObj) { + public boolean equals(@Nullable Object otherObj) { if (otherObj instanceof WindowId) { - return mToken.asBinder().equals(((WindowId) otherObj) - .mToken.asBinder()); + return mToken.asBinder().equals(((WindowId) otherObj).mToken.asBinder()); } return false; } @@ -182,7 +183,7 @@ public class WindowId implements Parcelable { sb.append("IntentSender{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(": "); - sb.append(mToken != null ? mToken.asBinder() : null); + sb.append(mToken.asBinder()); sb.append('}'); return sb.toString(); } @@ -195,30 +196,32 @@ public class WindowId implements Parcelable { out.writeStrongBinder(mToken.asBinder()); } - public static final Parcelable.Creator<WindowId> CREATOR - = new Parcelable.Creator<WindowId>() { + public static final Parcelable.Creator<WindowId> CREATOR = new Parcelable.Creator<WindowId>() { + @Override public WindowId createFromParcel(Parcel in) { IBinder target = in.readStrongBinder(); return target != null ? new WindowId(target) : null; } + @Override public WindowId[] newArray(int size) { return new WindowId[size]; } }; /** @hide */ + @NonNull public IWindowId getTarget() { return mToken; } /** @hide */ - public WindowId(IWindowId target) { + public WindowId(@NonNull IWindowId target) { mToken = target; } /** @hide */ - public WindowId(IBinder target) { + public WindowId(@NonNull IBinder target) { mToken = IWindowId.Stub.asInterface(target); } } |
