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

Commit 7ede7cbe authored by Kyeongkab.Nam's avatar Kyeongkab.Nam Committed by Henry Fang
Browse files

Add get client priority from TRM Service

Bug: 194149304
Test: atest com.android.server.tv.tunerresourcemanager
Change-Id: I9c1c57245144b3ab939353093842b281abf8a394
parent bd4a9f58
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6323,6 +6323,7 @@ package android.media.tv {
    method @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT) public boolean captureFrame(String, android.view.Surface, android.media.tv.TvStreamConfig);
    method @NonNull public java.util.List<java.lang.String> getAvailableExtensionInterfaceNames(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT) public java.util.List<android.media.tv.TvStreamConfig> getAvailableTvStreamConfigList(String);
    method public int getClientPriority(int, @Nullable String);
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_TUNED_INFO) public java.util.List<android.media.tv.TunedInfo> getCurrentTunedInfos();
    method @NonNull @RequiresPermission("android.permission.DVB_DEVICE") public java.util.List<android.media.tv.DvbDeviceInfo> getDvbDeviceList();
    method @Nullable public android.os.IBinder getExtensionInterface(@NonNull String, @NonNull String);
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ interface ITvInputManager {
            int seq, int userId);
    void releaseSession(in IBinder sessionToken, int userId);
    int getClientPid(in String sessionId);
    int getClientPriority(int useCase, in String sessionId);

    void setMainSession(in IBinder sessionToken, int userId);
    void setSurface(in IBinder sessionToken, in Surface surface, int userId);
+31 −0
Original line number Diff line number Diff line
@@ -1785,6 +1785,29 @@ public final class TvInputManager {
        return getClientPidInternal(sessionId);
    };

    /**
     * Returns a priority for the given use case type and the client's foreground or background
     * status.
     *
     * @param useCase the use case type of the client. When the given use case type is invalid,
     *        the default use case type will be used. {@see TvInputService#PriorityHintUseCaseType}.
     * @param sessionId the unique id of the session owned by the client. When {@code null},
     *        the caller will be used as a client. When the session is invalid, background status
     *        will be used as a client's status. Otherwise, TV app corresponding to the given
     *        session id will be used as a client.
     *        {@see TvInputService#onCreateSession(String, String)}.
     *
     * @return the use case priority value for the given use case type and the client's foreground
     *         or background status.
     *
     * @hide
     */
    @SystemApi
    public int getClientPriority(@TvInputService.PriorityHintUseCaseType int useCase,
            @Nullable String sessionId) {
        return getClientPriorityInternal(useCase, sessionId);
    };

    /**
     * Creates a recording {@link Session} for a given TV input.
     *
@@ -1829,6 +1852,14 @@ public final class TvInputManager {
        return clientPid;
    }

    private int getClientPriorityInternal(int useCase, String sessionId) {
        try {
            return mService.getClientPriority(useCase, sessionId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the TvStreamConfig list of the given TV input.
     *
+46 −0
Original line number Diff line number Diff line
@@ -21,9 +21,12 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.SuppressLint;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.tv.TvInputService;
import android.os.Binder;
import android.os.RemoteException;
import android.util.Log;
@@ -701,6 +704,49 @@ public class TunerResourceManager {
        }
    }

    /**
     * Returns a priority for the given use case type and the client's foreground or background
     * status.
     *
     * @param useCase the use case type of the client. When the given use case type is invalid,
     *        the default use case type will be used. {@see TvInputService#PriorityHintUseCaseType}.
     * @param pid the pid of the client. When the pid is invalid, background status will be used as
     *        a client's status. Otherwise, client's app corresponding to the given session id will
     *        be used as a client. {@see TvInputService#onCreateSession(String, String)}.
     *
     * @return the client priority..
     */
    public int getClientPriority(@TvInputService.PriorityHintUseCaseType int useCase, int pid) {
        try {
            return mService.getClientPriority(useCase, pid);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns a config priority for the given use case type and the foreground or background
     * status.
     *
     * @param useCase the use case type of the client. When the given use case type is invalid,
     *        the default use case type will be used. {@see TvInputService#PriorityHintUseCaseType}.
     * @param isForeground {@code true} if foreground, {@code false} otherwise.
     *
     * @return the config priority.
     *
     * @hide
     */
    @TestApi
    @SuppressLint("ShowingMemberInHiddenClass")
    public int getConfigPriority(@TvInputService.PriorityHintUseCaseType int useCase,
            boolean isForeground) {
        try {
            return mService.getConfigPriority(useCase, isForeground);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Interface used to receive events from TunerResourceManager.
     */
+26 −0
Original line number Diff line number Diff line
@@ -442,4 +442,30 @@ interface ITunerResourceManager {
     * guaranteed to work and may be unrecoverrable. (This should not happen.)
     */
    boolean releaseLock(in int clientId);

    /**
     * Returns a priority for the given use case type and the client's foreground or background
     * status.
     *
     * @param useCase the use case type of the client. When the given use case type is invalid,
     *        the default use case type will be used. {@see TvInputService#PriorityHintUseCaseType}.
     * @param pid the pid of the client. When the pid is invalid, background status will be used as
     *        a client's status. Otherwise, client's app corresponding to the given session id will
     *        be used as a client. {@see TvInputService#onCreateSession(String, String)}.
     *
     * @return the client priority..
     */
    int getClientPriority(int useCase, int pid);

    /**
     * Returns a config priority for the given use case type and the foreground or background
     * status.
     *
     * @param useCase the use case type of the client. When the given use case type is invalid,
     *        the default use case type will be used. {@see TvInputService#PriorityHintUseCaseType}.
     * @param isForeground {@code true} if foreground, {@code false} otherwise.
     *
     * @return the config priority.
     */
    int getConfigPriority(int useCase, boolean isForeground);
}
Loading