am e249eb3a: Merge "Perform One touch play upon pressing home key" into mnc-dev
* commit 'e249eb3a6f33ee945113a8f11e8382e70c4e066f': Perform One touch play upon pressing home key
This commit is contained in:
@@ -44,6 +44,9 @@ import android.content.res.TypedArray;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
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.AudioAttributes;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.AudioSystem;
|
import android.media.AudioSystem;
|
||||||
@@ -356,6 +359,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
boolean mSystemReady;
|
boolean mSystemReady;
|
||||||
boolean mSystemBooted;
|
boolean mSystemBooted;
|
||||||
boolean mHdmiPlugged;
|
boolean mHdmiPlugged;
|
||||||
|
HdmiControl mHdmiControl;
|
||||||
IUiModeManager mUiModeManager;
|
IUiModeManager mUiModeManager;
|
||||||
int mUiMode;
|
int mUiMode;
|
||||||
int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED;
|
int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED;
|
||||||
@@ -1212,6 +1216,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleShortPressOnHome() {
|
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
|
// If there's a dream running then use home to escape the dream
|
||||||
// but don't actually go home.
|
// but don't actually go home.
|
||||||
if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) {
|
if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) {
|
||||||
@@ -1223,6 +1230,46 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
launchHomeFromHotKey();
|
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) {
|
private void handleLongPressOnHome(int deviceId) {
|
||||||
if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
|
if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
|
||||||
mHomeConsumed = true;
|
mHomeConsumed = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user