diff options
| author | 2016-12-21 12:18:05 -0800 | |
|---|---|---|
| committer | 2016-12-21 12:18:05 -0800 | |
| commit | eb4a7943b19df05bb5bfb42cd26934ece45ef95c (patch) | |
| tree | 97308d682f301a78fa31b5f82d01c5414aba8e93 | |
| parent | 7fcd3fe24bd5370904e99a4eb6b0af5402117184 (diff) | |
Check if device supports HDMI before getting service
Hdmi control service is created only if device supports
HDMI CEC, so need to check for it before requesting.
Change-Id: I0e2d83514fd3b87e8db0a5e6784fc69377b890cf
Fixes: 33193534
Test: Manual - click home button, check logs for crashes.
| -rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 9d4b51fd66bf..fa1d991fa39a 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1567,7 +1567,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void handleShortPressOnHome() { // Turn on the connected TV and switch HDMI input if we're a HDMI playback device. - getHdmiControl().turnOnTv(); + final HdmiControl hdmiControl = getHdmiControl(); + if (hdmiControl != null) { + hdmiControl.turnOnTv(); + } // If there's a dream running then use home to escape the dream // but don't actually go home. @@ -1584,9 +1587,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { * Creates an accessor to HDMI control service that performs the operation of * turning on TV (optional) and switching input to us. If HDMI control service * is not available or we're not a HDMI playback device, the operation is no-op. + * @return {@link HdmiControl} instance if available, null otherwise. */ private HdmiControl getHdmiControl() { if (null == mHdmiControl) { + if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_HDMI_CEC)) { + return null; + } HdmiControlManager manager = (HdmiControlManager) mContext.getSystemService( Context.HDMI_CONTROL_SERVICE); HdmiPlaybackClient client = null; |