Merge "TIAF API review: rename TvInteractiveAppInfo" into tm-dev

This commit is contained in:
Shubang Lu
2022-03-17 00:43:32 +00:00
committed by Android (Google) Code Review
10 changed files with 70 additions and 64 deletions

View File

@@ -26105,21 +26105,8 @@ package android.media.tv.interactive {
method @NonNull public android.media.tv.interactive.AppLinkInfo.Builder setUriScheme(@NonNull String);
}
public final class TvInteractiveAppInfo implements android.os.Parcelable {
ctor public TvInteractiveAppInfo(@NonNull android.content.Context, @NonNull android.content.ComponentName);
method public int describeContents();
method @NonNull public String getId();
method @Nullable public android.content.pm.ServiceInfo getServiceInfo();
method @NonNull public int getSupportedTypes();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.interactive.TvInteractiveAppInfo> CREATOR;
field public static final int INTERACTIVE_APP_TYPE_ATSC = 2; // 0x2
field public static final int INTERACTIVE_APP_TYPE_GINGA = 4; // 0x4
field public static final int INTERACTIVE_APP_TYPE_HBBTV = 1; // 0x1
}
public final class TvInteractiveAppManager {
method @NonNull public java.util.List<android.media.tv.interactive.TvInteractiveAppInfo> getTvInteractiveAppServiceList();
method @NonNull public java.util.List<android.media.tv.interactive.TvInteractiveAppServiceInfo> getTvInteractiveAppServiceList();
method public void prepare(@NonNull String, int);
method public void registerAppLinkInfo(@NonNull String, @NonNull android.media.tv.interactive.AppLinkInfo);
method public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.tv.interactive.TvInteractiveAppManager.TvInteractiveAppCallback);
@@ -26242,6 +26229,19 @@ package android.media.tv.interactive {
method @CallSuper public void setVideoBounds(@NonNull android.graphics.Rect);
}
public final class TvInteractiveAppServiceInfo implements android.os.Parcelable {
ctor public TvInteractiveAppServiceInfo(@NonNull android.content.Context, @NonNull android.content.ComponentName);
method public int describeContents();
method @NonNull public String getId();
method @Nullable public android.content.pm.ServiceInfo getServiceInfo();
method @NonNull public int getSupportedTypes();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.interactive.TvInteractiveAppServiceInfo> CREATOR;
field public static final int INTERACTIVE_APP_TYPE_ATSC = 2; // 0x2
field public static final int INTERACTIVE_APP_TYPE_GINGA = 4; // 0x4
field public static final int INTERACTIVE_APP_TYPE_HBBTV = 1; // 0x1
}
public class TvInteractiveAppView extends android.view.ViewGroup {
ctor public TvInteractiveAppView(@NonNull android.content.Context);
ctor public TvInteractiveAppView(@NonNull android.content.Context, @Nullable android.util.AttributeSet);

View File

@@ -17,7 +17,7 @@
package android.media.tv;
import android.annotation.NonNull;
import android.media.tv.interactive.TvInteractiveAppInfo;
import android.media.tv.interactive.TvInteractiveAppServiceInfo;
import android.os.Parcel;
import android.os.Parcelable;
@@ -50,7 +50,7 @@ public final class AitInfo implements Parcelable {
/**
* Constructs AIT info.
*/
public AitInfo(@TvInteractiveAppInfo.InteractiveAppType int type, int version) {
public AitInfo(@TvInteractiveAppServiceInfo.InteractiveAppType int type, int version) {
mType = type;
mVersion = version;
}
@@ -58,7 +58,7 @@ public final class AitInfo implements Parcelable {
/**
* Gets interactive app type.
*/
@TvInteractiveAppInfo.InteractiveAppType
@TvInteractiveAppServiceInfo.InteractiveAppType
public int getType() {
return mType;
}

View File

@@ -23,7 +23,7 @@ import android.media.tv.TvTrackInfo;
import android.media.tv.interactive.AppLinkInfo;
import android.media.tv.interactive.ITvInteractiveAppClient;
import android.media.tv.interactive.ITvInteractiveAppManagerCallback;
import android.media.tv.interactive.TvInteractiveAppInfo;
import android.media.tv.interactive.TvInteractiveAppServiceInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Surface;
@@ -33,7 +33,7 @@ import android.view.Surface;
* @hide
*/
interface ITvInteractiveAppManager {
List<TvInteractiveAppInfo> getTvInteractiveAppServiceList(int userId);
List<TvInteractiveAppServiceInfo> getTvInteractiveAppServiceList(int userId);
void prepare(String tiasId, int type, int userId);
void registerAppLinkInfo(String tiasId, in AppLinkInfo info, int userId);
void unregisterAppLinkInfo(String tiasId, in AppLinkInfo info, int userId);

View File

@@ -16,7 +16,7 @@
package android.media.tv.interactive;
import android.media.tv.interactive.TvInteractiveAppInfo;
import android.media.tv.interactive.TvInteractiveAppServiceInfo;
/**
* Interface to receive callbacks from ITvInteractiveAppManager regardless of sessions.
@@ -26,6 +26,6 @@ interface ITvInteractiveAppManagerCallback {
void onInteractiveAppServiceAdded(in String iAppServiceId);
void onInteractiveAppServiceRemoved(in String iAppServiceId);
void onInteractiveAppServiceUpdated(in String iAppServiceId);
void onTvInteractiveAppInfoUpdated(in TvInteractiveAppInfo tvIAppInfo);
void onTvInteractiveAppServiceInfoUpdated(in TvInteractiveAppServiceInfo tvIAppInfo);
void onStateChanged(in String iAppServiceId, int type, int state, int err);
}

View File

@@ -249,7 +249,7 @@ public final class TvInteractiveAppManager {
*
* @see #sendAppLinkCommand(String, Bundle)
* @see #ACTION_APP_LINK_COMMAND
* @see android.media.tv.interactive.TvInteractiveAppInfo#getId()
* @see android.media.tv.interactive.TvInteractiveAppServiceInfo#getId()
*/
public static final String INTENT_KEY_INTERACTIVE_APP_SERVICE_ID = "interactive_app_id";
@@ -269,7 +269,7 @@ public final class TvInteractiveAppManager {
*
* @see #sendAppLinkCommand(String, Bundle)
* @see #ACTION_APP_LINK_COMMAND
* @see android.media.tv.interactive.TvInteractiveAppInfo#getSupportedTypes()
* @see android.media.tv.interactive.TvInteractiveAppServiceInfo#getSupportedTypes()
* @see android.media.tv.interactive.TvInteractiveAppView#createBiInteractiveApp(Uri, Bundle)
*/
public static final String INTENT_KEY_BI_INTERACTIVE_APP_TYPE = "bi_interactive_app_type";
@@ -543,11 +543,11 @@ public final class TvInteractiveAppManager {
}
@Override
public void onTvInteractiveAppInfoUpdated(TvInteractiveAppInfo iAppInfo) {
public void onTvInteractiveAppServiceInfoUpdated(TvInteractiveAppServiceInfo iAppInfo) {
// TODO: add public API updateInteractiveAppInfo()
synchronized (mLock) {
for (TvInteractiveAppCallbackRecord record : mCallbackRecords) {
record.postTvInteractiveAppInfoUpdated(iAppInfo);
record.postTvInteractiveAppServiceInfoUpdated(iAppInfo);
}
}
}
@@ -611,16 +611,17 @@ public final class TvInteractiveAppManager {
* This is called when the information about an existing TV Interactive App service has been
* updated.
*
* <p>Because the system automatically creates a <code>TvInteractiveAppInfo</code> object
* for each TV Interactive App service based on the information collected from the
* <p>Because the system automatically creates a <code>TvInteractiveAppServiceInfo</code>
* object for each TV Interactive App service based on the information collected from the
* <code>AndroidManifest.xml</code>, this method is only called back when such information
* has changed dynamically.
*
* @param iAppInfo The <code>TvInteractiveAppInfo</code> object that contains new
* @param iAppInfo The <code>TvInteractiveAppServiceInfo</code> object that contains new
* information.
* @hide
*/
public void onTvInteractiveAppInfoUpdated(@NonNull TvInteractiveAppInfo iAppInfo) {
public void onTvInteractiveAppServiceInfoUpdated(
@NonNull TvInteractiveAppServiceInfo iAppInfo) {
}
/**
@@ -634,7 +635,7 @@ public final class TvInteractiveAppManager {
*/
public void onTvInteractiveAppServiceStateChanged(
@NonNull String iAppServiceId,
@TvInteractiveAppInfo.InteractiveAppType int type,
@TvInteractiveAppServiceInfo.InteractiveAppType int type,
@ServiceState int state,
@ErrorCode int err) {
}
@@ -680,11 +681,12 @@ public final class TvInteractiveAppManager {
});
}
public void postTvInteractiveAppInfoUpdated(final TvInteractiveAppInfo iAppInfo) {
public void postTvInteractiveAppServiceInfoUpdated(
final TvInteractiveAppServiceInfo iAppInfo) {
mExecutor.execute(new Runnable() {
@Override
public void run() {
mCallback.onTvInteractiveAppInfoUpdated(iAppInfo);
mCallback.onTvInteractiveAppServiceInfoUpdated(iAppInfo);
}
});
}
@@ -737,11 +739,11 @@ public final class TvInteractiveAppManager {
/**
* Returns the complete list of TV Interactive App service on the system.
*
* @return List of {@link TvInteractiveAppInfo} for each TV Interactive App service that
* @return List of {@link TvInteractiveAppServiceInfo} for each TV Interactive App service that
* describes its meta information.
*/
@NonNull
public List<TvInteractiveAppInfo> getTvInteractiveAppServiceList() {
public List<TvInteractiveAppServiceInfo> getTvInteractiveAppServiceList() {
try {
return mService.getTvInteractiveAppServiceList(mUserId);
} catch (RemoteException e) {

View File

@@ -242,7 +242,7 @@ public abstract class TvInteractiveAppService extends Service {
/**
* Prepares TV Interactive App service for the given type.
*/
public abstract void onPrepare(@TvInteractiveAppInfo.InteractiveAppType int type);
public abstract void onPrepare(@TvInteractiveAppServiceInfo.InteractiveAppType int type);
/**
* Called when a request to register an Android application link info record is received.
@@ -277,7 +277,7 @@ public abstract class TvInteractiveAppService extends Service {
@Nullable
public abstract Session onCreateSession(
@NonNull String iAppServiceId,
@TvInteractiveAppInfo.InteractiveAppType int type);
@TvInteractiveAppServiceInfo.InteractiveAppType int type);
/**
* Notifies the system when the state of the interactive app RTE has been changed.
@@ -289,7 +289,7 @@ public abstract class TvInteractiveAppService extends Service {
* {@link TvInteractiveAppManager#SERVICE_STATE_ERROR}.
*/
public final void notifyStateChanged(
@TvInteractiveAppInfo.InteractiveAppType int type,
@TvInteractiveAppServiceInfo.InteractiveAppType int type,
@TvInteractiveAppManager.ServiceState int state,
@TvInteractiveAppManager.ErrorCode int error) {
SomeArgs args = SomeArgs.obtain();

View File

@@ -16,4 +16,4 @@
package android.media.tv.interactive;
parcelable TvInteractiveAppInfo;
parcelable TvInteractiveAppServiceInfo;

View File

@@ -45,9 +45,9 @@ import java.util.List;
/**
* This class is used to specify meta information of a TV interactive app.
*/
public final class TvInteractiveAppInfo implements Parcelable {
public final class TvInteractiveAppServiceInfo implements Parcelable {
private static final boolean DEBUG = false;
private static final String TAG = "TvInteractiveAppInfo";
private static final String TAG = "TvInteractiveAppServiceInfo";
private static final String XML_START_TAG_NAME = "tv-interactive-app";
@@ -71,7 +71,7 @@ public final class TvInteractiveAppInfo implements Parcelable {
private final String mId;
private int mTypes;
public TvInteractiveAppInfo(@NonNull Context context, @NonNull ComponentName component) {
public TvInteractiveAppServiceInfo(@NonNull Context context, @NonNull ComponentName component) {
if (context == null) {
throw new IllegalArgumentException("context cannot be null.");
}
@@ -94,28 +94,28 @@ public final class TvInteractiveAppInfo implements Parcelable {
mId = id;
mTypes = toTypesFlag(types);
}
private TvInteractiveAppInfo(ResolveInfo service, String id, int types) {
private TvInteractiveAppServiceInfo(ResolveInfo service, String id, int types) {
mService = service;
mId = id;
mTypes = types;
}
private TvInteractiveAppInfo(@NonNull Parcel in) {
private TvInteractiveAppServiceInfo(@NonNull Parcel in) {
mService = ResolveInfo.CREATOR.createFromParcel(in);
mId = in.readString();
mTypes = in.readInt();
}
public static final @NonNull Creator<TvInteractiveAppInfo> CREATOR =
new Creator<TvInteractiveAppInfo>() {
public static final @NonNull Creator<TvInteractiveAppServiceInfo> CREATOR =
new Creator<TvInteractiveAppServiceInfo>() {
@Override
public TvInteractiveAppInfo createFromParcel(Parcel in) {
return new TvInteractiveAppInfo(in);
public TvInteractiveAppServiceInfo createFromParcel(Parcel in) {
return new TvInteractiveAppServiceInfo(in);
}
@Override
public TvInteractiveAppInfo[] newArray(int size) {
return new TvInteractiveAppInfo[size];
public TvInteractiveAppServiceInfo[] newArray(int size) {
return new TvInteractiveAppServiceInfo[size];
}
};

View File

@@ -148,12 +148,14 @@ public class TvInteractiveAppView extends ViewGroup {
/**
* Sets the callback to be invoked when an event is dispatched to this TvInteractiveAppView.
*
* @param callback The callback to receive events. A value of {@code null} removes the existing
* callback.
* @param callback the callback to receive events. MUST NOT be {@code null}.
*
* @see #clearCallback()
*/
public void setCallback(
@NonNull @CallbackExecutor Executor executor,
@NonNull TvInteractiveAppCallback callback) {
com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, callback);
synchronized (mCallbackLock) {
mCallbackExecutor = executor;
mCallback = callback;
@@ -162,6 +164,8 @@ public class TvInteractiveAppView extends ViewGroup {
/**
* Clears the callback.
*
* @see #setCallback(Executor, TvInteractiveAppCallback)
*/
public void clearCallback() {
synchronized (mCallbackLock) {
@@ -389,13 +393,13 @@ public class TvInteractiveAppView extends ViewGroup {
* Prepares the interactive application.
*
* @param iAppServiceId the interactive app service ID, which can be found in
* {@link TvInteractiveAppInfo#getId()}.
* {@link TvInteractiveAppServiceInfo#getId()}.
*
* @see android.media.tv.interactive.TvInteractiveAppManager#getTvInteractiveAppServiceList()
*/
public void prepareInteractiveApp(
@NonNull String iAppServiceId,
@TvInteractiveAppInfo.InteractiveAppType int type) {
@TvInteractiveAppServiceInfo.InteractiveAppType int type) {
// TODO: document and handle the cases that this method is called multiple times.
if (DEBUG) {
Log.d(TAG, "prepareInteractiveApp");

View File

@@ -42,8 +42,8 @@ import android.media.tv.interactive.ITvInteractiveAppService;
import android.media.tv.interactive.ITvInteractiveAppServiceCallback;
import android.media.tv.interactive.ITvInteractiveAppSession;
import android.media.tv.interactive.ITvInteractiveAppSessionCallback;
import android.media.tv.interactive.TvInteractiveAppInfo;
import android.media.tv.interactive.TvInteractiveAppService;
import android.media.tv.interactive.TvInteractiveAppServiceInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -130,7 +130,7 @@ public class TvInteractiveAppManagerService extends SystemService {
new Intent(TvInteractiveAppService.SERVICE_INTERFACE),
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
userId);
List<TvInteractiveAppInfo> iAppList = new ArrayList<>();
List<TvInteractiveAppServiceInfo> iAppList = new ArrayList<>();
for (ResolveInfo ri : services) {
ServiceInfo si = ri.serviceInfo;
@@ -143,8 +143,8 @@ public class TvInteractiveAppManagerService extends SystemService {
ComponentName component = new ComponentName(si.packageName, si.name);
try {
TvInteractiveAppInfo info =
new TvInteractiveAppInfo(mContext, component);
TvInteractiveAppServiceInfo info =
new TvInteractiveAppServiceInfo(mContext, component);
iAppList.add(info);
} catch (Exception e) {
Slogf.e(TAG, "failed to load TV Interactive App service " + si.name, e);
@@ -154,10 +154,10 @@ public class TvInteractiveAppManagerService extends SystemService {
}
// sort the iApp list by iApp service id
Collections.sort(iAppList, Comparator.comparing(TvInteractiveAppInfo::getId));
Collections.sort(iAppList, Comparator.comparing(TvInteractiveAppServiceInfo::getId));
Map<String, TvInteractiveAppState> iAppMap = new HashMap<>();
ArrayMap<String, Integer> tiasAppCount = new ArrayMap<>(iAppMap.size());
for (TvInteractiveAppInfo info : iAppList) {
for (TvInteractiveAppServiceInfo info : iAppList) {
String iAppServiceId = info.getId();
if (DEBUG) {
Slogf.d(TAG, "add " + iAppServiceId);
@@ -195,7 +195,7 @@ public class TvInteractiveAppManagerService extends SystemService {
for (String iAppServiceId : userState.mIAppMap.keySet()) {
if (!iAppMap.containsKey(iAppServiceId)) {
TvInteractiveAppInfo info = userState.mIAppMap.get(iAppServiceId).mInfo;
TvInteractiveAppServiceInfo info = userState.mIAppMap.get(iAppServiceId).mInfo;
ServiceState serviceState = userState.mServiceStateMap.get(info.getComponent());
if (serviceState != null) {
abortPendingCreateSessionRequestsLocked(serviceState, iAppServiceId, userId);
@@ -283,7 +283,7 @@ public class TvInteractiveAppManagerService extends SystemService {
userState.mCallbacks.finishBroadcast();
}
private int getInteractiveAppUid(TvInteractiveAppInfo info) {
private int getInteractiveAppUid(TvInteractiveAppServiceInfo info) {
try {
return getContext().getPackageManager().getApplicationInfo(
info.getServiceInfo().packageName, 0).uid;
@@ -642,7 +642,7 @@ public class TvInteractiveAppManagerService extends SystemService {
private final class BinderService extends ITvInteractiveAppManager.Stub {
@Override
public List<TvInteractiveAppInfo> getTvInteractiveAppServiceList(int userId) {
public List<TvInteractiveAppServiceInfo> getTvInteractiveAppServiceList(int userId) {
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
Binder.getCallingUid(), userId, "getTvInteractiveAppServiceList");
final long identity = Binder.clearCallingIdentity();
@@ -653,7 +653,7 @@ public class TvInteractiveAppManagerService extends SystemService {
mGetServiceListCalled = true;
}
UserState userState = getOrCreateUserStateLocked(resolvedUserId);
List<TvInteractiveAppInfo> iAppList = new ArrayList<>();
List<TvInteractiveAppServiceInfo> iAppList = new ArrayList<>();
for (TvInteractiveAppState state : userState.mIAppMap.values()) {
iAppList.add(state.mInfo);
}
@@ -1738,7 +1738,7 @@ public class TvInteractiveAppManagerService extends SystemService {
private static final class TvInteractiveAppState {
private String mIAppServiceId;
private ComponentName mComponentName;
private TvInteractiveAppInfo mInfo;
private TvInteractiveAppServiceInfo mInfo;
private int mUid;
private int mIAppNumber;
}