Add notifyRecordingStopped API

Test: atest
Bug: 256713311
Change-Id: I9d8a0e163730bcd88597ebc468bc6ea88929ebdf
This commit is contained in:
David Zhao
2022-11-09 13:04:52 -08:00
parent 2ff1284e94
commit 2f09f6979f
7 changed files with 86 additions and 2 deletions

View File

@@ -64,6 +64,7 @@ interface ITvInteractiveAppManager {
void notifyContentBlocked(in IBinder sessionToken, in String rating, int userId);
void notifySignalStrength(in IBinder sessionToken, int stength, int userId);
void notifyRecordingStarted(in IBinder sessionToken, in String recordingId, int userId);
void notifyRecordingStopped(in IBinder sessionToken, in String recordingId, 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);

View File

@@ -54,6 +54,7 @@ oneway interface ITvInteractiveAppSession {
void notifyContentBlocked(in String rating);
void notifySignalStrength(int strength);
void notifyRecordingStarted(in String recordingId);
void notifyRecordingStopped(in String recordingId);
void setSurface(in Surface surface);
void dispatchSurfaceChanged(int format, int width, int height);
void notifyBroadcastInfoResponse(in BroadcastInfoResponse response);

View File

@@ -82,6 +82,7 @@ public class ITvInteractiveAppSessionWrapper
private static final int DO_RELAYOUT_MEDIA_VIEW = 28;
private static final int DO_REMOVE_MEDIA_VIEW = 29;
private static final int DO_NOTIFY_RECORDING_STARTED = 30;
private static final int DO_NOTIFY_RECORDING_STOPPED = 31;
private final HandlerCaller mCaller;
private Session mSessionImpl;
@@ -169,6 +170,10 @@ public class ITvInteractiveAppSessionWrapper
mSessionImpl.notifyRecordingStarted((String) msg.obj);
break;
}
case DO_NOTIFY_RECORDING_STOPPED: {
mSessionImpl.notifyRecordingStopped((String) msg.obj);
break;
}
case DO_SEND_SIGNING_RESULT: {
SomeArgs args = (SomeArgs) msg.obj;
mSessionImpl.sendSigningResult((String) args.arg1, (byte[]) args.arg2);
@@ -391,6 +396,12 @@ public class ITvInteractiveAppSessionWrapper
DO_NOTIFY_RECORDING_STARTED, recordingId));
}
@Override
public void notifyRecordingStopped(String recordingId) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(
DO_NOTIFY_RECORDING_STOPPED, recordingId));
}
@Override
public void setSurface(Surface surface) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_SURFACE, surface));

View File

@@ -1059,6 +1059,18 @@ public final class TvInteractiveAppManager {
}
}
void notifyRecordingStopped(String recordingId) {
if (mToken == null) {
Log.w(TAG, "The session has been already released");
return;
}
try {
mService.notifyRecordingStopped(mToken, recordingId, mUserId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
void sendSigningResult(@NonNull String signingId, @NonNull byte[] result) {
if (mToken == null) {
Log.w(TAG, "The session has been already released");

View File

@@ -462,6 +462,16 @@ public abstract class TvInteractiveAppService extends Service {
public void onRecordingStarted(@NonNull String recordingId) {
}
/**
* Receives stopped recording's ID.
*
* @param recordingId The ID of the recording stopped
* @hide
*/
public void onRecordingStopped(@NonNull String recordingId) {
}
/**
* Receives signing result.
* @param signingId the ID to identify the request. It's the same as the corresponding ID in
@@ -1151,10 +1161,20 @@ public abstract class TvInteractiveAppService extends Service {
onAdResponse(response);
}
/**
* Calls {@link #onRecordingStarted(String)}.
*/
void notifyRecordingStarted(String recordingId) {
onRecordingStarted(recordingId);
}
/**
* Calls {@link #onRecordingStopped(String)}.
*/
void notifyRecordingStopped(String recordingId) {
onRecordingStopped(recordingId);
}
/**
* Notifies when the session state is changed.
*

View File

@@ -581,9 +581,10 @@ public class TvInteractiveAppView extends ViewGroup {
}
/**
* Alerts the TV interactive app that a recording has been started with recordingId
* Alerts the TV interactive app that a recording has been started.
*
* @param recordingId The ID of the recording started
* @param recordingId The ID of the recording started. This ID is created and maintained by the
* TV app and is used to identify the recording in the future.
*/
public void notifyRecordingStarted(@NonNull String recordingId) {
if (DEBUG) {
@@ -594,6 +595,23 @@ public class TvInteractiveAppView extends ViewGroup {
}
}
/**
* Alerts the TV interactive app that a recording has been stopped.
*
* @param recordingId The ID of the recording stopped. This ID is created and maintained
* by the TV app when a recording is started.
* @see TvInteractiveAppView#notifyRecordingStarted(String)
* @hide
*/
public void notifyRecordingStopped(@NonNull String recordingId) {
if (DEBUG) {
Log.d(TAG, "notifyRecordingStopped");
}
if (mSession != null) {
mSession.notifyRecordingStopped(recordingId);
}
}
/**
* Sends signing result to related TV interactive app.
*

View File

@@ -1066,7 +1066,28 @@ public class TvInteractiveAppManagerService extends SystemService {
} finally {
Binder.restoreCallingIdentity(identity);
}
}
@Override
public void notifyRecordingStopped(IBinder sessionToken, String recordingId, int userId) {
final int callingUid = Binder.getCallingUid();
final int callingPid = Binder.getCallingPid();
final int resolvedUserId = resolveCallingUserId(callingPid, callingUid, userId,
"notifyRecordingStopped");
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
try {
SessionState sessionState = getSessionStateLocked(sessionToken, callingUid,
resolvedUserId);
getSessionLocked(sessionState).notifyRecordingStopped(recordingId);
} catch (RemoteException | SessionNotFoundException e) {
Slogf.e(TAG, "error in notifyRecordingStopped", e);
}
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
@Override