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

Commit df9f0a32 authored by Terry Heo's avatar Terry Heo Committed by Terry (Woncheol) Heo
Browse files

TIF: Add system API 'isSingleSessionActive()'

Bug: 16498558
Change-Id: I4f815f431051dbf786216d2b04e9737be451a508
parent ce5bbbea
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -82,4 +82,5 @@ interface ITvInputManager {
    List<TvStreamConfig> getAvailableTvStreamConfigList(in String inputId, int userId);
    boolean captureFrame(in String inputId, in Surface surface, in TvStreamConfig config,
            int userId);
    boolean isSingleSessionActive(int userId);
}
+14 −0
Original line number Diff line number Diff line
@@ -947,6 +947,20 @@ public final class TvInputManager {
        }
    }

    /**
     * Returns true if there is only a single TV input session.
     *
     * @hide
     */
    @SystemApi
    public boolean isSingleSessionActive() {
        try {
            return mService.isSingleSessionActive(mUserId);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * The Session provides the per-session functionality of TV inputs.
     * @hide
+28 −0
Original line number Diff line number Diff line
@@ -1521,6 +1521,34 @@ public final class TvInputManagerService extends SystemService {
            }
        }

        @Override
        public boolean isSingleSessionActive(int userId) throws RemoteException {
            final long identity = Binder.clearCallingIdentity();
            final int callingUid = Binder.getCallingUid();
            final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
                    userId, "isSingleSessionActive");
            try {
                synchronized (mLock) {
                    UserState userState = getUserStateLocked(resolvedUserId);
                    if (userState.sessionStateMap.size() == 1) {
                        return true;
                    }
                    else if (userState.sessionStateMap.size() == 2) {
                        SessionState[] sessionStates = userState.sessionStateMap.values().toArray(
                                new SessionState[0]);
                        // Check if there is a wrapper input.
                        if (sessionStates[0].mHardwareSessionToken != null
                                || sessionStates[1].mHardwareSessionToken != null) {
                            return true;
                        }
                    }
                    return false;
                }
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }

        @Override
        @SuppressWarnings("resource")
        protected void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {