Commit d1b784de authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Android] Disallow null stubs on DeferredViewStubInflationProvider

Currently, the DeferredViewStubInflationProvider will accept null as
view stub and try to inflate the non-existent stub much later.

To prevent this deferred NullPointerException, assert that used stubs
are never null. Fix the usage that uncovered that issue.

Bug: 876215
Change-Id: I51deb6aaa1ac3d3283e6794c0cae37c536b43aa5
Reviewed-on: https://chromium-review.googlesource.com/1210783Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Friedrich Horschig [CEST] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589487}
parent c50ab869
......@@ -1379,10 +1379,13 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
setStatusBarColor(null, mBaseStatusBarColor);
}, coordinator);
mManualFillingController.initialize(getWindowAndroid(),
new DeferredViewStubInflationProvider<>(findViewById(R.id.keyboard_accessory_stub)),
new DeferredViewStubInflationProvider<>(
findViewById(R.id.keyboard_accessory_sheet_stub)));
ViewStub accessoryBarStub = findViewById(R.id.keyboard_accessory_stub);
ViewStub accessorySheetStub = findViewById(R.id.keyboard_accessory_sheet_stub);
if (accessoryBarStub != null && accessorySheetStub != null) {
mManualFillingController.initialize(getWindowAndroid(),
new DeferredViewStubInflationProvider<>(accessoryBarStub),
new DeferredViewStubInflationProvider<>(accessorySheetStub));
}
// Create after native initialization so subclasses that override this method have a chance
// to setup.
......
......@@ -21,6 +21,7 @@ public class DeferredViewStubInflationProvider<T extends View> implements ViewPr
@SuppressWarnings("unchecked")
public DeferredViewStubInflationProvider(ViewStub viewStub) {
assert viewStub != null : "ViewStub to inflate may not be null!";
mViewStub = viewStub;
mViewStub.setOnInflateListener((stub, inflated) -> { mViewPromise.fulfill((T) inflated); });
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment