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

Commit 8f87c0b1 authored by Sherry Huang's avatar Sherry Huang
Browse files

TIF: update throw exception to log exception in servicestate

When an tis that is hardware is not allowed for kids, it could lead to
IllegalStateException when querying servicestate. This is because the
hardware input is added on owner session as it is allowed for the owner.
As we intent to share hardware inputs across profiles, this should not
happen when allowlist is finalized. For now, we should indicate the
exception with log instead of throw the exception, leading to the system
to crash unncessarily.

Test: manual
Bug: b/408900599
Flag: EXEMPT minor fix
Change-Id: Iadf1fecb962969f6e5a01fb3fa53fce29ace8348
parent a744c7e8
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -837,8 +837,7 @@ public final class TvInputManagerService extends SystemService {
        UserState userState = getOrCreateUserStateLocked(userId);
        ServiceState serviceState = userState.serviceStateMap.get(component);
        if (serviceState == null) {
            throw new IllegalStateException("Service state not found for " + component + " (userId="
                    + userId + ")");
            Slog.e(TAG, "Service state not found for " + component + " (userId=" + userId + ")");
        }
        return serviceState;
    }
@@ -1098,7 +1097,7 @@ public final class TvInputManagerService extends SystemService {
                        Process.SYSTEM_UID, userId);
            }
            ServiceState serviceState = getServiceStateLocked(sessionState.componentName, userId);
            if (!serviceState.isHardware) {
            if (serviceState == null || !serviceState.isHardware) {
                return;
            }
            ITvInputSession session = getSessionLocked(sessionState);
@@ -3735,6 +3734,7 @@ public final class TvInputManagerService extends SystemService {
    private void addHardwareInputLocked(
            TvInputInfo inputInfo, ComponentName component, int userId) {
        ServiceState serviceState = getServiceStateLocked(component, userId);
        if (serviceState == null) return;
        serviceState.hardwareInputMap.put(inputInfo.getId(), inputInfo);
        setPictureProfileLocked(inputInfo.getId());
        buildTvInputListLocked(userId, null);
@@ -3760,8 +3760,10 @@ public final class TvInputManagerService extends SystemService {
        }
        ComponentName component = mTvInputHardwareManager.getInputMap().get(inputId).getComponent();
        ServiceState serviceState = getServiceStateLocked(component, userId);
         if (serviceState != null) {
            serviceState.hardwareInputMap.remove(inputId);
            buildTvInputListLocked(userId, null);
        }
        mTvInputHardwareManager.removeHardwareInput(inputId);
    }

@@ -3924,7 +3926,8 @@ public final class TvInputManagerService extends SystemService {
            try {
                synchronized (mLock) {
                    ServiceState serviceState = getServiceStateLocked(mComponent, mUserId);
                    if (serviceState.hardwareInputMap.containsKey(inputInfo.getId())) {
                    if (serviceState != null && serviceState.hardwareInputMap.containsKey(
                            inputInfo.getId())) {
                        return;
                    }
                    Slog.d(TAG, "ServiceCallback: addHardwareInput, deviceId: " + deviceId +
@@ -3945,7 +3948,8 @@ public final class TvInputManagerService extends SystemService {
            try {
                synchronized (mLock) {
                    ServiceState serviceState = getServiceStateLocked(mComponent, mUserId);
                    if (serviceState.hardwareInputMap.containsKey(inputInfo.getId())) {
                    if (serviceState != null && serviceState.hardwareInputMap.containsKey(
                            inputInfo.getId())) {
                        return;
                    }
                    Slog.d(TAG, "ServiceCallback: addHdmiInput, id: " + id +