Moving TRM under a separate package

Change the TunerResourceManagerListener to ResourcesReclaimListener

Test: make framework-media-tv-trm-sources
Bug:
Change-Id: Id49bfead1b08b4d01adb1a3ae9f354da6d1a75b1
This commit is contained in:
Amy
2020-02-12 17:47:19 -08:00
parent 6988e11c8d
commit 92726fb752
19 changed files with 81 additions and 56 deletions

View File

@@ -109,8 +109,8 @@ import android.media.session.MediaSessionManager;
import android.media.soundtrigger.SoundTriggerManager;
import android.media.tv.ITvInputManager;
import android.media.tv.TvInputManager;
import android.media.tv.tuner.ITunerResourceManager;
import android.media.tv.tuner.TunerResourceManager;
import android.media.tv.tunerresourcemanager.ITunerResourceManager;
import android.media.tv.tunerresourcemanager.TunerResourceManager;
import android.net.ConnectivityDiagnosticsManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityThread;

View File

@@ -0,0 +1,17 @@
filegroup {
name: "framework-media-tv-tunerresourcemanager-sources",
srcs: [
"*.java",
"*.aidl",
],
path: ".",
}
java_library {
name: "framework-media-tv-trm-sources",
srcs: [":framework-media-tv-tunerresourcemanager-sources"],
installable: true,
visibility: [
"//frameworks/base",
],
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
/**
* A wrapper of a cas session requests that contains all the request info of the client.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.annotation.NonNull;
import android.os.Parcel;

View File

@@ -14,20 +14,20 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
/**
* Interface to receive callbacks from ITunerResourceManager.
*
* @hide
*/
oneway interface ITunerResourceManagerListener {
oneway interface IResourcesReclaimListener {
/*
* TRM invokes this method when the client's resources need to be reclaimed.
*
* <p>This method is implemented in Tuner Framework to take the reclaiming
* actions. It's a synchonized call. TRM would wait on the call to finish
* actions. It's a synchronous call. TRM would wait on the call to finish
* then grant the resource.
*/
void onResourcesReclaim();
void onReclaimResources();
}

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.media.tv.tuner.CasSessionRequest;
import android.media.tv.tuner.ITunerResourceManagerListener;
import android.media.tv.tuner.ResourceClientProfile;
import android.media.tv.tuner.TunerFrontendInfo;
import android.media.tv.tuner.TunerFrontendRequest;
import android.media.tv.tuner.TunerLnbRequest;
import android.media.tv.tunerresourcemanager.CasSessionRequest;
import android.media.tv.tunerresourcemanager.IResourcesReclaimListener;
import android.media.tv.tunerresourcemanager.ResourceClientProfile;
import android.media.tv.tunerresourcemanager.TunerFrontendInfo;
import android.media.tv.tunerresourcemanager.TunerFrontendRequest;
import android.media.tv.tunerresourcemanager.TunerLnbRequest;
/**
* Interface of the Tuner Resource Manager. It manages resources used by TV Tuners.
@@ -37,10 +37,10 @@ import android.media.tv.tuner.TunerLnbRequest;
* <ul>
* <li>Tuner Java/MediaCas/TIF update resources of the current device with TRM.
* <li>Client registers its profile through {@link #registerClientProfile(ResourceClientProfile,
* ITunerResourceManagerListener, int[])}.
* IResourcesReclaimListener, int[])}.
* <li>Client requests resources through request APIs.
* <li>If the resource needs to be handed to a higher priority client from a lower priority
* one, TRM calls ITunerResourceManagerListener registered by the lower priority client to release
* one, TRM calls IResourcesReclaimListener registered by the lower priority client to release
* the resource.
* <ul>
*
@@ -53,13 +53,13 @@ interface ITunerResourceManager {
* <p>The profile contains information that can show the base priority score of the client.
*
* @param profile {@link ResourceClientProfile} profile of the current client
* @param listener {@link ITunerResourceManagerListener} a callback to
* @param listener {@link IResourcesReclaimListener} a callback to
* reclaim clients' resources when needed.
* @param clientId returns a clientId from the resource manager when the
* the client registers its profile.
*/
void registerClientProfile(in ResourceClientProfile profile,
ITunerResourceManagerListener listener, out int[] clientId);
IResourcesReclaimListener listener, out int[] clientId);
/*
* This API is used by the client to unregister their profile with the Tuner Resource manager.
@@ -119,7 +119,7 @@ interface ITunerResourceManager {
*
* <li>If no Frontend is available but the current request info can show higher priority than
* other uses of Frontend, the API will send
* {@link ITunerResourceManagerListener#onResourcesReclaim()} to the {@link Tuner}. Tuner would
* {@link IResourcesReclaimListener#onReclaimResources()} to the {@link Tuner}. Tuner would
* handle the resource reclaim on the holder of lower priority and notify the holder of its
* resource loss.
*
@@ -157,7 +157,7 @@ interface ITunerResourceManager {
*
* <li>If no Cas session is available but the current request info can show higher priority than
* other uses of the sessions under the requested CAS system, the API will send
* {@link ITunerResourceManagerCallback#onResourcesReclaim()} to the {@link Tuner}. Tuner would
* {@link ITunerResourceManagerCallback#onReclaimResources()} to the {@link Tuner}. Tuner would
* handle the resource reclaim on the holder of lower priority and notify the holder of its
* resource loss.
*
@@ -181,7 +181,7 @@ interface ITunerResourceManager {
* <li>If there is Lnb available, the API would send the id back.
*
* <li>If no Lnb is available but the current request has a higher priority than other uses of
* lnbs, the API will send {@link ITunerResourceManagerCallback#onResourcesReclaim()} to the
* lnbs, the API will send {@link ITunerResourceManagerCallback#onReclaimResources()} to the
* {@link Tuner}. Tuner would handle the resource reclaim on the holder of lower priority and
* notify the holder of its resource loss.
*

View File

@@ -0,0 +1,4 @@
amyjojo@google.com
nchalko@google.com
quxiangfang@google.com
shubang@google.com

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
/**
* A profile of a resource client. This profile is used to register the client info

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.annotation.NonNull;
import android.os.Parcel;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
/**
* Simple container of the FrontendInfo struct defined in the TunerHAL 1.0 interface.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.annotation.NonNull;
import android.media.tv.tuner.frontend.FrontendSettings.Type;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
/**
* Information required to request a Tuner Frontend.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.annotation.NonNull;
import android.media.tv.tuner.frontend.FrontendSettings.Type;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
/**
* Information required to request a Tuner Lnb.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.annotation.NonNull;
import android.os.Parcel;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package android.media.tv.tuner;
package android.media.tv.tunerresourcemanager;
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
@@ -42,10 +42,10 @@ import java.util.concurrent.Executor;
* <ul>
* <li>Tuner Java/MediaCas/TIF update resources of the current device with TRM.
* <li>Client registers its profile through {@link #registerClientProfile(ResourceClientProfile,
* Executor, ResourceListener, int[])}.
* Executor, ResourcesReclaimListener, int[])}.
* <li>Client requests resources through request APIs.
* <li>If the resource needs to be handed to a higher priority client from a lower priority
* one, TRM calls ITunerResourceManagerListener registered by the lower priority client to release
* one, TRM calls IResourcesReclaimListener registered by the lower priority client to release
* the resource.
* <ul>
*
@@ -85,25 +85,26 @@ public class TunerResourceManager {
* @param profile {@link ResourceClientProfile} profile of the current client. Undefined use
* case would cause IllegalArgumentException.
* @param executor the executor on which the listener would be invoked.
* @param listener {@link ResourceListener} callback to reclaim clients' resources when needed.
* @param listener {@link ResourcesReclaimListener} callback to reclaim clients' resources when
* needed.
* @param clientId returned a clientId from the resource manager when the
* the client registeres.
* @throws IllegalArgumentException when {@code profile} contains undefined use case.
*/
public void registerClientProfile(@NonNull ResourceClientProfile profile,
@NonNull @CallbackExecutor Executor executor,
@NonNull ResourceListener listener,
@NonNull ResourcesReclaimListener listener,
@NonNull int[] clientId) {
// TODO: throw new IllegalArgumentException("Unknown client use case")
// when the use case is not defined.
try {
mService.registerClientProfile(profile,
new ITunerResourceManagerListener.Stub() {
new IResourcesReclaimListener.Stub() {
@Override
public void onResourcesReclaim() {
public void onReclaimResources() {
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> listener.onResourcesReclaim());
executor.execute(() -> listener.onReclaimResources());
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -214,7 +215,7 @@ public class TunerResourceManager {
*
* <li>If no Frontend is available but the current request info can show higher priority than
* other uses of Frontend, the API will send
* {@link ITunerResourceManagerListener#onResourcesReclaim()} to the {@link Tuner}. Tuner would
* {@link IResourcesReclaimListener#onReclaimResources()} to the {@link Tuner}. Tuner would
* handle the resource reclaim on the holder of lower priority and notify the holder of its
* resource loss.
*
@@ -267,7 +268,7 @@ public class TunerResourceManager {
*
* <li>If no Cas system is available but the current request info can show higher priority than
* other uses of the cas sessions under the requested cas system, the API will send
* {@link ITunerResourceManagerListener#onResourcesReclaim()} to the {@link Tuner}. Tuner would
* {@link IResourcesReclaimListener#onReclaimResources()} to the {@link Tuner}. Tuner would
* handle the resource reclaim on the holder of lower priority and notify the holder of its
* resource loss.
*
@@ -300,7 +301,7 @@ public class TunerResourceManager {
* <li>If there is Lnb available, the API would send the id back.
*
* <li>If no Lnb is available but the current request has a higher priority than other uses of
* lnbs, the API will send {@link ITunerResourceManagerListener#onResourcesReclaim()} to the
* lnbs, the API will send {@link IResourcesReclaimListener#onReclaimResources()} to the
* {@link Tuner}. Tuner would handle the resource reclaim on the holder of lower priority and
* notify the holder of its resource loss.
*
@@ -398,10 +399,10 @@ public class TunerResourceManager {
/**
* Interface used to receive events from TunerResourceManager.
*/
public abstract static class ResourceListener {
public abstract static class ResourcesReclaimListener {
/*
* To reclaim all the resources of the callack owner.
*/
public abstract void onResourcesReclaim();
public abstract void onReclaimResources();
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.server.tv.tuner;
package com.android.server.tv.tunerresourcemanager;
/**
* A client profile object used by the Tuner Resource Manager to record the registered clients'
@@ -122,6 +122,9 @@ public final class ClientProfile {
+ this.mUseCase + ", " + this.mProcessId;
}
/**
* Builder class for {@link ClientProfile}.
*/
public static class ClientProfileBuilder {
private final int mClientId;
private String mTvInputSessionId;

View File

@@ -14,20 +14,20 @@
* limitations under the License.
*/
package com.android.server.tv.tuner;
package com.android.server.tv.tunerresourcemanager;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.media.tv.TvInputManager;
import android.media.tv.tuner.CasSessionRequest;
import android.media.tv.tuner.ITunerResourceManager;
import android.media.tv.tuner.ITunerResourceManagerListener;
import android.media.tv.tuner.ResourceClientProfile;
import android.media.tv.tuner.TunerFrontendInfo;
import android.media.tv.tuner.TunerFrontendRequest;
import android.media.tv.tuner.TunerLnbRequest;
import android.media.tv.tuner.TunerResourceManager;
import android.media.tv.tunerresourcemanager.CasSessionRequest;
import android.media.tv.tunerresourcemanager.IResourcesReclaimListener;
import android.media.tv.tunerresourcemanager.ITunerResourceManager;
import android.media.tv.tunerresourcemanager.ResourceClientProfile;
import android.media.tv.tunerresourcemanager.TunerFrontendInfo;
import android.media.tv.tunerresourcemanager.TunerFrontendRequest;
import android.media.tv.tunerresourcemanager.TunerLnbRequest;
import android.media.tv.tunerresourcemanager.TunerResourceManager;
import android.os.RemoteException;
import android.util.Log;
import android.util.Slog;
@@ -48,7 +48,7 @@ public class TunerResourceManagerService extends SystemService {
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private SparseArray<ClientProfile> mClientProfiles = new SparseArray<>();
private SparseArray<ITunerResourceManagerListener> mListeners = new SparseArray<>();
private SparseArray<IResourcesReclaimListener> mListeners = new SparseArray<>();
private int mNextUnusedFrontendId = 0;
private List<Integer> mReleasedClientId = new ArrayList<Integer>();
private List<Integer> mAvailableFrontendIds = new ArrayList<Integer>();
@@ -69,7 +69,7 @@ public class TunerResourceManagerService extends SystemService {
private final class BinderService extends ITunerResourceManager.Stub {
@Override
public void registerClientProfile(@NonNull ResourceClientProfile profile,
@NonNull ITunerResourceManagerListener listener,
@NonNull IResourcesReclaimListener listener,
@NonNull int[] clientId) {
if (DEBUG) {
Slog.d(TAG, "registerClientProfile(clientProfile=" + profile + ")");

View File

@@ -162,7 +162,7 @@ import com.android.server.textservices.TextServicesManagerService;
import com.android.server.trust.TrustManagerService;
import com.android.server.tv.TvInputManagerService;
import com.android.server.tv.TvRemoteService;
import com.android.server.tv.tuner.TunerResourceManagerService;
import com.android.server.tv.tunerresourcemanager.TunerResourceManagerService;
import com.android.server.twilight.TwilightService;
import com.android.server.uri.UriGrantsManagerService;
import com.android.server.usage.UsageStatsService;