Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6d1e09f authored by Kyeongkab.Nam's avatar Kyeongkab.Nam Committed by nchalko
Browse files

TIF: Add TvInputService#onHdmiDeviceUpdated()

Add API to update device infos to TvInputInfo.

Bug: 145047101
Test: Manual
Change-Id: I67438193cc00d3bf76b8ebaa02869b6ff4e04b77
parent 01e54d44
Loading
Loading
Loading
Loading

api/system-current.txt

100644 → 100755
+1 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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;
+10 −0
Original line number Diff line number Diff line
@@ -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);
                    }
                }
            }
        }
    }