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

Commit b1a8ec5f authored by Amy Zhang's avatar Amy Zhang
Browse files

Use Tuner Resource Handle instead of Resource Id in TunerResourceManager

Test: atest TunerResourceManagerServiceTest
Bug: 170684039
Change-Id: I5dcf1ee97c35be7f95adeeb5afee9266d0b845be
parent 9a9ed604
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public final class TunerFrontendInfo implements Parcelable {
                }
            };

    private final int mId;
    private final int mHandle;

    @Type
    private final int mFrontendType;
@@ -66,7 +66,7 @@ public final class TunerFrontendInfo implements Parcelable {
    private final int mExclusiveGroupId;

    private TunerFrontendInfo(@NonNull Parcel source) {
        mId = source.readInt();
        mHandle = source.readInt();
        mFrontendType = source.readInt();
        mExclusiveGroupId = source.readInt();
    }
@@ -74,25 +74,26 @@ public final class TunerFrontendInfo implements Parcelable {
    /**
     * Constructs a new {@link TunerFrontendInfo} with the given parameters.
     *
     * @param handle frontend handle
     * @param frontendType the type of the frontend.
     * @param exclusiveGroupId the group id of the frontend. FE with the same
                               group id can't function at the same time.
     */
    public TunerFrontendInfo(int id,
    public TunerFrontendInfo(int handle,
                             @Type int frontendType,
                             int exclusiveGroupId) {
        mId = id;
        mHandle = handle;
        mFrontendType = frontendType;
        mExclusiveGroupId = exclusiveGroupId;
    }

    /**
     * Returns the frontend id.
     * Returns the frontend handle.
     *
     * @return the value of the frontend id.
     * @return the value of the frontend handle.
     */
    public int getId() {
        return mId;
    public int getHandle() {
        return mHandle;
    }

    /**
@@ -125,7 +126,7 @@ public final class TunerFrontendInfo implements Parcelable {
    @Override
    public String toString() {
        StringBuilder b = new StringBuilder(128);
        b.append("TunerFrontendInfo {id=").append(mId);
        b.append("TunerFrontendInfo {handle=").append(mHandle);
        b.append(", frontendType=").append(mFrontendType);
        b.append(", exclusiveGroupId=").append(mExclusiveGroupId);
        b.append("}");
@@ -134,7 +135,7 @@ public final class TunerFrontendInfo implements Parcelable {

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mId);
        dest.writeInt(mHandle);
        dest.writeInt(mFrontendType);
        dest.writeInt(mExclusiveGroupId);
    }
+20 −20
Original line number Diff line number Diff line
@@ -63,9 +63,9 @@ public final class ClientProfile {
    private int mNiceValue;

    /**
     * List of the frontend ids that are used by the current client.
     * List of the frontend handles that are used by the current client.
     */
    private Set<Integer> mUsingFrontendIds = new HashSet<>();
    private Set<Integer> mUsingFrontendHandles = new HashSet<>();

    /**
     * List of the client ids that share frontend with the current client.
@@ -73,9 +73,9 @@ public final class ClientProfile {
    private Set<Integer> mShareFeClientIds = new HashSet<>();

    /**
     * List of the Lnb ids that are used by the current client.
     * List of the Lnb handles that are used by the current client.
     */
    private Set<Integer> mUsingLnbIds = new HashSet<>();
    private Set<Integer> mUsingLnbHandles = new HashSet<>();

    /**
     * List of the Cas system ids that are used by the current client.
@@ -139,10 +139,10 @@ public final class ClientProfile {
    /**
     * Set when the client starts to use a frontend.
     *
     * @param frontendId being used.
     * @param frontendHandle being used.
     */
    public void useFrontend(int frontendId) {
        mUsingFrontendIds.add(frontendId);
    public void useFrontend(int frontendHandle) {
        mUsingFrontendHandles.add(frontendHandle);
    }

    /**
@@ -163,8 +163,8 @@ public final class ClientProfile {
        mShareFeClientIds.remove(clientId);
    }

    public Set<Integer> getInUseFrontendIds() {
        return mUsingFrontendIds;
    public Set<Integer> getInUseFrontendHandles() {
        return mUsingFrontendHandles;
    }

    public Set<Integer> getShareFeClientIds() {
@@ -175,30 +175,30 @@ public final class ClientProfile {
     * Called when the client released a frontend.
     */
    public void releaseFrontend() {
        mUsingFrontendIds.clear();
        mUsingFrontendHandles.clear();
        mShareFeClientIds.clear();
    }

    /**
     * Set when the client starts to use an Lnb.
     *
     * @param lnbId being used.
     * @param lnbHandle being used.
     */
    public void useLnb(int lnbId) {
        mUsingLnbIds.add(lnbId);
    public void useLnb(int lnbHandle) {
        mUsingLnbHandles.add(lnbHandle);
    }

    public Set<Integer> getInUseLnbIds() {
        return mUsingLnbIds;
    public Set<Integer> getInUseLnbHandles() {
        return mUsingLnbHandles;
    }

    /**
     * Called when the client released an lnb.
     *
     * @param lnbId being released.
     * @param lnbHandle being released.
     */
    public void releaseLnb(int lnbId) {
        mUsingLnbIds.remove(lnbId);
    public void releaseLnb(int lnbHandle) {
        mUsingLnbHandles.remove(lnbHandle);
    }

    /**
@@ -225,9 +225,9 @@ public final class ClientProfile {
     * Called to reclaim all the resources being used by the current client.
     */
    public void reclaimAllResources() {
        mUsingFrontendIds.clear();
        mUsingFrontendHandles.clear();
        mShareFeClientIds.clear();
        mUsingLnbIds.clear();
        mUsingLnbHandles.clear();
        mUsingCasSystemId = INVALID_RESOURCE_ID;
    }

+19 −19
Original line number Diff line number Diff line
@@ -40,9 +40,9 @@ public final class FrontendResource extends TunerResourceBasic {
    private final int mExclusiveGroupId;

    /**
     * An array to save all the FE ids under the same exclisive group.
     * An array to save all the FE handles under the same exclisive group.
     */
    private Set<Integer> mExclusiveGroupMemberFeIds = new HashSet<>();
    private Set<Integer> mExclusiveGroupMemberHandles = new HashSet<>();

    private FrontendResource(Builder builder) {
        super(builder);
@@ -58,26 +58,26 @@ public final class FrontendResource extends TunerResourceBasic {
        return mExclusiveGroupId;
    }

    public Set<Integer> getExclusiveGroupMemberFeIds() {
        return mExclusiveGroupMemberFeIds;
    public Set<Integer> getExclusiveGroupMemberFeHandles() {
        return mExclusiveGroupMemberHandles;
    }

    /**
     * Add one id into the exclusive group member id collection.
     * Add one handle into the exclusive group member handle collection.
     *
     * @param id the id to be added.
     * @param handle the handle to be added.
     */
    public void addExclusiveGroupMemberFeId(int id) {
        mExclusiveGroupMemberFeIds.add(id);
    public void addExclusiveGroupMemberFeHandle(int handle) {
        mExclusiveGroupMemberHandles.add(handle);
    }

    /**
     * Add one id collection to the exclusive group member id collection.
     * Add one handle collection to the exclusive group member handle collection.
     *
     * @param ids the id collection to be added.
     * @param handles the handle collection to be added.
     */
    public void addExclusiveGroupMemberFeIds(Collection<Integer> ids) {
        mExclusiveGroupMemberFeIds.addAll(ids);
    public void addExclusiveGroupMemberFeHandles(Collection<Integer> handles) {
        mExclusiveGroupMemberHandles.addAll(handles);
    }

    /**
@@ -85,15 +85,15 @@ public final class FrontendResource extends TunerResourceBasic {
     *
     * @param id the id to be removed.
     */
    public void removeExclusiveGroupMemberFeId(int id) {
        mExclusiveGroupMemberFeIds.remove(id);
    public void removeExclusiveGroupMemberFeId(int handle) {
        mExclusiveGroupMemberHandles.remove(handle);
    }

    @Override
    public String toString() {
        return "FrontendResource[id=" + this.mId + ", type=" + this.mType
                + ", exclusiveGId=" + this.mExclusiveGroupId + ", exclusiveGMemeberIds="
                + this.mExclusiveGroupMemberFeIds
        return "FrontendResource[handle=" + this.mHandle + ", type=" + this.mType
                + ", exclusiveGId=" + this.mExclusiveGroupId + ", exclusiveGMemeberHandles="
                + this.mExclusiveGroupMemberHandles
                + ", isInUse=" + this.mIsInUse + ", ownerClientId=" + this.mOwnerClientId + "]";
    }

@@ -104,8 +104,8 @@ public final class FrontendResource extends TunerResourceBasic {
        @Type private int mType;
        private int mExclusiveGroupId;

        Builder(int id) {
            super(id);
        Builder(int handle) {
            super(handle);
        }

        /**
+3 −3
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ public final class LnbResource extends TunerResourceBasic {

    @Override
    public String toString() {
        return "LnbResource[id=" + this.mId
        return "LnbResource[handle=" + this.mHandle
                + ", isInUse=" + this.mIsInUse + ", ownerClientId=" + this.mOwnerClientId + "]";
    }

@@ -38,8 +38,8 @@ public final class LnbResource extends TunerResourceBasic {
     */
    public static class Builder extends TunerResourceBasic.Builder {

        Builder(int id) {
            super(id);
        Builder(int handle) {
            super(handle);
        }

        /**
+9 −9
Original line number Diff line number Diff line
@@ -25,10 +25,10 @@ import static android.media.tv.tunerresourcemanager.TunerResourceManager.INVALID
 */
public class TunerResourceBasic {
    /**
     * Id of the current resource. Should not be changed and should be aligned with the driver level
     * implementation.
     * Handle of the current resource. Should not be changed and should be aligned with the driver
     * level implementation.
     */
    final int mId;
    final int mHandle;

    /**
     * If the current resource is in use.
@@ -41,11 +41,11 @@ public class TunerResourceBasic {
    int mOwnerClientId = INVALID_OWNER_ID;

    TunerResourceBasic(Builder builder) {
        this.mId = builder.mId;
        this.mHandle = builder.mHandle;
    }

    public int getId() {
        return mId;
    public int getHandle() {
        return mHandle;
    }

    public boolean isInUse() {
@@ -78,10 +78,10 @@ public class TunerResourceBasic {
     * Builder class for {@link TunerResourceBasic}.
     */
    public static class Builder {
        private final int mId;
        private final int mHandle;

        Builder(int id) {
            this.mId = id;
        Builder(int handle) {
            this.mHandle = handle;
        }

        /**
Loading