Merge "Implement setTvMessageEnabled" into udc-dev

This commit is contained in:
David Zhao
2023-03-17 05:08:05 +00:00
committed by Android (Google) Code Review
6 changed files with 47 additions and 3 deletions

View File

@@ -120,6 +120,7 @@ interface ITvInputManager {
// For TV Message
void notifyTvMessage(in IBinder sessionToken, int type, in Bundle data, int userId);
void setTvMessageEnabled(in IBinder sessionToken, int type, boolean enabled, int userId);
// For TV input hardware binding
List<TvInputHardwareInfo> getHardwareList();

View File

@@ -79,4 +79,5 @@ oneway interface ITvInputSession {
// For TV messages
void notifyTvMessage(int type, in Bundle data);
void setTvMessageEnabled(int type, boolean enabled);
}

View File

@@ -268,6 +268,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
case DO_SET_TV_MESSAGE_ENABLED: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.setTvMessageEnabled((Integer) args.arg1, (Boolean) args.arg2);
args.recycle();
break;
}
case DO_REQUEST_AD: {
@@ -474,6 +475,12 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_NOTIFY_TV_MESSAGE, type, data));
}
@Override
public void setTvMessageEnabled(int type, boolean enabled) {
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_SET_TV_MESSAGE_ENABLED, type,
enabled));
}
private final class TvInputEventReceiver extends InputEventReceiver {
TvInputEventReceiver(InputChannel inputChannel, Looper looper) {
super(inputChannel, looper);

View File

@@ -3305,7 +3305,7 @@ public final class TvInputManager {
/**
* Sends TV messages to the service for testing purposes
*/
public void notifyTvMessage(@NonNull @TvMessageType int type, @NonNull Bundle data) {
public void notifyTvMessage(int type, Bundle data) {
try {
mService.notifyTvMessage(mToken, type, data, mUserId);
} catch (RemoteException e) {
@@ -3313,6 +3313,17 @@ public final class TvInputManager {
}
}
/**
* Sets whether the TV message of the specific type should be enabled.
*/
public void setTvMessageEnabled(int type, boolean enabled) {
try {
mService.setTvMessageEnabled(mToken, type, enabled, mUserId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Starts TV program recording in the current recording session.
*

View File

@@ -745,6 +745,9 @@ public class TvView extends ViewGroup {
*/
public void setTvMessageEnabled(@TvInputManager.TvMessageType int type,
boolean enabled) {
if (mSession != null) {
mSession.setTvMessageEnabled(type, enabled);
}
}
@Override

View File

@@ -2128,7 +2128,7 @@ public final class TvInputManagerService extends SystemService {
public void notifyTvMessage(IBinder sessionToken, int type, Bundle data, int userId) {
final int callingUid = Binder.getCallingUid();
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
userId, "timeShiftEnablePositionTracking");
userId, "notifyTvmessage");
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
@@ -2136,7 +2136,28 @@ public final class TvInputManagerService extends SystemService {
getSessionLocked(sessionToken, callingUid, resolvedUserId)
.notifyTvMessage(type, data);
} catch (RemoteException | SessionNotFoundException e) {
Slog.e(TAG, "error in timeShiftEnablePositionTracking", e);
Slog.e(TAG, "error in notifyTvMessage", e);
}
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
@Override
public void setTvMessageEnabled(IBinder sessionToken, int type, boolean enabled,
int userId) {
final int callingUid = Binder.getCallingUid();
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
userId, "setTvMessageEnabled");
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
try {
getSessionLocked(sessionToken, callingUid, resolvedUserId)
.setTvMessageEnabled(type, enabled);
} catch (RemoteException | SessionNotFoundException e) {
Slog.e(TAG, "error in setTvMessageEnabled", e);
}
}
} finally {