diff options
author | Jinsuk Kim <jinsukkim@google.com> | 2015-07-07 08:01:02 +0900 |
---|---|---|
committer | Jinsuk Kim <jinsukkim@google.com> | 2015-07-08 06:48:52 +0900 |
commit | e601b712b10323d0c0a737567cf6798a0d20a219 (patch) | |
tree | 79f6fcbeadb3d64da6e2a9655ef8c9104ac80ed4 /services | |
parent | e42441a232ae1a75cdd2541f974ed8da258b97cd (diff) | |
download | frameworks_base-e601b712b10323d0c0a737567cf6798a0d20a219.zip frameworks_base-e601b712b10323d0c0a737567cf6798a0d20a219.tar.gz frameworks_base-e601b712b10323d0c0a737567cf6798a0d20a219.tar.bz2 |
Perform One touch play upon pressing home key
Power on TV (optional) and switch HDMI input when home key is pressed
on a device with HDMI-out port (playback device).
Bug: 22204515
Change-Id: Ie1714e9bb066fedc618ee176d1a2bd1572393a6e
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 93e1f18..461c936 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -44,6 +44,9 @@ import android.content.res.TypedArray; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.graphics.Rect; +import android.hardware.hdmi.HdmiControlManager; +import android.hardware.hdmi.HdmiPlaybackClient; +import android.hardware.hdmi.HdmiPlaybackClient.OneTouchPlayCallback; import android.media.AudioAttributes; import android.media.AudioManager; import android.media.AudioSystem; @@ -351,6 +354,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mSystemReady; boolean mSystemBooted; boolean mHdmiPlugged; + HdmiControl mHdmiControl; IUiModeManager mUiModeManager; int mUiMode; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; @@ -1200,6 +1204,9 @@ 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(); + // If there's a dream running then use home to escape the dream // but don't actually go home. if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) { @@ -1211,6 +1218,46 @@ public class PhoneWindowManager implements WindowManagerPolicy { launchHomeFromHotKey(); } + /** + * 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. + */ + private HdmiControl getHdmiControl() { + if (null == mHdmiControl) { + HdmiControlManager manager = (HdmiControlManager) mContext.getSystemService( + Context.HDMI_CONTROL_SERVICE); + HdmiPlaybackClient client = null; + if (manager != null) { + client = manager.getPlaybackClient(); + } + mHdmiControl = new HdmiControl(client); + } + return mHdmiControl; + } + + private static class HdmiControl { + private final HdmiPlaybackClient mClient; + + private HdmiControl(HdmiPlaybackClient client) { + mClient = client; + } + + public void turnOnTv() { + if (mClient == null) { + return; + } + mClient.oneTouchPlay(new OneTouchPlayCallback() { + @Override + public void onComplete(int result) { + if (result != HdmiControlManager.RESULT_SUCCESS) { + Log.w(TAG, "One touch play failed: " + result); + } + } + }); + } + } + private void handleLongPressOnHome(int deviceId) { if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { mHomeConsumed = true; |