Fix crash when Context is null in InCallPresenter
We need to use the Context to check if the device is a ODR device for a workaround (http://cl/165734624). It turns out the Context can be null (rarely). In those cases, we should not crash.
Bug: 64954483
Test: manual
PiperOrigin-RevId: 167326838
Change-Id: I4d8d8de86b5e3a4eca165a562f2ddc6106052c6e
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java
index 3f87a59..4cc03f3 100644
--- a/java/com/android/incallui/InCallPresenter.java
+++ b/java/com/android/incallui/InCallPresenter.java
@@ -1682,18 +1682,23 @@
VideoSurfaceTexture getLocalVideoSurfaceTexture() {
if (mLocalVideoSurfaceTexture == null) {
- mLocalVideoSurfaceTexture =
- VideoSurfaceBindings.createLocalVideoSurfaceTexture(
- mContext.getPackageManager().hasSystemFeature(PIXEL2017_SYSTEM_FEATURE));
+ boolean isPixel2017 = false;
+ if (mContext != null) {
+ isPixel2017 = mContext.getPackageManager().hasSystemFeature(PIXEL2017_SYSTEM_FEATURE);
+ }
+ mLocalVideoSurfaceTexture = VideoSurfaceBindings.createLocalVideoSurfaceTexture(isPixel2017);
}
return mLocalVideoSurfaceTexture;
}
VideoSurfaceTexture getRemoteVideoSurfaceTexture() {
if (mRemoteVideoSurfaceTexture == null) {
+ boolean isPixel2017 = false;
+ if (mContext != null) {
+ isPixel2017 = mContext.getPackageManager().hasSystemFeature(PIXEL2017_SYSTEM_FEATURE);
+ }
mRemoteVideoSurfaceTexture =
- VideoSurfaceBindings.createRemoteVideoSurfaceTexture(
- mContext.getPackageManager().hasSystemFeature(PIXEL2017_SYSTEM_FEATURE));
+ VideoSurfaceBindings.createRemoteVideoSurfaceTexture(isPixel2017);
}
return mRemoteVideoSurfaceTexture;
}