Loading media/java/android/media/tv/tunerresourcemanager/ITunerResourceManager.aidl +9 −9 Original line number Diff line number Diff line Loading @@ -132,11 +132,11 @@ interface ITunerResourceManager { * before this request. * * @param request {@link TunerFrontendRequest} information of the current request. * @param frontendId a one-element array to return the granted frontendId. * @param frontendHandle a one-element array to return the granted frontendHandle. * * @return true if there is frontend granted. */ boolean requestFrontend(in TunerFrontendRequest request, out int[] frontendId); boolean requestFrontend(in TunerFrontendRequest request, out int[] frontendHandle); /* * Requests to share frontend with an existing client. Loading Loading @@ -240,11 +240,11 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfos(int[])} must be called before this request. * * @param request {@link TunerLnbRequest} information of the current request. * @param lnbId a one-element array to return the granted Lnb id. * @param lnbHandle a one-element array to return the granted Lnb handle. * * @return true if there is Lnb granted. */ boolean requestLnb(in TunerLnbRequest request, out int[] lnbId); boolean requestLnb(in TunerLnbRequest request, out int[] lnbHandle); /* * Notifies the TRM that the given frontend has been released. Loading @@ -254,9 +254,9 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #setFrontendInfoList(TunerFrontendInfo[])} must be called * before this release. * * @param frontendId the id of the released frontend. * @param frontendHandle the handle of the released frontend. */ void releaseFrontend(in int frontendId); void releaseFrontend(in int frontendHandle); /* * Notifies the TRM that the Demux with the given handle was released. Loading Loading @@ -288,15 +288,15 @@ interface ITunerResourceManager { void releaseCasSession(in int sessionResourceId); /* * Notifies the TRM that the Lnb with the given id was released. * Notifies the TRM that the Lnb with the given handle was released. * * <p>Client must call this whenever it releases an Lnb. * * <p><strong>Note:</strong> {@link #setLnbInfos(int[])} must be called before this release. * * @param lnbId the id of the released Tuner Lnb. * @param lnbHandle the handle of the released Tuner Lnb. */ void releaseLnb(in int lnbId); void releaseLnb(in int lnbHandle); /* * Compare two clients' priority. Loading media/java/android/media/tv/tunerresourcemanager/TunerResourceManager.java +14 −11 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ public class TunerResourceManager { private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); public static final int INVALID_RESOURCE_HANDLE = -1; public static final int INVALID_OWNER_ID = -1; /** * Tuner resource type to help generate resource handle */ Loading @@ -73,6 +74,7 @@ public class TunerResourceManager { TUNER_RESOURCE_TYPE_DESCRAMBLER, TUNER_RESOURCE_TYPE_LNB, TUNER_RESOURCE_TYPE_CAS_SESSION, TUNER_RESOURCE_TYPE_MAX, }) @Retention(RetentionPolicy.SOURCE) public @interface TunerResourceType {} Loading @@ -82,6 +84,7 @@ public class TunerResourceManager { public static final int TUNER_RESOURCE_TYPE_DESCRAMBLER = 2; public static final int TUNER_RESOURCE_TYPE_LNB = 3; public static final int TUNER_RESOURCE_TYPE_CAS_SESSION = 4; public static final int TUNER_RESOURCE_TYPE_MAX = 5; private final ITunerResourceManager mService; private final int mUserId; Loading Loading @@ -243,16 +246,16 @@ public class TunerResourceManager { * before this request. * * @param request {@link TunerFrontendRequest} information of the current request. * @param frontendId a one-element array to return the granted frontendId. If * no frontend granted, this will return {@link #INVALID_FRONTEND_ID}. * @param frontendHandle a one-element array to return the granted frontendHandle. If * no frontend granted, this will return {@link #INVALID_RESOURCE_HANDLE}. * * @return true if there is frontend granted. */ public boolean requestFrontend(@NonNull TunerFrontendRequest request, @Nullable int[] frontendId) { @Nullable int[] frontendHandle) { boolean result = false; try { result = mService.requestFrontend(request, frontendId); result = mService.requestFrontend(request, frontendHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -393,15 +396,15 @@ public class TunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfoList(int[])} must be called before this request. * * @param request {@link TunerLnbRequest} information of the current request. * @param lnbId a one-element array to return the granted Lnb id. * If no Lnb granted, this will return {@link #INVALID_LNB_ID}. * @param lnbHandle a one-element array to return the granted Lnb handle. * If no Lnb granted, this will return {@link #INVALID_RESOURCE_HANDLE}. * * @return true if there is Lnb granted. */ public boolean requestLnb(@NonNull TunerLnbRequest request, @NonNull int[] lnbId) { public boolean requestLnb(@NonNull TunerLnbRequest request, @NonNull int[] lnbHandle) { boolean result = false; try { result = mService.requestLnb(request, lnbId); result = mService.requestLnb(request, lnbHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -481,11 +484,11 @@ public class TunerResourceManager { * * <p><strong>Note:</strong> {@link #setLnbInfoList(int[])} must be called before this release. * * @param lnbId the id of the released Tuner Lnb. * @param lnbHandle the handle of the released Tuner Lnb. */ public void releaseLnb(int lnbId) { public void releaseLnb(int lnbHandle) { try { mService.releaseLnb(lnbId); mService.releaseLnb(lnbHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading services/core/java/com/android/server/tv/tunerresourcemanager/ClientProfile.java +29 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,11 @@ public final class ClientProfile { */ private Set<Integer> mUsingFrontendIds = new HashSet<>(); /** * List of the Lnb ids that are used by the current client. */ private Set<Integer> mUsingLnbIds = new HashSet<>(); /** * Optional arbitrary priority value given by the client. * Loading Loading @@ -146,6 +151,30 @@ public final class ClientProfile { mUsingFrontendIds.remove(frontendId); } /** * Set when the client starts to use an Lnb. * * @param lnbId being used. */ public void useLnb(int lnbId) { mUsingLnbIds.add(lnbId); } public Set<Integer> getInUseLnbIds() { return mUsingLnbIds; } /** * Called when the client released an lnb. * * <p>This could happen when client resource reclaimed. * * @param lnbId being released. */ public void releaseLnb(int lnbId) { mUsingLnbIds.remove(lnbId); } @Override public String toString() { return "ClientProfile[id=" + this.mId + ", tvInputSessionId=" + this.mTvInputSessionId Loading services/core/java/com/android/server/tv/tunerresourcemanager/FrontendResource.java +5 −54 Original line number Diff line number Diff line Loading @@ -27,14 +27,7 @@ import java.util.Set; * * @hide */ public final class FrontendResource { public static final int INVALID_OWNER_ID = -1; /** * Id of the current frontend. Should not be changed and should be aligned with the driver level * implementation. */ private final int mId; public final class FrontendResource extends TunerResourceBasic { /** * see {@link android.media.tv.tuner.frontend.FrontendSettings.Type} Loading @@ -51,28 +44,12 @@ public final class FrontendResource { */ private Set<Integer> mExclusiveGroupMemberFeIds = new HashSet<>(); /** * If the current resource is in use. Once resources under the same exclusive group id is in use * all other resources in the same group would be considered in use. */ private boolean mIsInUse; /** * The owner client's id if this resource is occupied. Owner of the resource under the same * exclusive group id would be considered as the whole group's owner. */ private int mOwnerClientId = INVALID_OWNER_ID; private FrontendResource(Builder builder) { this.mId = builder.mId; super(builder); this.mType = builder.mType; this.mExclusiveGroupId = builder.mExclusiveGroupId; } public int getId() { return mId; } public int getType() { return mType; } Loading Loading @@ -112,32 +89,6 @@ public final class FrontendResource { mExclusiveGroupMemberFeIds.remove(id); } public boolean isInUse() { return mIsInUse; } public int getOwnerClientId() { return mOwnerClientId; } /** * Set an owner client on the resource. * * @param ownerClientId the id of the owner client. */ public void setOwner(int ownerClientId) { mIsInUse = true; mOwnerClientId = ownerClientId; } /** * Remove an owner client from the resource. */ public void removeOwner() { mIsInUse = false; mOwnerClientId = INVALID_OWNER_ID; } @Override public String toString() { return "FrontendResource[id=" + this.mId + ", type=" + this.mType Loading @@ -149,13 +100,12 @@ public final class FrontendResource { /** * Builder class for {@link FrontendResource}. */ public static class Builder { private final int mId; public static class Builder extends TunerResourceBasic.Builder { @Type private int mType; private int mExclusiveGroupId; Builder(int id) { this.mId = id; super(id); } /** Loading Loading @@ -183,6 +133,7 @@ public final class FrontendResource { * * @return {@link FrontendResource}. */ @Override public FrontendResource build() { FrontendResource frontendResource = new FrontendResource(this); return frontendResource; Loading services/core/java/com/android/server/tv/tunerresourcemanager/LnbResource.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.tv.tunerresourcemanager; /** * An Lnb resource object used by the Tuner Resource Manager to record the tuner Lnb * information. * * @hide */ public final class LnbResource extends TunerResourceBasic { private LnbResource(Builder builder) { super(builder); } @Override public String toString() { return "LnbResource[id=" + this.mId + ", isInUse=" + this.mIsInUse + ", ownerClientId=" + this.mOwnerClientId + "]"; } /** * Builder class for {@link LnbResource}. */ public static class Builder extends TunerResourceBasic.Builder { Builder(int id) { super(id); } /** * Build a {@link LnbResource}. * * @return {@link LnbResource}. */ @Override public LnbResource build() { LnbResource lnb = new LnbResource(this); return lnb; } } } Loading
media/java/android/media/tv/tunerresourcemanager/ITunerResourceManager.aidl +9 −9 Original line number Diff line number Diff line Loading @@ -132,11 +132,11 @@ interface ITunerResourceManager { * before this request. * * @param request {@link TunerFrontendRequest} information of the current request. * @param frontendId a one-element array to return the granted frontendId. * @param frontendHandle a one-element array to return the granted frontendHandle. * * @return true if there is frontend granted. */ boolean requestFrontend(in TunerFrontendRequest request, out int[] frontendId); boolean requestFrontend(in TunerFrontendRequest request, out int[] frontendHandle); /* * Requests to share frontend with an existing client. Loading Loading @@ -240,11 +240,11 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfos(int[])} must be called before this request. * * @param request {@link TunerLnbRequest} information of the current request. * @param lnbId a one-element array to return the granted Lnb id. * @param lnbHandle a one-element array to return the granted Lnb handle. * * @return true if there is Lnb granted. */ boolean requestLnb(in TunerLnbRequest request, out int[] lnbId); boolean requestLnb(in TunerLnbRequest request, out int[] lnbHandle); /* * Notifies the TRM that the given frontend has been released. Loading @@ -254,9 +254,9 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #setFrontendInfoList(TunerFrontendInfo[])} must be called * before this release. * * @param frontendId the id of the released frontend. * @param frontendHandle the handle of the released frontend. */ void releaseFrontend(in int frontendId); void releaseFrontend(in int frontendHandle); /* * Notifies the TRM that the Demux with the given handle was released. Loading Loading @@ -288,15 +288,15 @@ interface ITunerResourceManager { void releaseCasSession(in int sessionResourceId); /* * Notifies the TRM that the Lnb with the given id was released. * Notifies the TRM that the Lnb with the given handle was released. * * <p>Client must call this whenever it releases an Lnb. * * <p><strong>Note:</strong> {@link #setLnbInfos(int[])} must be called before this release. * * @param lnbId the id of the released Tuner Lnb. * @param lnbHandle the handle of the released Tuner Lnb. */ void releaseLnb(in int lnbId); void releaseLnb(in int lnbHandle); /* * Compare two clients' priority. Loading
media/java/android/media/tv/tunerresourcemanager/TunerResourceManager.java +14 −11 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ public class TunerResourceManager { private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); public static final int INVALID_RESOURCE_HANDLE = -1; public static final int INVALID_OWNER_ID = -1; /** * Tuner resource type to help generate resource handle */ Loading @@ -73,6 +74,7 @@ public class TunerResourceManager { TUNER_RESOURCE_TYPE_DESCRAMBLER, TUNER_RESOURCE_TYPE_LNB, TUNER_RESOURCE_TYPE_CAS_SESSION, TUNER_RESOURCE_TYPE_MAX, }) @Retention(RetentionPolicy.SOURCE) public @interface TunerResourceType {} Loading @@ -82,6 +84,7 @@ public class TunerResourceManager { public static final int TUNER_RESOURCE_TYPE_DESCRAMBLER = 2; public static final int TUNER_RESOURCE_TYPE_LNB = 3; public static final int TUNER_RESOURCE_TYPE_CAS_SESSION = 4; public static final int TUNER_RESOURCE_TYPE_MAX = 5; private final ITunerResourceManager mService; private final int mUserId; Loading Loading @@ -243,16 +246,16 @@ public class TunerResourceManager { * before this request. * * @param request {@link TunerFrontendRequest} information of the current request. * @param frontendId a one-element array to return the granted frontendId. If * no frontend granted, this will return {@link #INVALID_FRONTEND_ID}. * @param frontendHandle a one-element array to return the granted frontendHandle. If * no frontend granted, this will return {@link #INVALID_RESOURCE_HANDLE}. * * @return true if there is frontend granted. */ public boolean requestFrontend(@NonNull TunerFrontendRequest request, @Nullable int[] frontendId) { @Nullable int[] frontendHandle) { boolean result = false; try { result = mService.requestFrontend(request, frontendId); result = mService.requestFrontend(request, frontendHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -393,15 +396,15 @@ public class TunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfoList(int[])} must be called before this request. * * @param request {@link TunerLnbRequest} information of the current request. * @param lnbId a one-element array to return the granted Lnb id. * If no Lnb granted, this will return {@link #INVALID_LNB_ID}. * @param lnbHandle a one-element array to return the granted Lnb handle. * If no Lnb granted, this will return {@link #INVALID_RESOURCE_HANDLE}. * * @return true if there is Lnb granted. */ public boolean requestLnb(@NonNull TunerLnbRequest request, @NonNull int[] lnbId) { public boolean requestLnb(@NonNull TunerLnbRequest request, @NonNull int[] lnbHandle) { boolean result = false; try { result = mService.requestLnb(request, lnbId); result = mService.requestLnb(request, lnbHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -481,11 +484,11 @@ public class TunerResourceManager { * * <p><strong>Note:</strong> {@link #setLnbInfoList(int[])} must be called before this release. * * @param lnbId the id of the released Tuner Lnb. * @param lnbHandle the handle of the released Tuner Lnb. */ public void releaseLnb(int lnbId) { public void releaseLnb(int lnbHandle) { try { mService.releaseLnb(lnbId); mService.releaseLnb(lnbHandle); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
services/core/java/com/android/server/tv/tunerresourcemanager/ClientProfile.java +29 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,11 @@ public final class ClientProfile { */ private Set<Integer> mUsingFrontendIds = new HashSet<>(); /** * List of the Lnb ids that are used by the current client. */ private Set<Integer> mUsingLnbIds = new HashSet<>(); /** * Optional arbitrary priority value given by the client. * Loading Loading @@ -146,6 +151,30 @@ public final class ClientProfile { mUsingFrontendIds.remove(frontendId); } /** * Set when the client starts to use an Lnb. * * @param lnbId being used. */ public void useLnb(int lnbId) { mUsingLnbIds.add(lnbId); } public Set<Integer> getInUseLnbIds() { return mUsingLnbIds; } /** * Called when the client released an lnb. * * <p>This could happen when client resource reclaimed. * * @param lnbId being released. */ public void releaseLnb(int lnbId) { mUsingLnbIds.remove(lnbId); } @Override public String toString() { return "ClientProfile[id=" + this.mId + ", tvInputSessionId=" + this.mTvInputSessionId Loading
services/core/java/com/android/server/tv/tunerresourcemanager/FrontendResource.java +5 −54 Original line number Diff line number Diff line Loading @@ -27,14 +27,7 @@ import java.util.Set; * * @hide */ public final class FrontendResource { public static final int INVALID_OWNER_ID = -1; /** * Id of the current frontend. Should not be changed and should be aligned with the driver level * implementation. */ private final int mId; public final class FrontendResource extends TunerResourceBasic { /** * see {@link android.media.tv.tuner.frontend.FrontendSettings.Type} Loading @@ -51,28 +44,12 @@ public final class FrontendResource { */ private Set<Integer> mExclusiveGroupMemberFeIds = new HashSet<>(); /** * If the current resource is in use. Once resources under the same exclusive group id is in use * all other resources in the same group would be considered in use. */ private boolean mIsInUse; /** * The owner client's id if this resource is occupied. Owner of the resource under the same * exclusive group id would be considered as the whole group's owner. */ private int mOwnerClientId = INVALID_OWNER_ID; private FrontendResource(Builder builder) { this.mId = builder.mId; super(builder); this.mType = builder.mType; this.mExclusiveGroupId = builder.mExclusiveGroupId; } public int getId() { return mId; } public int getType() { return mType; } Loading Loading @@ -112,32 +89,6 @@ public final class FrontendResource { mExclusiveGroupMemberFeIds.remove(id); } public boolean isInUse() { return mIsInUse; } public int getOwnerClientId() { return mOwnerClientId; } /** * Set an owner client on the resource. * * @param ownerClientId the id of the owner client. */ public void setOwner(int ownerClientId) { mIsInUse = true; mOwnerClientId = ownerClientId; } /** * Remove an owner client from the resource. */ public void removeOwner() { mIsInUse = false; mOwnerClientId = INVALID_OWNER_ID; } @Override public String toString() { return "FrontendResource[id=" + this.mId + ", type=" + this.mType Loading @@ -149,13 +100,12 @@ public final class FrontendResource { /** * Builder class for {@link FrontendResource}. */ public static class Builder { private final int mId; public static class Builder extends TunerResourceBasic.Builder { @Type private int mType; private int mExclusiveGroupId; Builder(int id) { this.mId = id; super(id); } /** Loading Loading @@ -183,6 +133,7 @@ public final class FrontendResource { * * @return {@link FrontendResource}. */ @Override public FrontendResource build() { FrontendResource frontendResource = new FrontendResource(this); return frontendResource; Loading
services/core/java/com/android/server/tv/tunerresourcemanager/LnbResource.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.tv.tunerresourcemanager; /** * An Lnb resource object used by the Tuner Resource Manager to record the tuner Lnb * information. * * @hide */ public final class LnbResource extends TunerResourceBasic { private LnbResource(Builder builder) { super(builder); } @Override public String toString() { return "LnbResource[id=" + this.mId + ", isInUse=" + this.mIsInUse + ", ownerClientId=" + this.mOwnerClientId + "]"; } /** * Builder class for {@link LnbResource}. */ public static class Builder extends TunerResourceBasic.Builder { Builder(int id) { super(id); } /** * Build a {@link LnbResource}. * * @return {@link LnbResource}. */ @Override public LnbResource build() { LnbResource lnb = new LnbResource(this); return lnb; } } }