am 31f31f10: am 0e29adb6: am bf1a0ff0: TIF: Add sendAppPrivateCommand()
* commit '31f31f10de63b562b2137c7ca7b22472bfb9a7e3': TIF: Add sendAppPrivateCommand()
This commit is contained in:
@@ -26,6 +26,7 @@ import android.media.tv.TvInputHardwareInfo;
|
||||
import android.media.tv.TvInputInfo;
|
||||
import android.media.tv.TvTrackInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Surface;
|
||||
|
||||
/**
|
||||
@@ -51,6 +52,9 @@ interface ITvInputManager {
|
||||
void selectTrack(in IBinder sessionToken, in TvTrackInfo track, int userId);
|
||||
void unselectTrack(in IBinder sessionToken, in TvTrackInfo track, int userId);
|
||||
|
||||
void sendAppPrivateCommand(in IBinder sessionToken, in String action, in Bundle data,
|
||||
int userId);
|
||||
|
||||
void createOverlayView(in IBinder sessionToken, in IBinder windowToken, in Rect frame,
|
||||
int userId);
|
||||
void relayoutOverlayView(in IBinder sessionToken, in Rect frame, int userId);
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.media.tv;
|
||||
import android.graphics.Rect;
|
||||
import android.media.tv.TvTrackInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Surface;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,8 @@ oneway interface ITvInputSession {
|
||||
void selectTrack(in TvTrackInfo track);
|
||||
void unselectTrack(in TvTrackInfo track);
|
||||
|
||||
void appPrivateCommand(in String action, in Bundle data);
|
||||
|
||||
void createOverlayView(in IBinder windowToken, in Rect frame);
|
||||
void relayoutOverlayView(in Rect frame);
|
||||
void removeOverlayView();
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.media.tv;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
@@ -48,10 +49,11 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
|
||||
private static final int DO_SET_CAPTION_ENABLED = 6;
|
||||
private static final int DO_SELECT_TRACK = 7;
|
||||
private static final int DO_UNSELECT_TRACK = 8;
|
||||
private static final int DO_CREATE_OVERLAY_VIEW = 9;
|
||||
private static final int DO_RELAYOUT_OVERLAY_VIEW = 10;
|
||||
private static final int DO_REMOVE_OVERLAY_VIEW = 11;
|
||||
private static final int DO_REQUEST_UNBLOCK_CONTENT = 12;
|
||||
private static final int DO_APP_PRIVATE_COMMAND = 9;
|
||||
private static final int DO_CREATE_OVERLAY_VIEW = 10;
|
||||
private static final int DO_RELAYOUT_OVERLAY_VIEW = 11;
|
||||
private static final int DO_REMOVE_OVERLAY_VIEW = 12;
|
||||
private static final int DO_REQUEST_UNBLOCK_CONTENT = 13;
|
||||
|
||||
private final HandlerCaller mCaller;
|
||||
|
||||
@@ -119,6 +121,12 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
|
||||
mTvInputSessionImpl.unselectTrack((TvTrackInfo) msg.obj);
|
||||
return;
|
||||
}
|
||||
case DO_APP_PRIVATE_COMMAND: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
mTvInputSessionImpl.appPrivateCommand((String) args.arg1, (Bundle) args.arg2);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_CREATE_OVERLAY_VIEW: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
mTvInputSessionImpl.createOverlayView((IBinder) args.arg1, (Rect) args.arg2);
|
||||
@@ -185,6 +193,12 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
|
||||
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_UNSELECT_TRACK, track));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appPrivateCommand(String action, Bundle data) {
|
||||
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_APP_PRIVATE_COMMAND, action,
|
||||
data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createOverlayView(IBinder windowToken, Rect frame) {
|
||||
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_CREATE_OVERLAY_VIEW, windowToken,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.media.tv;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -893,6 +894,29 @@ public final class TvInputManager {
|
||||
mTracks = tracks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link TvInputService.Session#appPrivateCommand(String, Bundle)
|
||||
* TvInputService.Session.appPrivateCommand()} on the current TvView.
|
||||
*
|
||||
* @param action Name of the command to be performed. This <em>must</em> be a scoped name,
|
||||
* i.e. prefixed with a package name you own, so that different developers will
|
||||
* not create conflicting commands.
|
||||
* @param data Any data to include with the command.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public void sendAppPrivateCommand(String action, Bundle data) {
|
||||
if (mToken == null) {
|
||||
Log.w(TAG, "The session has been already released");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mService.sendAppPrivateCommand(mToken, action, data, mUserId);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an overlay view. Once the overlay view is created, {@link #relayoutOverlayView}
|
||||
* should be called whenever the layout of its containing view is changed.
|
||||
|
||||
@@ -518,6 +518,21 @@ public abstract class TvInputService extends Service {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a private command sent from the application to the TV input. This can be used
|
||||
* to provide domain-specific features that are only known between certain TV inputs and
|
||||
* their clients.
|
||||
*
|
||||
* @param action Name of the command to be performed. This <em>must</em> be a scoped name,
|
||||
* i.e. prefixed with a package name you own, so that different developers will
|
||||
* not create conflicting commands.
|
||||
* @param data Any data to include with the command.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public void onAppPrivateCommand(String action, Bundle data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an application requests to create an overlay view. Each session
|
||||
* implementation can override this method and return its own view.
|
||||
@@ -725,6 +740,13 @@ public abstract class TvInputService extends Service {
|
||||
// TODO: Handle failure.
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #onAppPrivateCommand}.
|
||||
*/
|
||||
void appPrivateCommand(String action, Bundle data) {
|
||||
onAppPrivateCommand(action, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an overlay view. This calls {@link #onCreateOverlayView} to get a view to attach
|
||||
* to the overlay window.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.media.tv;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.media.tv.TvInputManager.Session;
|
||||
@@ -290,6 +291,26 @@ public class TvView extends ViewGroup {
|
||||
return mSession.getTracks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link TvInputService.Session#appPrivateCommand(String, Bundle)
|
||||
* TvInputService.Session.appPrivateCommand()} on the current TvView.
|
||||
*
|
||||
* @param action Name of the command to be performed. This <em>must</em> be a scoped name, i.e.
|
||||
* prefixed with a package name you own, so that different developers will not create
|
||||
* conflicting commands.
|
||||
* @param data Any data to include with the command.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public void sendAppPrivateCommand(String action, Bundle data) {
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
throw new IllegalArgumentException("action cannot be null or an empty string");
|
||||
}
|
||||
if (mSession != null) {
|
||||
mSession.sendAppPrivateCommand(action, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an unhandled input event to the next receiver.
|
||||
* <p>
|
||||
|
||||
@@ -1115,6 +1115,27 @@ public final class TvInputManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAppPrivateCommand(IBinder sessionToken, String command, Bundle data,
|
||||
int userId) {
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
|
||||
userId, "sendAppPrivateCommand");
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
try {
|
||||
getSessionLocked(sessionToken, callingUid, resolvedUserId)
|
||||
.appPrivateCommand(command, data);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "error in sendAppPrivateCommand", e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createOverlayView(IBinder sessionToken, IBinder windowToken, Rect frame,
|
||||
int userId) {
|
||||
|
||||
Reference in New Issue
Block a user