summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author shubang <shubang@google.com> 2022-01-14 04:16:54 -0800
committer shubang <shubang@google.com> 2022-01-15 02:36:16 -0800
commitbf93602e1f3840ad93a7858f854f0779a0937fdf (patch)
tree8b5839a48bb885f8aa18f94d2763f0eb04a07dff
parent7f9572371d7f76aa2428578aed0f69f2430516be (diff)
TIAF cleanup: add missing APIs part 2
Bug: 211931006 Test: mmm Change-Id: Ibeb96c4d286392251ec0ae64be0688e763e6bfeb
-rw-r--r--media/java/android/media/tv/BroadcastInfoRequest.java4
-rw-r--r--media/java/android/media/tv/BroadcastInfoResponse.java4
-rw-r--r--media/java/android/media/tv/CommandRequest.java2
-rw-r--r--media/java/android/media/tv/CommandResponse.java2
-rw-r--r--media/java/android/media/tv/DsmccResponse.java14
-rw-r--r--media/java/android/media/tv/ITvInputClient.aidl1
-rw-r--r--media/java/android/media/tv/ITvInputSessionCallback.aidl1
-rw-r--r--media/java/android/media/tv/TableResponse.java2
-rw-r--r--media/java/android/media/tv/TimelineRequest.java72
-rw-r--r--media/java/android/media/tv/TimelineResponse.java106
-rw-r--r--media/java/android/media/tv/TvInputManager.java64
-rwxr-xr-xmedia/java/android/media/tv/TvInputService.java21
-rw-r--r--media/java/android/media/tv/TvView.java24
-rw-r--r--media/java/android/media/tv/interactive/ITvIAppManager.aidl6
-rw-r--r--media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl1
-rw-r--r--media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl3
-rw-r--r--media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl3
-rw-r--r--media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl1
-rw-r--r--media/java/android/media/tv/interactive/TvIAppManager.java101
-rw-r--r--media/java/android/media/tv/interactive/TvIAppService.java96
-rw-r--r--media/java/android/media/tv/interactive/TvInteractiveAppView.java52
-rwxr-xr-xservices/core/java/com/android/server/tv/TvInputManagerService.java17
-rw-r--r--services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java162
23 files changed, 720 insertions, 39 deletions
diff --git a/media/java/android/media/tv/BroadcastInfoRequest.java b/media/java/android/media/tv/BroadcastInfoRequest.java
index 85ad3cdb5700..6ba913353896 100644
--- a/media/java/android/media/tv/BroadcastInfoRequest.java
+++ b/media/java/android/media/tv/BroadcastInfoRequest.java
@@ -49,8 +49,10 @@ public abstract class BroadcastInfoRequest implements Parcelable {
return StreamEventRequest.createFromParcelBody(source);
case TvInputManager.BROADCAST_INFO_TYPE_DSMCC:
return DsmccRequest.createFromParcelBody(source);
- case TvInputManager.BROADCAST_INFO_TYPE_TV_PROPRIETARY_FUNCTION:
+ case TvInputManager.BROADCAST_INFO_TYPE_COMMAND:
return CommandRequest.createFromParcelBody(source);
+ case TvInputManager.BROADCAST_INFO_TYPE_TIMELINE:
+ return TimelineRequest.createFromParcelBody(source);
default:
throw new IllegalStateException(
"Unexpected broadcast info request type (value "
diff --git a/media/java/android/media/tv/BroadcastInfoResponse.java b/media/java/android/media/tv/BroadcastInfoResponse.java
index e423abaf550d..67bdedc83f31 100644
--- a/media/java/android/media/tv/BroadcastInfoResponse.java
+++ b/media/java/android/media/tv/BroadcastInfoResponse.java
@@ -50,8 +50,10 @@ public abstract class BroadcastInfoResponse implements Parcelable {
return StreamEventResponse.createFromParcelBody(source);
case TvInputManager.BROADCAST_INFO_TYPE_DSMCC:
return DsmccResponse.createFromParcelBody(source);
- case TvInputManager.BROADCAST_INFO_TYPE_TV_PROPRIETARY_FUNCTION:
+ case TvInputManager.BROADCAST_INFO_TYPE_COMMAND:
return CommandResponse.createFromParcelBody(source);
+ case TvInputManager.BROADCAST_INFO_TYPE_TIMELINE:
+ return TimelineResponse.createFromParcelBody(source);
default:
throw new IllegalStateException(
"Unexpected broadcast info response type (value "
diff --git a/media/java/android/media/tv/CommandRequest.java b/media/java/android/media/tv/CommandRequest.java
index 2391fa3a4aef..d61c85849ad2 100644
--- a/media/java/android/media/tv/CommandRequest.java
+++ b/media/java/android/media/tv/CommandRequest.java
@@ -23,7 +23,7 @@ import android.os.Parcelable;
/** @hide */
public final class CommandRequest extends BroadcastInfoRequest implements Parcelable {
public static final @TvInputManager.BroadcastInfoType int requestType =
- TvInputManager.BROADCAST_INFO_TYPE_TV_PROPRIETARY_FUNCTION;
+ TvInputManager.BROADCAST_INFO_TYPE_COMMAND;
public static final @NonNull Parcelable.Creator<CommandRequest> CREATOR =
new Parcelable.Creator<CommandRequest>() {
diff --git a/media/java/android/media/tv/CommandResponse.java b/media/java/android/media/tv/CommandResponse.java
index d34681f443c2..af3d00ce5b90 100644
--- a/media/java/android/media/tv/CommandResponse.java
+++ b/media/java/android/media/tv/CommandResponse.java
@@ -23,7 +23,7 @@ import android.os.Parcelable;
/** @hide */
public final class CommandResponse extends BroadcastInfoResponse implements Parcelable {
public static final @TvInputManager.BroadcastInfoType int responseType =
- TvInputManager.BROADCAST_INFO_TYPE_TV_PROPRIETARY_FUNCTION;
+ TvInputManager.BROADCAST_INFO_TYPE_COMMAND;
public static final @NonNull Parcelable.Creator<CommandResponse> CREATOR =
new Parcelable.Creator<CommandResponse>() {
diff --git a/media/java/android/media/tv/DsmccResponse.java b/media/java/android/media/tv/DsmccResponse.java
index e43d31adaed5..4d496207051a 100644
--- a/media/java/android/media/tv/DsmccResponse.java
+++ b/media/java/android/media/tv/DsmccResponse.java
@@ -21,6 +21,9 @@ import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
+import java.util.ArrayList;
+import java.util.List;
+
/** @hide */
public final class DsmccResponse extends BroadcastInfoResponse implements Parcelable {
public static final @TvInputManager.BroadcastInfoType int responseType =
@@ -41,20 +44,27 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
};
private final ParcelFileDescriptor mFileDescriptor;
+ private final boolean mIsDirectory;
+ private final List<String> mChildren;
public static DsmccResponse createFromParcelBody(Parcel in) {
return new DsmccResponse(in);
}
public DsmccResponse(int requestId, int sequence, @ResponseResult int responseResult,
- ParcelFileDescriptor file) {
+ ParcelFileDescriptor file, boolean isDirectory, List<String> children) {
super(responseType, requestId, sequence, responseResult);
mFileDescriptor = file;
+ mIsDirectory = isDirectory;
+ mChildren = children;
}
protected DsmccResponse(Parcel source) {
super(responseType, source);
mFileDescriptor = source.readFileDescriptor();
+ mIsDirectory = (source.readInt() == 1);
+ mChildren = new ArrayList<>();
+ source.readStringList(mChildren);
}
public ParcelFileDescriptor getFile() {
@@ -65,5 +75,7 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
public void writeToParcel(@NonNull Parcel dest, int flags) {
super.writeToParcel(dest, flags);
mFileDescriptor.writeToParcel(dest, flags);
+ dest.writeInt(mIsDirectory ? 1 : 0);
+ dest.writeStringList(mChildren);
}
}
diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl
index f4f55e44255e..49148ceb84e2 100644
--- a/media/java/android/media/tv/ITvInputClient.aidl
+++ b/media/java/android/media/tv/ITvInputClient.aidl
@@ -47,6 +47,7 @@ oneway interface ITvInputClient {
void onTimeShiftStartPositionChanged(long timeMs, int seq);
void onTimeShiftCurrentPositionChanged(long timeMs, int seq);
void onAitInfoUpdated(in AitInfo aitInfo, int seq);
+ void onSignalStrength(int stength, int seq);
void onTuned(in Uri channelUri, int seq);
// For the recording session
diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl
index 9830e78a7faa..9dfdb78061a7 100644
--- a/media/java/android/media/tv/ITvInputSessionCallback.aidl
+++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl
@@ -44,6 +44,7 @@ oneway interface ITvInputSessionCallback {
void onTimeShiftStartPositionChanged(long timeMs);
void onTimeShiftCurrentPositionChanged(long timeMs);
void onAitInfoUpdated(in AitInfo aitInfo);
+ void onSignalStrength(int strength);
// For the recording session
void onTuned(in Uri channelUri);
diff --git a/media/java/android/media/tv/TableResponse.java b/media/java/android/media/tv/TableResponse.java
index 912cbce81e93..68d5f8aca21e 100644
--- a/media/java/android/media/tv/TableResponse.java
+++ b/media/java/android/media/tv/TableResponse.java
@@ -17,9 +17,9 @@
package android.media.tv;
import android.annotation.NonNull;
+import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
-import android.net.Uri;
/** @hide */
public final class TableResponse extends BroadcastInfoResponse implements Parcelable {
diff --git a/media/java/android/media/tv/TimelineRequest.java b/media/java/android/media/tv/TimelineRequest.java
new file mode 100644
index 000000000000..0714972befb2
--- /dev/null
+++ b/media/java/android/media/tv/TimelineRequest.java
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/** @hide */
+public final class TimelineRequest extends BroadcastInfoRequest implements Parcelable {
+ private static final @TvInputManager.BroadcastInfoType int REQUEST_TYPE =
+ TvInputManager.BROADCAST_INFO_TYPE_TIMELINE;
+
+ public static final @NonNull Parcelable.Creator<TimelineRequest> CREATOR =
+ new Parcelable.Creator<TimelineRequest>() {
+ @Override
+ public TimelineRequest createFromParcel(Parcel source) {
+ source.readInt();
+ return createFromParcelBody(source);
+ }
+
+ @Override
+ public TimelineRequest[] newArray(int size) {
+ return new TimelineRequest[size];
+ }
+ };
+
+ private final int mIntervalMs;
+
+ static TimelineRequest createFromParcelBody(Parcel in) {
+ return new TimelineRequest(in);
+ }
+
+ public TimelineRequest(int requestId, @RequestOption int option, int intervalMs) {
+ super(REQUEST_TYPE, requestId, option);
+ mIntervalMs = intervalMs;
+ }
+
+ protected TimelineRequest(Parcel source) {
+ super(REQUEST_TYPE, source);
+ mIntervalMs = source.readInt();
+ }
+
+ public int getIntervalMs() {
+ return mIntervalMs;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeInt(mIntervalMs);
+ }
+}
diff --git a/media/java/android/media/tv/TimelineResponse.java b/media/java/android/media/tv/TimelineResponse.java
new file mode 100644
index 000000000000..fee10b4e56d6
--- /dev/null
+++ b/media/java/android/media/tv/TimelineResponse.java
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/** @hide */
+public final class TimelineResponse extends BroadcastInfoResponse implements Parcelable {
+ private static final @TvInputManager.BroadcastInfoType int RESPONSE_TYPE =
+ TvInputManager.BROADCAST_INFO_TYPE_TIMELINE;
+
+ public static final @NonNull Parcelable.Creator<TimelineResponse> CREATOR =
+ new Parcelable.Creator<TimelineResponse>() {
+ @Override
+ public TimelineResponse createFromParcel(Parcel source) {
+ source.readInt();
+ return createFromParcelBody(source);
+ }
+
+ @Override
+ public TimelineResponse[] newArray(int size) {
+ return new TimelineResponse[size];
+ }
+ };
+
+ private final String mSelector;
+ private final int mUnitsPerTick;
+ private final int mUnitsPerSecond;
+ private final long mWallClock;
+ private final long mTicks;
+
+ static TimelineResponse createFromParcelBody(Parcel in) {
+ return new TimelineResponse(in);
+ }
+
+ public TimelineResponse(int requestId, int sequence,
+ @ResponseResult int responseResult, String selector, int unitsPerTick,
+ int unitsPerSecond, long wallClock, long ticks) {
+ super(RESPONSE_TYPE, requestId, sequence, responseResult);
+ mSelector = selector;
+ mUnitsPerTick = unitsPerTick;
+ mUnitsPerSecond = unitsPerSecond;
+ mWallClock = wallClock;
+ mTicks = ticks;
+ }
+
+ protected TimelineResponse(Parcel source) {
+ super(RESPONSE_TYPE, source);
+ mSelector = source.readString();
+ mUnitsPerTick = source.readInt();
+ mUnitsPerSecond = source.readInt();
+ mWallClock = source.readLong();
+ mTicks = source.readLong();
+ }
+
+ public String getSelector() {
+ return mSelector;
+ }
+
+ public int getUnitsPerTick() {
+ return mUnitsPerTick;
+ }
+
+ public int getUnitsPerSecond() {
+ return mUnitsPerSecond;
+ }
+
+ public long getWallClock() {
+ return mWallClock;
+ }
+
+ public long getTicks() {
+ return mTicks;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeString(mSelector);
+ dest.writeInt(mUnitsPerTick);
+ dest.writeInt(mUnitsPerSecond);
+ dest.writeLong(mWallClock);
+ dest.writeLong(mTicks);
+ }
+}
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index a92887cfaddd..98d1599e62e9 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -363,9 +363,10 @@ public final class TvInputManager {
/** @hide */
@Retention(RetentionPolicy.SOURCE)
- @IntDef({BROADCAST_INFO_TYPE_TS, BROADCAST_INFO_TYPE_TABLE, BROADCAST_INFO_TYPE_SECTION,
+ @IntDef(prefix = "BROADCAST_INFO_TYPE_", value =
+ {BROADCAST_INFO_TYPE_TS, BROADCAST_INFO_TYPE_TABLE, BROADCAST_INFO_TYPE_SECTION,
BROADCAST_INFO_TYPE_PES, BROADCAST_INFO_STREAM_EVENT, BROADCAST_INFO_TYPE_DSMCC,
- BROADCAST_INFO_TYPE_TV_PROPRIETARY_FUNCTION})
+ BROADCAST_INFO_TYPE_COMMAND, BROADCAST_INFO_TYPE_TIMELINE})
public @interface BroadcastInfoType {}
/** @hide */
@@ -381,7 +382,31 @@ public final class TvInputManager {
/** @hide */
public static final int BROADCAST_INFO_TYPE_DSMCC = 6;
/** @hide */
- public static final int BROADCAST_INFO_TYPE_TV_PROPRIETARY_FUNCTION = 7;
+ public static final int BROADCAST_INFO_TYPE_COMMAND = 7;
+ /** @hide */
+ public static final int BROADCAST_INFO_TYPE_TIMELINE = 8;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "SIGNAL_STRENGTH_",
+ value = {SIGNAL_STRENGTH_LOST, SIGNAL_STRENGTH_WEAK, SIGNAL_STRENGTH_STRONG})
+ public @interface SignalStrength {}
+
+ /**
+ * Signal lost.
+ * @hide
+ */
+ public static final int SIGNAL_STRENGTH_LOST = 1;
+ /**
+ * Weak signal.
+ * @hide
+ */
+ public static final int SIGNAL_STRENGTH_WEAK = 2;
+ /**
+ * Strong signal.
+ * @hide
+ */
+ public static final int SIGNAL_STRENGTH_STRONG = 3;
/**
* An unknown state of the client pid gets from the TvInputManager. Client gets this value when
@@ -662,6 +687,14 @@ public final class TvInputManager {
}
/**
+ * This is called when signal strength is updated.
+ * @param session A {@link TvInputManager.Session} associated with this callback.
+ * @param strength The current signal strength.
+ */
+ public void onSignalStrength(Session session, @SignalStrength int strength) {
+ }
+
+ /**
* This is called when the session has been tuned to the given channel.
*
* @param channelUri The URI of a channel.
@@ -872,6 +905,19 @@ public final class TvInputManager {
});
}
+ void postSignalStrength(final int strength) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onSignalStrength(mSession, strength);
+ if (mSession.mIAppNotificationEnabled
+ && mSession.getInteractiveAppSession() != null) {
+ mSession.getInteractiveAppSession().notifySignalStrength(strength);
+ }
+ }
+ });
+ }
+
void postTuned(final Uri channelUri) {
mHandler.post(new Runnable() {
@Override
@@ -1307,6 +1353,18 @@ public final class TvInputManager {
}
@Override
+ public void onSignalStrength(int strength, int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postSignalStrength(strength);
+ }
+ }
+
+ @Override
public void onTuned(Uri channelUri, int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index d52965b20a49..524ba34685b5 100755
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -966,6 +966,27 @@ public abstract class TvInputService extends Service {
}
/**
+ * Notifies signal strength.
+ * @hide
+ */
+ public void notifySignalStrength(@TvInputManager.SignalStrength final int strength) {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) Log.d(TAG, "notifySignalStrength");
+ if (mSessionCallback != null) {
+ mSessionCallback.onSignalStrength(strength);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in notifySignalStrength", e);
+ }
+ }
+ });
+ }
+
+ /**
* Assigns a size and position to the surface passed in {@link #onSetSurface}. The position
* is relative to the overlay view that sits on top of this surface.
*
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index 0d790f8fff58..71f6ad6dd034 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -1071,6 +1071,16 @@ public class TvView extends ViewGroup {
}
/**
+ * This is called when signal strength is updated.
+ * @param inputId The ID of the TV input bound to this view.
+ * @param strength The current signal strength.
+ *
+ * @hide
+ */
+ public void onSignalStrength(String inputId, @TvInputManager.SignalStrength int strength) {
+ }
+
+ /**
* This is called when the session has been tuned to the given channel.
*
* @param channelUri The URI of a channel.
@@ -1390,6 +1400,20 @@ public class TvView extends ViewGroup {
}
@Override
+ public void onSignalStrength(Session session, int strength) {
+ if (DEBUG) {
+ Log.d(TAG, "onSignalStrength(strength=" + strength + ")");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onSignalStrength - session not created");
+ return;
+ }
+ if (mCallback != null) {
+ mCallback.onSignalStrength(mInputId, strength);
+ }
+ }
+
+ @Override
public void onTuned(Session session, Uri channelUri) {
if (DEBUG) {
Log.d(TAG, "onTuned(channelUri=" + channelUri + ")");
diff --git a/media/java/android/media/tv/interactive/ITvIAppManager.aidl b/media/java/android/media/tv/interactive/ITvIAppManager.aidl
index ce8656e64df9..7da539ecc3ab 100644
--- a/media/java/android/media/tv/interactive/ITvIAppManager.aidl
+++ b/media/java/android/media/tv/interactive/ITvIAppManager.aidl
@@ -34,10 +34,12 @@ import android.view.Surface;
interface ITvIAppManager {
List<TvInteractiveAppInfo> getTvInteractiveAppServiceList(int userId);
void prepare(String tiasId, int type, int userId);
- void notifyAppLinkInfo(String tiasId, in Bundle info, int userId);
+ void registerAppLinkInfo(String tiasId, in Bundle info, int userId);
+ void unregisterAppLinkInfo(String tiasId, in Bundle 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);
+ void resetInteractiveApp(in IBinder sessionToken, int userId);
void createBiInteractiveApp(
in IBinder sessionToken, in Uri biIAppUri, in Bundle params, int userId);
void destroyBiInteractiveApp(in IBinder sessionToken, in String biIAppId, int userId);
@@ -45,6 +47,7 @@ interface ITvIAppManager {
void sendCurrentChannelLcn(in IBinder sessionToken, int lcn, int userId);
void sendStreamVolume(in IBinder sessionToken, float volume, int userId);
void sendTrackInfoList(in IBinder sessionToken, in List<TvTrackInfo> tracks, int userId);
+ void sendCurrentTvInputId(in IBinder sessionToken, in String inputId, int userId);
void createSession(in ITvInteractiveAppClient client, in String iAppServiceId, int type,
int seq, int userId);
void releaseSession(in IBinder sessionToken, int userId);
@@ -55,6 +58,7 @@ interface ITvIAppManager {
void notifyVideoUnavailable(in IBinder sessionToken, int reason, int userId);
void notifyContentAllowed(in IBinder sessionToken, int userId);
void notifyContentBlocked(in IBinder sessionToken, in String rating, int userId);
+ void notifySignalStrength(in IBinder sessionToken, int stength, int userId);
void setSurface(in IBinder sessionToken, in Surface surface, int userId);
void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height,
int userId);
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl
index bb1a73eed8d5..f4b58c681313 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl
@@ -42,5 +42,6 @@ oneway interface ITvInteractiveAppClient {
void onRequestCurrentChannelLcn(int seq);
void onRequestStreamVolume(int seq);
void onRequestTrackInfoList(int seq);
+ void onRequestCurrentTvInputId(int seq);
void onAdRequest(in AdRequest request, int Seq);
}
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl
index d5555344a000..c1e66229670a 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl
@@ -32,6 +32,7 @@ oneway interface ITvInteractiveAppService {
void createSession(in InputChannel channel, in ITvInteractiveAppSessionCallback callback,
in String iAppServiceId, int type);
void prepare(int type);
- void notifyAppLinkInfo(in Bundle info);
+ void registerAppLinkInfo(in Bundle info);
+ void unregisterAppLinkInfo(in Bundle info);
void sendAppLinkCommand(in Bundle command);
} \ No newline at end of file
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl
index 2d27bc302f15..0806531df2c4 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl
@@ -33,12 +33,14 @@ import android.view.Surface;
oneway interface ITvInteractiveAppSession {
void startInteractiveApp();
void stopInteractiveApp();
+ void resetInteractiveApp();
void createBiInteractiveApp(in Uri biIAppUri, in Bundle params);
void destroyBiInteractiveApp(in String biIAppId);
void sendCurrentChannelUri(in Uri channelUri);
void sendCurrentChannelLcn(int lcn);
void sendStreamVolume(float volume);
void sendTrackInfoList(in List<TvTrackInfo> tracks);
+ void sendCurrentTvInputId(in String inputId);
void release();
void notifyTuned(in Uri channelUri);
void notifyTrackSelected(int type, in String trackId);
@@ -47,6 +49,7 @@ oneway interface ITvInteractiveAppSession {
void notifyVideoUnavailable(int reason);
void notifyContentAllowed();
void notifyContentBlocked(in String rating);
+ void notifySignalStrength(int strength);
void setSurface(in Surface surface);
void dispatchSurfaceChanged(int format, int width, int height);
void notifyBroadcastInfoResponse(in BroadcastInfoResponse response);
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl
index 97015440f324..2350d4442a55 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl
@@ -41,5 +41,6 @@ oneway interface ITvInteractiveAppSessionCallback {
void onRequestCurrentChannelLcn();
void onRequestStreamVolume();
void onRequestTrackInfoList();
+ void onRequestCurrentTvInputId();
void onAdRequest(in AdRequest request);
}
diff --git a/media/java/android/media/tv/interactive/TvIAppManager.java b/media/java/android/media/tv/interactive/TvIAppManager.java
index 1a55ef9c230b..2b7eddf2c50d 100644
--- a/media/java/android/media/tv/interactive/TvIAppManager.java
+++ b/media/java/android/media/tv/interactive/TvIAppManager.java
@@ -96,7 +96,7 @@ public final class TvIAppManager {
* Key for package name in app link.
* <p>Type: String
*
- * @see #notifyAppLinkInfo(String, Bundle)
+ * @see #registerAppLinkInfo(String, Bundle)
* @see #sendAppLinkCommand(String, Bundle)
* @hide
*/
@@ -106,7 +106,7 @@ public final class TvIAppManager {
* Key for class name in app link.
* <p>Type: String
*
- * @see #notifyAppLinkInfo(String, Bundle)
+ * @see #registerAppLinkInfo(String, Bundle)
* @see #sendAppLinkCommand(String, Bundle)
* @hide
*/
@@ -116,7 +116,7 @@ public final class TvIAppManager {
* Key for URI scheme in app link.
* <p>Type: String
*
- * @see #notifyAppLinkInfo(String, Bundle)
+ * @see #registerAppLinkInfo(String, Bundle)
* @hide
*/
public static final String KEY_URI_SCHEME = "uri_scheme";
@@ -125,7 +125,7 @@ public final class TvIAppManager {
* Key for URI host in app link.
* <p>Type: String
*
- * @see #notifyAppLinkInfo(String, Bundle)
+ * @see #registerAppLinkInfo(String, Bundle)
* @hide
*/
public static final String KEY_URI_HOST = "uri_host";
@@ -134,7 +134,7 @@ public final class TvIAppManager {
* Key for URI prefix in app link.
* <p>Type: String
*
- * @see #notifyAppLinkInfo(String, Bundle)
+ * @see #registerAppLinkInfo(String, Bundle)
* @hide
*/
public static final String KEY_URI_PREFIX = "uri_prefix";
@@ -347,6 +347,18 @@ public final class TvIAppManager {
}
@Override
+ public void onRequestCurrentTvInputId(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestCurrentTvInputId();
+ }
+ }
+
+ @Override
public void onSessionStateChanged(int state, int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
@@ -611,12 +623,25 @@ public final class TvIAppManager {
}
/**
- * Notifies app link info.
+ * Registers app link info.
* @hide
*/
- public void notifyAppLinkInfo(@NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
+ public void registerAppLinkInfo(@NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
try {
- mService.notifyAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
+ mService.registerAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Unregisters app link info.
+ * @hide
+ */
+ public void unregisterAppLinkInfo(
+ @NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
+ try {
+ mService.unregisterAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -740,6 +765,18 @@ public final class TvIAppManager {
}
}
+ void resetInteractiveApp() {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.resetInteractiveApp(mToken, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
void createBiInteractiveApp(Uri biIAppUri, Bundle params) {
if (mToken == null) {
Log.w(TAG, "The session has been already released");
@@ -812,6 +849,18 @@ public final class TvIAppManager {
}
}
+ void sendCurrentTvInputId(@Nullable String inputId) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.sendCurrentTvInputId(mToken, inputId, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
/**
* Sets the {@link android.view.Surface} for this session.
*
@@ -1104,6 +1153,21 @@ public final class TvIAppManager {
}
}
+ /**
+ * Notifies Interactive APP session when signal strength is changed.
+ */
+ public void notifySignalStrength(int strength) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.notifySignalStrength(mToken, strength, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
private void flushPendingEventsLocked() {
mHandler.removeMessages(InputEventHandler.MSG_FLUSH_INPUT_EVENT);
@@ -1421,6 +1485,15 @@ public final class TvIAppManager {
});
}
+ void postRequestCurrentTvInputId() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestCurrentTvInputId(mSession);
+ }
+ });
+ }
+
void postAdRequest(final AdRequest request) {
mHandler.post(new Runnable() {
@Override
@@ -1545,8 +1618,16 @@ public final class TvIAppManager {
}
/**
- * This is called when {@link TvIAppService.Session#notifySessionStateChanged} is
- * called.
+ * This is called when {@link TvIAppService.Session#RequestCurrentTvInputId} is called.
+ *
+ * @param session A {@link TvIAppManager.Session} associated with this callback.
+ * @hide
+ */
+ public void onRequestCurrentTvInputId(Session session) {
+ }
+
+ /**
+ * This is called when {@link TvIAppService.Session#notifySessionStateChanged} is called.
*
* @param session A {@link TvIAppManager.Session} associated with this callback.
* @param state the current state.
diff --git a/media/java/android/media/tv/interactive/TvIAppService.java b/media/java/android/media/tv/interactive/TvIAppService.java
index 6c72af23c8a6..ef848db5730a 100644
--- a/media/java/android/media/tv/interactive/TvIAppService.java
+++ b/media/java/android/media/tv/interactive/TvIAppService.java
@@ -32,6 +32,7 @@ import android.media.tv.AdResponse;
import android.media.tv.BroadcastInfoRequest;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.TvContentRating;
+import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
import android.net.Uri;
import android.os.AsyncTask;
@@ -174,8 +175,13 @@ public abstract class TvIAppService extends Service {
}
@Override
- public void notifyAppLinkInfo(Bundle appLinkInfo) {
- onAppLinkInfo(appLinkInfo);
+ public void registerAppLinkInfo(Bundle appLinkInfo) {
+ onRegisterAppLinkInfo(appLinkInfo);
+ }
+
+ @Override
+ public void unregisterAppLinkInfo(Bundle appLinkInfo) {
+ onUnregisterAppLinkInfo(appLinkInfo);
}
@Override
@@ -198,7 +204,15 @@ public abstract class TvIAppService extends Service {
* Registers App link info.
* @hide
*/
- public void onAppLinkInfo(Bundle appLinkInfo) {
+ public void onRegisterAppLinkInfo(Bundle appLinkInfo) {
+ // TODO: make it abstract when unhide
+ }
+
+ /**
+ * Unregisters App link info.
+ * @hide
+ */
+ public void onUnregisterAppLinkInfo(Bundle appLinkInfo) {
// TODO: make it abstract when unhide
}
@@ -319,6 +333,13 @@ public abstract class TvIAppService extends Service {
}
/**
+ * Resets TvIAppService session.
+ * @hide
+ */
+ public void onResetInteractiveApp() {
+ }
+
+ /**
* Creates broadcast-independent(BI) interactive application.
*
* @see #onDestroyBiInteractiveApp(String)
@@ -369,6 +390,13 @@ public abstract class TvIAppService extends Service {
}
/**
+ * Receives current TV input ID.
+ * @hide
+ */
+ public void onCurrentTvInputId(@Nullable String inputId) {
+ }
+
+ /**
* Called when the application sets the surface.
*
* <p>The TV Interactive App service should render interactive app UI onto the given
@@ -475,6 +503,13 @@ public abstract class TvIAppService extends Service {
}
/**
+ * Called when signal strength is changed.
+ * @hide
+ */
+ public void onSignalStrength(@TvInputManager.SignalStrength int strength) {
+ }
+
+ /**
* Called when a broadcast info response is received.
* @hide
*/
@@ -760,6 +795,31 @@ public abstract class TvIAppService extends Service {
}
/**
+ * Requests current TV input ID.
+ *
+ * @see android.media.tv.TvInputInfo
+ * @hide
+ */
+ public void requestCurrentTvInputId() {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestCurrentTvInputId");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestCurrentTvInputId();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestCurrentTvInputId", e);
+ }
+ }
+ });
+ }
+
+ /**
* requests an advertisement request to be processed by the related TV input.
* @param request advertisement request
*/
@@ -790,6 +850,10 @@ public abstract class TvIAppService extends Service {
onStopInteractiveApp();
}
+ void resetInteractiveApp() {
+ onResetInteractiveApp();
+ }
+
void createBiInteractiveApp(@NonNull Uri biIAppUri, @Nullable Bundle params) {
onCreateBiInteractiveApp(biIAppUri, params);
}
@@ -814,6 +878,10 @@ public abstract class TvIAppService extends Service {
onTrackInfoList(tracks);
}
+ void sendCurrentTvInputId(@Nullable String inputId) {
+ onCurrentTvInputId(inputId);
+ }
+
void release() {
onRelease();
if (mSurface != null) {
@@ -878,6 +946,13 @@ public abstract class TvIAppService extends Service {
onContentBlocked(rating);
}
+ void notifySignalStrength(int strength) {
+ if (DEBUG) {
+ Log.d(TAG, "notifySignalStrength (strength=" + strength + ")");
+ }
+ onSignalStrength(strength);
+ }
+
/**
* Calls {@link #onBroadcastInfoResponse}.
*/
@@ -1194,6 +1269,11 @@ public abstract class TvIAppService extends Service {
}
@Override
+ public void resetInteractiveApp() {
+ mSessionImpl.resetInteractiveApp();
+ }
+
+ @Override
public void createBiInteractiveApp(@NonNull Uri biIAppUri, @Nullable Bundle params) {
mSessionImpl.createBiInteractiveApp(biIAppUri, params);
}
@@ -1224,6 +1304,11 @@ public abstract class TvIAppService extends Service {
}
@Override
+ public void sendCurrentTvInputId(@Nullable String inputId) {
+ mSessionImpl.sendCurrentTvInputId(inputId);
+ }
+
+ @Override
public void release() {
mSessionImpl.scheduleMediaViewCleanup();
mSessionImpl.release();
@@ -1265,6 +1350,11 @@ public abstract class TvIAppService extends Service {
}
@Override
+ public void notifySignalStrength(int strength) {
+ mSessionImpl.notifySignalStrength(strength);
+ }
+
+ @Override
public void setSurface(Surface surface) {
mSessionImpl.setSurface(surface);
}
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppView.java b/media/java/android/media/tv/interactive/TvInteractiveAppView.java
index de2fee2646f7..6c05687b4177 100644
--- a/media/java/android/media/tv/interactive/TvInteractiveAppView.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppView.java
@@ -420,6 +420,19 @@ public class TvInteractiveAppView extends ViewGroup {
}
/**
+ * Resets the interactive application.
+ * @hide
+ */
+ public void resetInteractiveApp() {
+ if (DEBUG) {
+ Log.d(TAG, "resetInteractiveApp");
+ }
+ if (mSession != null) {
+ mSession.resetInteractiveApp();
+ }
+ }
+
+ /**
* Sends current channel URI to related TV interactive app.
* @hide
*/
@@ -471,6 +484,23 @@ public class TvInteractiveAppView extends ViewGroup {
}
}
+ /**
+ * Sends current TV input ID to related TV interactive app.
+ *
+ * @param inputId The current TV input ID whose channel is tuned. {@code null} if no channel is
+ * tuned.
+ * @see android.media.tv.TvInputInfo
+ * @hide
+ */
+ public void sendCurrentTvInputId(@Nullable String inputId) {
+ if (DEBUG) {
+ Log.d(TAG, "sendCurrentTvInputId");
+ }
+ if (mSession != null) {
+ mSession.sendCurrentTvInputId(inputId);
+ }
+ }
+
private void resetInternal() {
mSessionCallback = null;
if (mSession != null) {
@@ -643,6 +673,14 @@ public class TvInteractiveAppView extends ViewGroup {
public void onRequestTrackInfoList(@NonNull String iAppServiceId) {
}
+ /**
+ * This is called when {@link TvIAppService.Session#RequestCurrentTvInputId} is called.
+ *
+ * @param iAppServiceId The ID of the TV interactive app service bound to this view.
+ */
+ public void onRequestCurrentTvInputId(@NonNull String iAppServiceId) {
+ }
+
}
/**
@@ -918,5 +956,19 @@ public class TvInteractiveAppView extends ViewGroup {
}
}
}
+
+ @Override
+ public void onRequestCurrentTvInputId(Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestCurrentTvInputId");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestCurrentTvInputId - session not created");
+ return;
+ }
+ if (mCallback != null) {
+ mCallback.onRequestCurrentTvInputId(mIAppServiceId);
+ }
+ }
}
}
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 6db9cf3463b7..e786fa270a37 100755
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -3539,6 +3539,23 @@ public final class TvInputManagerService extends SystemService {
}
@Override
+ public void onSignalStrength(int strength) {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slog.d(TAG, "onSignalStrength(" + strength + ")");
+ }
+ if (mSessionState.session == null || mSessionState.client == null) {
+ return;
+ }
+ try {
+ mSessionState.client.onSignalStrength(strength, mSessionState.seq);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "error in onSignalStrength", e);
+ }
+ }
+ }
+
+ @Override
public void onTuned(Uri channelUri) {
synchronized (mLock) {
if (DEBUG) {
diff --git a/services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java b/services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java
index 592954ab9828..512fc4b2412d 100644
--- a/services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java
+++ b/services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java
@@ -53,6 +53,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArrayMap;
+import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
import android.view.InputChannel;
@@ -685,16 +686,16 @@ public class TvIAppManagerService extends SystemService {
}
@Override
- public void notifyAppLinkInfo(String tiasId, Bundle appLinkInfo, int userId) {
+ public void registerAppLinkInfo(String tiasId, Bundle appLinkInfo, int userId) {
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
- Binder.getCallingUid(), userId, "notifyAppLinkInfo");
+ Binder.getCallingUid(), userId, "registerAppLinkInfo");
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
UserState userState = getOrCreateUserStateLocked(resolvedUserId);
TvInteractiveAppState iAppState = userState.mIAppMap.get(tiasId);
if (iAppState == null) {
- Slogf.e(TAG, "failed to notifyAppLinkInfo - unknown TIAS id "
+ Slogf.e(TAG, "failed to registerAppLinkInfo - unknown TIAS id "
+ tiasId);
return;
}
@@ -703,18 +704,54 @@ public class TvIAppManagerService extends SystemService {
if (serviceState == null) {
serviceState = new ServiceState(
componentName, tiasId, resolvedUserId);
- serviceState.addPendingAppLink(appLinkInfo);
+ serviceState.addPendingAppLink(appLinkInfo, true);
userState.mServiceStateMap.put(componentName, serviceState);
updateServiceConnectionLocked(componentName, resolvedUserId);
} else if (serviceState.mService != null) {
- serviceState.mService.notifyAppLinkInfo(appLinkInfo);
+ serviceState.mService.registerAppLinkInfo(appLinkInfo);
} else {
- serviceState.addPendingAppLink(appLinkInfo);
+ serviceState.addPendingAppLink(appLinkInfo, true);
updateServiceConnectionLocked(componentName, resolvedUserId);
}
}
} catch (RemoteException e) {
- Slogf.e(TAG, "error in notifyAppLinkInfo", e);
+ Slogf.e(TAG, "error in registerAppLinkInfo", e);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void unregisterAppLinkInfo(String tiasId, Bundle appLinkInfo, int userId) {
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, "unregisterAppLinkInfo");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ UserState userState = getOrCreateUserStateLocked(resolvedUserId);
+ TvInteractiveAppState iAppState = userState.mIAppMap.get(tiasId);
+ if (iAppState == null) {
+ Slogf.e(TAG, "failed to unregisterAppLinkInfo - unknown TIAS id "
+ + tiasId);
+ return;
+ }
+ ComponentName componentName = iAppState.mInfo.getComponent();
+ ServiceState serviceState = userState.mServiceStateMap.get(componentName);
+ if (serviceState == null) {
+ serviceState = new ServiceState(
+ componentName, tiasId, resolvedUserId);
+ serviceState.addPendingAppLink(appLinkInfo, false);
+ userState.mServiceStateMap.put(componentName, serviceState);
+ updateServiceConnectionLocked(componentName, resolvedUserId);
+ } else if (serviceState.mService != null) {
+ serviceState.mService.unregisterAppLinkInfo(appLinkInfo);
+ } else {
+ serviceState.addPendingAppLink(appLinkInfo, false);
+ updateServiceConnectionLocked(componentName, resolvedUserId);
+ }
+ }
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in unregisterAppLinkInfo", e);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -1007,6 +1044,28 @@ public class TvIAppManagerService extends SystemService {
}
@Override
+ public void notifySignalStrength(IBinder sessionToken, int strength, int userId) {
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ final int resolvedUserId = resolveCallingUserId(callingPid, callingUid, userId,
+ "notifySignalStrength");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ SessionState sessionState = getSessionStateLocked(sessionToken, callingUid,
+ resolvedUserId);
+ getSessionLocked(sessionState).notifySignalStrength(strength);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in notifySignalStrength", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void startInteractiveApp(IBinder sessionToken, int userId) {
if (DEBUG) {
Slogf.d(TAG, "BinderService#start(userId=%d)", userId);
@@ -1057,6 +1116,31 @@ public class TvIAppManagerService extends SystemService {
}
@Override
+ public void resetInteractiveApp(IBinder sessionToken, int userId) {
+ if (DEBUG) {
+ Slogf.d(TAG, "BinderService#reset(userId=%d)", userId);
+ }
+ final int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
+ userId, "resetInteractiveApp");
+ SessionState sessionState = null;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ sessionState = getSessionStateLocked(sessionToken, callingUid,
+ resolvedUserId);
+ getSessionLocked(sessionState).resetInteractiveApp();
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in reset", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void createBiInteractiveApp(
IBinder sessionToken, Uri biIAppUri, Bundle params, int userId) {
if (DEBUG) {
@@ -1209,6 +1293,31 @@ public class TvIAppManagerService extends SystemService {
}
@Override
+ public void sendCurrentTvInputId(IBinder sessionToken, String inputId, int userId) {
+ if (DEBUG) {
+ Slogf.d(TAG, "sendCurrentTvInputId(inputId=%s)", inputId);
+ }
+ final int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
+ userId, "sendCurrentTvInputId");
+ SessionState sessionState = null;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ sessionState = getSessionStateLocked(sessionToken, callingUid,
+ resolvedUserId);
+ getSessionLocked(sessionState).sendCurrentTvInputId(inputId);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in sendCurrentTvInputId", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void setSurface(IBinder sessionToken, Surface surface, int userId) {
final int callingUid = Binder.getCallingUid();
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
@@ -1528,7 +1637,8 @@ public class TvIAppManagerService extends SystemService {
}
boolean shouldBind = (!serviceState.mSessionTokens.isEmpty())
- || (serviceState.mPendingPrepare) || (!serviceState.mPendingAppLinkInfo.isEmpty());
+ || (serviceState.mPendingPrepare)
+ || (!serviceState.mPendingAppLinkInfo.isEmpty());
if (serviceState.mService == null && shouldBind) {
// This means that the service is not yet connected but its state indicates that we
@@ -1675,7 +1785,7 @@ public class TvIAppManagerService extends SystemService {
private final ServiceConnection mConnection;
private final ComponentName mComponent;
private final String mIAppServiceId;
- private final List<Bundle> mPendingAppLinkInfo = new ArrayList<>();
+ private final List<Pair<Bundle, Boolean>> mPendingAppLinkInfo = new ArrayList<>();
private final List<Bundle> mPendingAppLinkCommand = new ArrayList<>();
private boolean mPendingPrepare = false;
@@ -1698,8 +1808,8 @@ public class TvIAppManagerService extends SystemService {
mIAppServiceId = tias;
}
- private void addPendingAppLink(Bundle info) {
- mPendingAppLinkInfo.add(info);
+ private void addPendingAppLink(Bundle info, boolean register) {
+ mPendingAppLinkInfo.add(Pair.create(info, register));
}
private void addPendingAppLinkCommand(Bundle command) {
@@ -1745,15 +1855,20 @@ public class TvIAppManagerService extends SystemService {
}
if (!serviceState.mPendingAppLinkInfo.isEmpty()) {
- for (Iterator<Bundle> it = serviceState.mPendingAppLinkInfo.iterator();
+ for (Iterator<Pair<Bundle, Boolean>> it =
+ serviceState.mPendingAppLinkInfo.iterator();
it.hasNext(); ) {
- Bundle appLinkInfo = it.next();
+ Pair<Bundle, Boolean> appLinkInfoPair = it.next();
final long identity = Binder.clearCallingIdentity();
try {
- serviceState.mService.notifyAppLinkInfo(appLinkInfo);
+ if (appLinkInfoPair.second) {
+ serviceState.mService.registerAppLinkInfo(appLinkInfoPair.first);
+ } else {
+ serviceState.mService.unregisterAppLinkInfo(appLinkInfoPair.first);
+ }
it.remove();
} catch (RemoteException e) {
- Slogf.e(TAG, "error in notifyAppLinkInfo(" + appLinkInfo
+ Slogf.e(TAG, "error in notifyAppLinkInfo(" + appLinkInfoPair
+ ") when onServiceConnected", e);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2036,6 +2151,23 @@ public class TvIAppManagerService extends SystemService {
}
@Override
+ public void onRequestCurrentTvInputId() {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestCurrentTvInputId");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestCurrentTvInputId(mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestCurrentTvInputId", e);
+ }
+ }
+ }
+
+ @Override
public void onAdRequest(AdRequest request) {
synchronized (mLock) {
if (DEBUG) {