am 05df974a: Hook up device power status change to TIF
* commit '05df974a127a6c4b38a030d449d54d336813bfc1': Hook up device power status change to TIF
This commit is contained in:
@@ -69,6 +69,10 @@ public final class HdmiControlManager {
|
||||
public static final int RESULT_INCORRECT_MODE = 6;
|
||||
public static final int RESULT_COMMUNICATION_FAILED = 7;
|
||||
|
||||
public static final int DEVICE_EVENT_ADD_DEVICE = 1;
|
||||
public static final int DEVICE_EVENT_REMOVE_DEVICE = 2;
|
||||
public static final int DEVICE_EVENT_UPDATE_DEVICE = 3;
|
||||
|
||||
// --- One Touch Recording success result
|
||||
/** Recording currently selected source. Indicates the status of a recording. */
|
||||
public static final int ONE_TOUCH_RECORD_RECORDING_CURRENTLY_SELECTED_SOURCE = 0x01;
|
||||
|
||||
@@ -29,7 +29,12 @@ oneway interface IHdmiDeviceEventListener {
|
||||
/**
|
||||
* @param deviceInfo {@link HdmiDeviceInfo} of the logical device whose
|
||||
* status has changed
|
||||
* @param activated true if the device gets activated
|
||||
* @param status device status. It should be one of the following values
|
||||
* <ul>
|
||||
* <li>{@link HdmiControlManager#DEVICE_EVENT_ADD_DEVICE}
|
||||
* <li>{@link HdmiControlManager#DEVICE_EVENT_REMOVE_DEVICE}
|
||||
* <li>{@link HdmiControlManager#DEVICE_EVENT_UPDATE_DEVICE}
|
||||
* </ul>
|
||||
*/
|
||||
void onStatusChanged(in HdmiDeviceInfo deviceInfo, in boolean activated);
|
||||
void onStatusChanged(in HdmiDeviceInfo deviceInfo, in int status);
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
private void clearDeviceInfoList() {
|
||||
assertRunOnServiceThread();
|
||||
for (HdmiDeviceInfo info : mSafeExternalInputs) {
|
||||
invokeDeviceEventListener(info, false);
|
||||
invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE);
|
||||
}
|
||||
mDeviceInfos.clear();
|
||||
updateSafeDeviceInfoList();
|
||||
@@ -1070,9 +1070,9 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void invokeDeviceEventListener(HdmiDeviceInfo info, boolean activated) {
|
||||
private void invokeDeviceEventListener(HdmiDeviceInfo info, int status) {
|
||||
if (!hideDevicesBehindLegacySwitch(info)) {
|
||||
mService.invokeDeviceEventListeners(info, activated);
|
||||
mService.invokeDeviceEventListeners(info, status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1144,7 +1144,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
// The addition of TV device itself should not be notified.
|
||||
return;
|
||||
}
|
||||
invokeDeviceEventListener(info, true);
|
||||
invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_ADD_DEVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1158,7 +1158,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
HdmiDeviceInfo info = removeDeviceInfo(address);
|
||||
|
||||
mCecMessageCache.flushMessagesFrom(address);
|
||||
invokeDeviceEventListener(info, false);
|
||||
invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE);
|
||||
}
|
||||
|
||||
@ServiceThreadOnly
|
||||
@@ -1537,6 +1537,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
// addDeviceInfo replaces old device info with new one if exists.
|
||||
addDeviceInfo(newInfo);
|
||||
|
||||
// TODO: notify this update to others.
|
||||
invokeDeviceEventListener(newInfo, HdmiControlManager.DEVICE_EVENT_UPDATE_DEVICE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1254,11 +1254,11 @@ public final class HdmiControlService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
void invokeDeviceEventListeners(HdmiDeviceInfo device, boolean activated) {
|
||||
void invokeDeviceEventListeners(HdmiDeviceInfo device, int status) {
|
||||
synchronized (mLock) {
|
||||
for (IHdmiDeviceEventListener listener : mDeviceEventListeners) {
|
||||
try {
|
||||
listener.onStatusChanged(device, activated);
|
||||
listener.onStatusChanged(device, status);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Failed to report device event:" + e);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.media.tv.TvInputManager.INPUT_STATE_DISCONNECTED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.HdmiDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiHotplugEvent;
|
||||
import android.hardware.hdmi.IHdmiControlService;
|
||||
@@ -862,6 +863,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
public void onHardwareDeviceRemoved(TvInputHardwareInfo info);
|
||||
public void onHdmiDeviceAdded(HdmiDeviceInfo device);
|
||||
public void onHdmiDeviceRemoved(HdmiDeviceInfo device);
|
||||
public void onHdmiDeviceUpdated(HdmiDeviceInfo device);
|
||||
}
|
||||
|
||||
private class ListenerHandler extends Handler {
|
||||
@@ -870,6 +872,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
private static final int HARDWARE_DEVICE_REMOVED = 3;
|
||||
private static final int HDMI_DEVICE_ADDED = 4;
|
||||
private static final int HDMI_DEVICE_REMOVED = 5;
|
||||
private static final int HDMI_DEVICE_UPDATED = 6;
|
||||
|
||||
@Override
|
||||
public final void handleMessage(Message msg) {
|
||||
@@ -900,6 +903,10 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
mListener.onHdmiDeviceRemoved(info);
|
||||
break;
|
||||
}
|
||||
case HDMI_DEVICE_UPDATED: {
|
||||
HdmiDeviceInfo info = (HdmiDeviceInfo) msg.obj;
|
||||
mListener.onHdmiDeviceUpdated(info);
|
||||
}
|
||||
default: {
|
||||
Slog.w(TAG, "Unhandled message: " + msg);
|
||||
break;
|
||||
@@ -932,25 +939,40 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
|
||||
private final class HdmiDeviceEventListener extends IHdmiDeviceEventListener.Stub {
|
||||
@Override
|
||||
public void onStatusChanged(HdmiDeviceInfo deviceInfo, boolean activated) {
|
||||
public void onStatusChanged(HdmiDeviceInfo deviceInfo, int status) {
|
||||
synchronized (mLock) {
|
||||
if (activated) {
|
||||
if (!mHdmiDeviceList.contains(deviceInfo)) {
|
||||
mHdmiDeviceList.add(deviceInfo);
|
||||
} else {
|
||||
Slog.w(TAG, "The list already contains " + deviceInfo + "; ignoring.");
|
||||
return;
|
||||
int messageType = 0;
|
||||
switch (status) {
|
||||
case HdmiControlManager.DEVICE_EVENT_ADD_DEVICE: {
|
||||
if (!mHdmiDeviceList.contains(deviceInfo)) {
|
||||
mHdmiDeviceList.add(deviceInfo);
|
||||
} else {
|
||||
Slog.w(TAG, "The list already contains " + deviceInfo + "; ignoring.");
|
||||
return;
|
||||
}
|
||||
messageType = ListenerHandler.HDMI_DEVICE_ADDED;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!mHdmiDeviceList.remove(deviceInfo)) {
|
||||
Slog.w(TAG, "The list doesn't contain " + deviceInfo + "; ignoring.");
|
||||
return;
|
||||
case HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE: {
|
||||
if (!mHdmiDeviceList.remove(deviceInfo)) {
|
||||
Slog.w(TAG, "The list doesn't contain " + deviceInfo + "; ignoring.");
|
||||
return;
|
||||
}
|
||||
messageType = ListenerHandler.HDMI_DEVICE_REMOVED;
|
||||
break;
|
||||
}
|
||||
case HdmiControlManager.DEVICE_EVENT_UPDATE_DEVICE: {
|
||||
if (!mHdmiDeviceList.remove(deviceInfo)) {
|
||||
Slog.w(TAG, "The list doesn't contain " + deviceInfo + "; ignoring.");
|
||||
return;
|
||||
}
|
||||
mHdmiDeviceList.add(deviceInfo);
|
||||
messageType = ListenerHandler.HDMI_DEVICE_UPDATED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Message msg = mHandler.obtainMessage(
|
||||
activated ? ListenerHandler.HDMI_DEVICE_ADDED
|
||||
: ListenerHandler.HDMI_DEVICE_REMOVED,
|
||||
0, 0, deviceInfo);
|
||||
|
||||
Message msg = mHandler.obtainMessage(messageType, 0, 0, deviceInfo);
|
||||
if (findHardwareInfoForHdmiPortLocked(deviceInfo.getPortId()) != null) {
|
||||
msg.sendToTarget();
|
||||
} else {
|
||||
|
||||
@@ -2174,5 +2174,10 @@ public final class TvInputManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHdmiDeviceUpdated(HdmiDeviceInfo deviceInfo) {
|
||||
// TODO: implement here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user