From 12b50c650c4fc61ff9f59670e3edf08a0bdb3620 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Fri, 1 Sep 2017 14:41:19 -0700 Subject: 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 --- java/com/android/incallui/InCallPresenter.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'java/com/android/incallui/InCallPresenter.java') diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index 3f87a592d..4cc03f3dd 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -1682,18 +1682,23 @@ public class InCallPresenter implements CallList.Listener { 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; } -- cgit v1.2.3