Merge "Add requestStopRecording APIs"

This commit is contained in:
David Zhao
2022-11-15 00:02:18 +00:00
committed by Android (Google) Code Review
6 changed files with 105 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ oneway interface ITvInteractiveAppClient {
void onRequestTrackInfoList(int seq);
void onRequestCurrentTvInputId(int seq);
void onRequestStartRecording(in Uri programUri, int seq);
void onRequestStopRecording(in String recordingId, int seq);
void onRequestSigning(
in String id, in String algorithm, in String alias, in byte[] data, int seq);
void onAdRequest(in AdRequest request, int Seq);

View File

@@ -44,6 +44,7 @@ oneway interface ITvInteractiveAppSessionCallback {
void onRequestTrackInfoList();
void onRequestCurrentTvInputId();
void onRequestStartRecording(in Uri programUri);
void onRequestStopRecording(in String recordingId);
void onRequestSigning(in String id, in String algorithm, in String alias, in byte[] data);
void onAdRequest(in AdRequest request);
}

View File

@@ -498,6 +498,18 @@ public final class TvInteractiveAppManager {
}
}
@Override
public void onRequestStopRecording(String recordingId, int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
if (record == null) {
Log.e(TAG, "Callback not found for seq " + seq);
return;
}
record.postRequestStopRecording(recordingId);
}
}
@Override
public void onRequestSigning(
String id, String algorithm, String alias, byte[] data, int seq) {
@@ -1729,6 +1741,15 @@ public final class TvInteractiveAppManager {
});
}
void postRequestStopRecording(String recordingId) {
mHandler.post(new Runnable() {
@Override
public void run() {
mSessionCallback.onRequestStopRecording(mSession, recordingId);
}
});
}
void postRequestSigning(String id, String algorithm, String alias, byte[] data) {
mHandler.post(new Runnable() {
@Override
@@ -1884,10 +1905,21 @@ public final class TvInteractiveAppManager {
* called.
*
* @param session A {@link TvInteractiveAppService.Session} associated with this callback.
* @param programUri The Uri of the program to be recorded.
*/
public void onRequestStartRecording(Session session, Uri programUri) {
}
/**
* This is called when {@link TvInteractiveAppService.Session#RequestStopRecording} is
* called.
*
* @param session A {@link TvInteractiveAppService.Session} associated with this callback.
* @param recordingId The recordingId of the recording to be stopped.
*/
public void onRequestStopRecording(Session session, String recordingId) {
}
/**
* This is called when
* {@link TvInteractiveAppService.Session#requestSigning(String, String, String, byte[])} is

View File

@@ -941,6 +941,33 @@ public abstract class TvInteractiveAppService extends Service {
});
}
/**
* Requests starting of recording
*
* <p> This is used to request the active {@link android.media.tv.TvRecordingClient} to
* call {@link android.media.tv.TvRecordingClient#stopRecording()}.
* @see android.media.tv.TvRecordingClient#stopRecording()
*
* @hide
*/
@CallSuper
public void requestStopRecording(@NonNull String recordingId) {
executeOrPostRunnableOnMainThread(() -> {
try {
if (DEBUG) {
Log.d(TAG, "requestStopRecording");
}
if (mSessionCallback != null) {
mSessionCallback.onRequestStopRecording(recordingId);
}
} catch (RemoteException e) {
Log.w(TAG, "error in requestStopRecording", e);
}
});
}
/**
* Requests signing of the given data.
*

View File

@@ -866,6 +866,19 @@ public class TvInteractiveAppView extends ViewGroup {
@Nullable Uri programUri) {
}
/**
* This is called when {@link TvInteractiveAppService.Session#requestStopRecording()}
* is called.
*
* @param iAppServiceId The ID of the TV interactive app service bound to this view.
* @param recordingId The ID of the recording to stop.
* @hide
*/
public void onRequestStopRecording(
@NonNull String iAppServiceId,
@NonNull String recordingId) {
}
/**
* This is called when
* {@link TvInteractiveAppService.Session#requestSigning(String, String, String, byte[])} is
@@ -1203,6 +1216,20 @@ public class TvInteractiveAppView extends ViewGroup {
}
}
@Override
public void onRequestStopRecording(Session session, String recordingId) {
if (DEBUG) {
Log.d(TAG, "onRequestStopRecording");
}
if (this != mSessionCallback) {
Log.w(TAG, "onRequestStopRecording - session not created");
return;
}
if (mCallback != null) {
mCallback.onRequestStopRecording(mIAppServiceId, recordingId);
}
}
@Override
public void onRequestSigning(
Session session, String id, String algorithm, String alias, byte[] data) {

View File

@@ -2252,6 +2252,23 @@ public class TvInteractiveAppManagerService extends SystemService {
}
}
@Override
public void onRequestStopRecording(String recordingId) {
synchronized (mLock) {
if (DEBUG) {
Slogf.d(TAG, "onRequestStopRecording");
}
if (mSessionState.mSession == null || mSessionState.mClient == null) {
return;
}
try {
mSessionState.mClient.onRequestStopRecording(recordingId, mSessionState.mSeq);
} catch (RemoteException e) {
Slogf.e(TAG, "error in onRequestStopRecording", e);
}
}
}
@Override
public void onRequestSigning(String id, String algorithm, String alias, byte[] data) {
synchronized (mLock) {