import android.view.KeyEvent;
import android.view.Surface;
+import com.android.internal.os.SomeArgs;
import com.android.server.SystemService;
import java.util.ArrayList;
public void onHardwareDeviceRemoved(TvInputHardwareInfo info);
public void onHdmiDeviceAdded(HdmiDeviceInfo device);
public void onHdmiDeviceRemoved(HdmiDeviceInfo device);
- public void onHdmiDeviceUpdated(HdmiDeviceInfo device);
+ public void onHdmiDeviceUpdated(String inputId, HdmiDeviceInfo device);
}
private class ListenerHandler extends Handler {
break;
}
case HDMI_DEVICE_UPDATED: {
- HdmiDeviceInfo info = (HdmiDeviceInfo) msg.obj;
- mListener.onHdmiDeviceUpdated(info);
+ SomeArgs args = (SomeArgs) msg.obj;
+ String inputId = (String) args.arg1;
+ HdmiDeviceInfo info = (HdmiDeviceInfo) args.arg2;
+ args.recycle();
+ mListener.onHdmiDeviceUpdated(inputId, info);
}
default: {
Slog.w(TAG, "Unhandled message: " + msg);
public void onStatusChanged(HdmiDeviceInfo deviceInfo, int status) {
synchronized (mLock) {
int messageType = 0;
+ Object obj = null;
switch (status) {
case HdmiControlManager.DEVICE_EVENT_ADD_DEVICE: {
if (!mHdmiDeviceList.contains(deviceInfo)) {
return;
}
messageType = ListenerHandler.HDMI_DEVICE_ADDED;
+ obj = deviceInfo;
break;
}
case HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE: {
return;
}
messageType = ListenerHandler.HDMI_DEVICE_REMOVED;
+ obj = deviceInfo;
break;
}
case HdmiControlManager.DEVICE_EVENT_UPDATE_DEVICE: {
}
mHdmiDeviceList.add(deviceInfo);
messageType = ListenerHandler.HDMI_DEVICE_UPDATED;
+ String inputId = mHdmiInputIdMap.get(deviceInfo.getLogicalAddress());
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = inputId;
+ args.arg2 = deviceInfo;
+ obj = args;
break;
}
}
- Message msg = mHandler.obtainMessage(messageType, 0, 0, deviceInfo);
+ Message msg = mHandler.obtainMessage(messageType, 0, 0, obj);
if (findHardwareInfoForHdmiPortLocked(deviceInfo.getPortId()) != null) {
msg.sendToTarget();
} else {
package com.android.server.tv;
import static android.media.tv.TvInputManager.INPUT_STATE_CONNECTED;
+import static android.media.tv.TvInputManager.INPUT_STATE_CONNECTED_STANDBY;
import static android.media.tv.TvInputManager.INPUT_STATE_DISCONNECTED;
import android.app.ActivityManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.graphics.Rect;
+import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.media.tv.ITvInputClient;
import android.media.tv.ITvInputHardware;
}
@Override
- public void onHdmiDeviceUpdated(HdmiDeviceInfo deviceInfo) {
- // TODO: implement here.
+ public void onHdmiDeviceUpdated(String inputId, HdmiDeviceInfo deviceInfo) {
+ synchronized (mLock) {
+ Integer state = null;
+ switch (deviceInfo.getDevicePowerStatus()) {
+ case HdmiControlManager.POWER_STATUS_ON:
+ state = INPUT_STATE_CONNECTED;
+ break;
+ case HdmiControlManager.POWER_STATUS_STANDBY:
+ case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON:
+ case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY:
+ state = INPUT_STATE_CONNECTED_STANDBY;
+ break;
+ case HdmiControlManager.POWER_STATUS_UNKNOWN:
+ default:
+ state = null;
+ break;
+ }
+ if (state != null) {
+ setStateLocked(inputId, state.intValue(), mCurrentUserId);
+ }
+ }
}
}
}