Merge "TIF: Add TvInputService#onHdmiDeviceUpdated()"

am: efacbc6cc8

Change-Id: I0fddc69addc32b6923bb76327b7f5ebbb66728a6
This commit is contained in:
Kyeongkab.Nam
2019-12-13 02:02:32 -08:00
committed by android-build-merger
4 changed files with 42 additions and 0 deletions

1
api/system-current.txt Normal file → Executable file
View File

@@ -4081,6 +4081,7 @@ package android.media.tv {
method @Nullable public String onHardwareRemoved(android.media.tv.TvInputHardwareInfo);
method @Nullable public android.media.tv.TvInputInfo onHdmiDeviceAdded(android.hardware.hdmi.HdmiDeviceInfo);
method @Nullable public String onHdmiDeviceRemoved(android.hardware.hdmi.HdmiDeviceInfo);
method public void onHdmiDeviceUpdated(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
}
public abstract static class TvInputService.RecordingSession {

1
media/java/android/media/tv/ITvInputService.aidl Normal file → Executable file
View File

@@ -38,4 +38,5 @@ oneway interface ITvInputService {
void notifyHardwareRemoved(in TvInputHardwareInfo hardwareInfo);
void notifyHdmiDeviceAdded(in HdmiDeviceInfo deviceInfo);
void notifyHdmiDeviceRemoved(in HdmiDeviceInfo deviceInfo);
void notifyHdmiDeviceUpdated(in HdmiDeviceInfo deviceInfo);
}

30
media/java/android/media/tv/TvInputService.java Normal file → Executable file
View File

@@ -173,6 +173,12 @@ public abstract class TvInputService extends Service {
mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HDMI_INPUT,
deviceInfo).sendToTarget();
}
@Override
public void notifyHdmiDeviceUpdated(HdmiDeviceInfo deviceInfo) {
mServiceHandler.obtainMessage(ServiceHandler.DO_UPDATE_HDMI_INPUT,
deviceInfo).sendToTarget();
}
};
}
@@ -257,6 +263,24 @@ public abstract class TvInputService extends Service {
return null;
}
/**
* Called when {@code deviceInfo} is updated.
*
* <p>The changes are usually cuased by the corresponding HDMI-CEC logical device.
*
* <p>The default behavior ignores all changes.
*
* <p>The TV input service responsible for {@code deviceInfo} can update the {@link TvInputInfo}
* object based on the updated {@code deviceInfo} (e.g. update the label based on the preferred
* device OSD name).
*
* @param deviceInfo the updated {@link HdmiDeviceInfo} object.
* @hide
*/
@SystemApi
public void onHdmiDeviceUpdated(@NonNull HdmiDeviceInfo deviceInfo) {
}
private boolean isPassthroughInput(String inputId) {
if (mTvInputManager == null) {
mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
@@ -1962,6 +1986,7 @@ public abstract class TvInputService extends Service {
private static final int DO_REMOVE_HARDWARE_INPUT = 5;
private static final int DO_ADD_HDMI_INPUT = 6;
private static final int DO_REMOVE_HDMI_INPUT = 7;
private static final int DO_UPDATE_HDMI_INPUT = 8;
private void broadcastAddHardwareInput(int deviceId, TvInputInfo inputInfo) {
int n = mCallbacks.beginBroadcast();
@@ -2131,6 +2156,11 @@ public abstract class TvInputService extends Service {
}
return;
}
case DO_UPDATE_HDMI_INPUT: {
HdmiDeviceInfo deviceInfo = (HdmiDeviceInfo) msg.obj;
onHdmiDeviceUpdated(deviceInfo);
return;
}
default: {
Log.w(TAG, "Unhandled message code: " + msg.what);
return;

View File

@@ -2943,6 +2943,16 @@ public final class TvInputManagerService extends SystemService {
if (state != null) {
setStateLocked(inputId, state, mCurrentUserId);
}
UserState userState = getOrCreateUserStateLocked(mCurrentUserId);
// Broadcast the event to all hardware inputs.
for (ServiceState serviceState : userState.serviceStateMap.values()) {
if (!serviceState.isHardware || serviceState.service == null) continue;
try {
serviceState.service.notifyHdmiDeviceUpdated(deviceInfo);
} catch (RemoteException e) {
Slog.e(TAG, "error in notifyHdmiDeviceUpdated", e);
}
}
}
}
}