Merge "TIAF: make AppLinkInfo a class"
This commit is contained in:
19
media/java/android/media/tv/interactive/AppLinkInfo.aidl
Normal file
19
media/java/android/media/tv/interactive/AppLinkInfo.aidl
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 android.media.tv.interactive;
|
||||
|
||||
parcelable AppLinkInfo;
|
||||
234
media/java/android/media/tv/interactive/AppLinkInfo.java
Normal file
234
media/java/android/media/tv/interactive/AppLinkInfo.java
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 android.media.tv.interactive;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* App link information used by TV interactive app to launch Android apps.
|
||||
* @hide
|
||||
*/
|
||||
public final class AppLinkInfo implements Parcelable {
|
||||
private @NonNull String mPackageName;
|
||||
private @NonNull String mClassName;
|
||||
private @Nullable String mUriScheme;
|
||||
private @Nullable String mUriHost;
|
||||
private @Nullable String mUriPrefix;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new AppLinkInfo.
|
||||
*/
|
||||
private AppLinkInfo(
|
||||
@NonNull String packageName,
|
||||
@NonNull String className,
|
||||
@Nullable String uriScheme,
|
||||
@Nullable String uriHost,
|
||||
@Nullable String uriPrefix) {
|
||||
this.mPackageName = packageName;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mPackageName);
|
||||
this.mClassName = className;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mClassName);
|
||||
this.mUriScheme = uriScheme;
|
||||
this.mUriHost = uriHost;
|
||||
this.mUriPrefix = uriPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets package name of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets package class of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public String getClassName() {
|
||||
return mClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets URI scheme of the App link.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUriScheme() {
|
||||
return mUriScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets URI host of the App link.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUriHost() {
|
||||
return mUriHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets URI prefix of the App link.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUriPrefix() {
|
||||
return mUriPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppLinkInfo { "
|
||||
+ "packageName = " + mPackageName + ", "
|
||||
+ "className = " + mClassName + ", "
|
||||
+ "uriScheme = " + mUriScheme + ", "
|
||||
+ "uriHost = " + mUriHost + ", "
|
||||
+ "uriPrefix = " + mUriPrefix
|
||||
+ " }";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
dest.writeString(mPackageName);
|
||||
dest.writeString(mClassName);
|
||||
dest.writeString(mUriScheme);
|
||||
dest.writeString(mUriHost);
|
||||
dest.writeString(mUriPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* package-private */ AppLinkInfo(@NonNull Parcel in) {
|
||||
String packageName = in.readString();
|
||||
String className = in.readString();
|
||||
String uriScheme = in.readString();
|
||||
String uriHost = in.readString();
|
||||
String uriPrefix = in.readString();
|
||||
|
||||
this.mPackageName = packageName;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mPackageName);
|
||||
this.mClassName = className;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mClassName);
|
||||
this.mUriScheme = uriScheme;
|
||||
this.mUriHost = uriHost;
|
||||
this.mUriPrefix = uriPrefix;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static final Parcelable.Creator<AppLinkInfo> CREATOR =
|
||||
new Parcelable.Creator<AppLinkInfo>() {
|
||||
@Override
|
||||
public AppLinkInfo[] newArray(int size) {
|
||||
return new AppLinkInfo[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppLinkInfo createFromParcel(@NonNull Parcel in) {
|
||||
return new AppLinkInfo(in);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A builder for {@link AppLinkInfo}
|
||||
*/
|
||||
public static final class Builder {
|
||||
private @NonNull String mPackageName;
|
||||
private @NonNull String mClassName;
|
||||
private @Nullable String mUriScheme;
|
||||
private @Nullable String mUriHost;
|
||||
private @Nullable String mUriPrefix;
|
||||
|
||||
/**
|
||||
* Creates a new Builder.
|
||||
*/
|
||||
public Builder(
|
||||
@NonNull String packageName,
|
||||
@NonNull String className) {
|
||||
mPackageName = packageName;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mPackageName);
|
||||
mClassName = className;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets package name of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setPackageName(@NonNull String value) {
|
||||
mPackageName = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets app name of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setClassName(@NonNull String value) {
|
||||
mClassName = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets URI scheme of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setUriScheme(@Nullable String value) {
|
||||
mUriScheme = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets URI host of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setUriHost(@Nullable String value) {
|
||||
mUriHost = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets URI prefix of the App link.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setUriPrefix(@Nullable String value) {
|
||||
mUriPrefix = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the instance. This builder should not be touched after calling this! */
|
||||
@NonNull
|
||||
public AppLinkInfo build() {
|
||||
AppLinkInfo o = new AppLinkInfo(
|
||||
mPackageName,
|
||||
mClassName,
|
||||
mUriScheme,
|
||||
mUriHost,
|
||||
mUriPrefix);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import android.graphics.Rect;
|
||||
import android.media.tv.AdResponse;
|
||||
import android.media.tv.BroadcastInfoResponse;
|
||||
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;
|
||||
@@ -34,8 +35,8 @@ import android.view.Surface;
|
||||
interface ITvInteractiveAppManager {
|
||||
List<TvInteractiveAppInfo> getTvInteractiveAppServiceList(int userId);
|
||||
void prepare(String tiasId, int type, int userId);
|
||||
void registerAppLinkInfo(String tiasId, in Bundle info, int userId);
|
||||
void unregisterAppLinkInfo(String tiasId, in Bundle info, int userId);
|
||||
void registerAppLinkInfo(String tiasId, in AppLinkInfo info, int userId);
|
||||
void unregisterAppLinkInfo(String tiasId, in AppLinkInfo info, int userId);
|
||||
void sendAppLinkCommand(String tiasId, in Bundle command, int userId);
|
||||
void startInteractiveApp(in IBinder sessionToken, int userId);
|
||||
void stopInteractiveApp(in IBinder sessionToken, int userId);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.media.tv.interactive;
|
||||
|
||||
import android.media.tv.interactive.AppLinkInfo;
|
||||
import android.media.tv.interactive.ITvInteractiveAppServiceCallback;
|
||||
import android.media.tv.interactive.ITvInteractiveAppSessionCallback;
|
||||
import android.os.Bundle;
|
||||
@@ -32,7 +33,7 @@ oneway interface ITvInteractiveAppService {
|
||||
void createSession(in InputChannel channel, in ITvInteractiveAppSessionCallback callback,
|
||||
in String iAppServiceId, int type);
|
||||
void prepare(int type);
|
||||
void registerAppLinkInfo(in Bundle info);
|
||||
void unregisterAppLinkInfo(in Bundle info);
|
||||
void registerAppLinkInfo(in AppLinkInfo info);
|
||||
void unregisterAppLinkInfo(in AppLinkInfo info);
|
||||
void sendAppLinkCommand(in Bundle command);
|
||||
}
|
||||
@@ -757,7 +757,8 @@ public final class TvInteractiveAppManager {
|
||||
* Registers app link info.
|
||||
* @hide
|
||||
*/
|
||||
public void registerAppLinkInfo(@NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
|
||||
public void registerAppLinkInfo(
|
||||
@NonNull String tvIAppServiceId, @NonNull AppLinkInfo appLinkInfo) {
|
||||
try {
|
||||
mService.registerAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
|
||||
} catch (RemoteException e) {
|
||||
@@ -770,7 +771,7 @@ public final class TvInteractiveAppManager {
|
||||
* @hide
|
||||
*/
|
||||
public void unregisterAppLinkInfo(
|
||||
@NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
|
||||
@NonNull String tvIAppServiceId, @NonNull AppLinkInfo appLinkInfo) {
|
||||
try {
|
||||
mService.unregisterAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -182,12 +182,12 @@ public abstract class TvInteractiveAppService extends Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAppLinkInfo(Bundle appLinkInfo) {
|
||||
public void registerAppLinkInfo(AppLinkInfo appLinkInfo) {
|
||||
onRegisterAppLinkInfo(appLinkInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAppLinkInfo(Bundle appLinkInfo) {
|
||||
public void unregisterAppLinkInfo(AppLinkInfo appLinkInfo) {
|
||||
onUnregisterAppLinkInfo(appLinkInfo);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public abstract class TvInteractiveAppService extends Service {
|
||||
* Registers App link info.
|
||||
* @hide
|
||||
*/
|
||||
public void onRegisterAppLinkInfo(Bundle appLinkInfo) {
|
||||
public void onRegisterAppLinkInfo(AppLinkInfo appLinkInfo) {
|
||||
// TODO: make it abstract when unhide
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public abstract class TvInteractiveAppService extends Service {
|
||||
* Unregisters App link info.
|
||||
* @hide
|
||||
*/
|
||||
public void onUnregisterAppLinkInfo(Bundle appLinkInfo) {
|
||||
public void onUnregisterAppLinkInfo(AppLinkInfo appLinkInfo) {
|
||||
// TODO: make it abstract when unhide
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.media.tv.AdResponse;
|
||||
import android.media.tv.BroadcastInfoRequest;
|
||||
import android.media.tv.BroadcastInfoResponse;
|
||||
import android.media.tv.TvTrackInfo;
|
||||
import android.media.tv.interactive.AppLinkInfo;
|
||||
import android.media.tv.interactive.ITvInteractiveAppClient;
|
||||
import android.media.tv.interactive.ITvInteractiveAppManager;
|
||||
import android.media.tv.interactive.ITvInteractiveAppManagerCallback;
|
||||
@@ -695,9 +696,9 @@ public class TvInteractiveAppManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAppLinkInfo(String tiasId, Bundle appLinkInfo, int userId) {
|
||||
public void registerAppLinkInfo(String tiasId, AppLinkInfo appLinkInfo, int userId) {
|
||||
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), userId, "registerAppLinkInfo");
|
||||
Binder.getCallingUid(), userId, "registerAppLinkInfo: " + appLinkInfo);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
@@ -731,9 +732,9 @@ public class TvInteractiveAppManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAppLinkInfo(String tiasId, Bundle appLinkInfo, int userId) {
|
||||
public void unregisterAppLinkInfo(String tiasId, AppLinkInfo appLinkInfo, int userId) {
|
||||
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), userId, "unregisterAppLinkInfo");
|
||||
Binder.getCallingUid(), userId, "unregisterAppLinkInfo: " + appLinkInfo);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
@@ -1819,7 +1820,7 @@ public class TvInteractiveAppManagerService extends SystemService {
|
||||
private final ServiceConnection mConnection;
|
||||
private final ComponentName mComponent;
|
||||
private final String mIAppServiceId;
|
||||
private final List<Pair<Bundle, Boolean>> mPendingAppLinkInfo = new ArrayList<>();
|
||||
private final List<Pair<AppLinkInfo, Boolean>> mPendingAppLinkInfo = new ArrayList<>();
|
||||
private final List<Bundle> mPendingAppLinkCommand = new ArrayList<>();
|
||||
|
||||
private boolean mPendingPrepare = false;
|
||||
@@ -1842,7 +1843,7 @@ public class TvInteractiveAppManagerService extends SystemService {
|
||||
mIAppServiceId = tias;
|
||||
}
|
||||
|
||||
private void addPendingAppLink(Bundle info, boolean register) {
|
||||
private void addPendingAppLink(AppLinkInfo info, boolean register) {
|
||||
mPendingAppLinkInfo.add(Pair.create(info, register));
|
||||
}
|
||||
|
||||
@@ -1899,10 +1900,10 @@ public class TvInteractiveAppManagerService extends SystemService {
|
||||
}
|
||||
|
||||
if (!serviceState.mPendingAppLinkInfo.isEmpty()) {
|
||||
for (Iterator<Pair<Bundle, Boolean>> it =
|
||||
for (Iterator<Pair<AppLinkInfo, Boolean>> it =
|
||||
serviceState.mPendingAppLinkInfo.iterator();
|
||||
it.hasNext(); ) {
|
||||
Pair<Bundle, Boolean> appLinkInfoPair = it.next();
|
||||
Pair<AppLinkInfo, Boolean> appLinkInfoPair = it.next();
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
if (appLinkInfoPair.second) {
|
||||
|
||||
Reference in New Issue
Block a user