Add IBinder extensions to TvInputService

Bug: 149941356
Test: todo
Change-Id: I6cc0acf504048721cacdb93c51152d4653d1b6a2
This commit is contained in:
Nick Chalko
2020-03-05 10:00:15 -08:00
committed by Henry Fang
parent 674f06fc93
commit 86e90122be
3 changed files with 25 additions and 2 deletions

View File

@@ -4910,6 +4910,7 @@ package android.media.tv {
}
public abstract class TvInputService extends android.app.Service {
method @Nullable public android.os.IBinder createExtension();
method @Nullable public android.media.tv.TvInputInfo onHardwareAdded(android.media.tv.TvInputHardwareInfo);
method @Nullable public String onHardwareRemoved(android.media.tv.TvInputHardwareInfo);
method @Nullable public android.media.tv.TvInputInfo onHdmiDeviceAdded(android.hardware.hdmi.HdmiDeviceInfo);

View File

@@ -152,7 +152,7 @@ public abstract class TvInputService extends Service {
@Override
public final IBinder onBind(Intent intent) {
return new ITvInputService.Stub() {
ITvInputService.Stub tvInputServiceBinder = new ITvInputService.Stub() {
@Override
public void registerCallback(ITvInputServiceCallback cb) {
if (cb != null) {
@@ -181,7 +181,8 @@ public abstract class TvInputService extends Service {
args.arg2 = cb;
args.arg3 = inputId;
args.arg4 = sessionId;
mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_SESSION, args).sendToTarget();
mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_SESSION,
args).sendToTarget();
}
@Override
@@ -228,6 +229,26 @@ public abstract class TvInputService extends Service {
deviceInfo).sendToTarget();
}
};
IBinder ext = createExtension();
if (ext != null) {
tvInputServiceBinder.setExtension(ext);
}
return tvInputServiceBinder;
}
/**
* Returns a new {@link android.os.Binder}
*
* <p> if an extension is provided on top of existing {@link TvInputService}; otherwise,
* return {@code null}. Override to provide extended interface.
*
* @see android.os.Binder#setExtension(IBinder)
* @hide
*/
@Nullable
@SystemApi
public IBinder createExtension() {
return null;
}
/**

View File

@@ -4850,6 +4850,7 @@ package android.media.tv {
}
public abstract class TvInputService extends android.app.Service {
method @Nullable public android.os.IBinder createExtension();
method @Nullable public android.media.tv.TvInputInfo onHardwareAdded(android.media.tv.TvInputHardwareInfo);
method @Nullable public String onHardwareRemoved(android.media.tv.TvInputHardwareInfo);
method @Nullable public android.media.tv.TvInputInfo onHdmiDeviceAdded(android.hardware.hdmi.HdmiDeviceInfo);