Implement setTvMessageEnabled
Bug: 273823812 Test: atest TvInputServiceTest Change-Id: I439214e726827d47d30a9629ea6bba8b893536e8
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -79,4 +79,5 @@ oneway interface ITvInputSession {
|
||||
|
||||
// For TV messages
|
||||
void notifyTvMessage(int type, in Bundle data);
|
||||
void setTvMessageEnabled(int type, boolean enabled);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -3273,7 +3273,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) {
|
||||
@@ -3281,6 +3281,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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user