summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJae Seo <jaeseo@google.com>2014-04-17 21:35:29 -0700
committerJae Seo <jaeseo@google.com>2014-04-29 14:18:55 +0900
commit6a6059a29edf31e65541b3d8927a46f5846fb0a2 (patch)
treeda667bb3062a0945c36f63d6c62e16598852399b /services
parent6d50c3ff8815e6fedd1f80ba7afb8f1d22ea45b7 (diff)
downloadframeworks_base-6a6059a29edf31e65541b3d8927a46f5846fb0a2.zip
frameworks_base-6a6059a29edf31e65541b3d8927a46f5846fb0a2.tar.gz
frameworks_base-6a6059a29edf31e65541b3d8927a46f5846fb0a2.tar.bz2
Dispatch input events to the TV input
TvInputManagerService now creates an InputChannel pair and passes one end to the app and the other end to the service. Then the TvInputManager in the app creates an InputEventSender around one end of the channel to send events and the service creates an InputEventReceiver around the other end of the channel to receive events. Most of the newly added code here was borrowed heavily from the IME. Change-Id: I0bd83847cba0033ccb6f4b6dad267ebeaf5e9c7c
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/tv/TvInputManagerService.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 5ceb992..649f9dc 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -49,9 +49,9 @@ import android.tv.ITvInputSession;
import android.tv.ITvInputSessionCallback;
import android.tv.TvInputInfo;
import android.tv.TvInputService;
-import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
+import android.view.InputChannel;
import android.view.Surface;
import com.android.internal.content.PackageMonitor;
@@ -292,6 +292,9 @@ public final class TvInputManagerService extends SystemService {
Slog.d(TAG, "createSessionInternalLocked(name=" + sessionState.name.getClassName()
+ ")");
}
+
+ final InputChannel[] channels = InputChannel.openInputChannelPair(sessionToken.toString());
+
// Set up a callback to send the session token.
ITvInputSessionCallback callback = new ITvInputSessionCallback.Stub() {
@Override
@@ -304,30 +307,32 @@ public final class TvInputManagerService extends SystemService {
if (session == null) {
removeSessionStateLocked(sessionToken, userId);
sendSessionTokenToClientLocked(sessionState.client, sessionState.name, null,
- sessionState.seq, userId);
+ null, sessionState.seq, userId);
} else {
sendSessionTokenToClientLocked(sessionState.client, sessionState.name,
- sessionToken, sessionState.seq, userId);
+ sessionToken, channels[0], sessionState.seq, userId);
}
+ channels[0].dispose();
}
}
};
// Create a session. When failed, send a null token immediately.
try {
- service.createSession(callback);
+ service.createSession(channels[1], callback);
} catch (RemoteException e) {
Slog.e(TAG, "error in createSession", e);
removeSessionStateLocked(sessionToken, userId);
- sendSessionTokenToClientLocked(sessionState.client, sessionState.name, null,
+ sendSessionTokenToClientLocked(sessionState.client, sessionState.name, null, null,
sessionState.seq, userId);
}
+ channels[1].dispose();
}
private void sendSessionTokenToClientLocked(ITvInputClient client, ComponentName name,
- IBinder sessionToken, int seq, int userId) {
+ IBinder sessionToken, InputChannel channel, int seq, int userId) {
try {
- client.onSessionCreated(name, sessionToken, seq);
+ client.onSessionCreated(name, sessionToken, channel, seq);
} catch (RemoteException exception) {
Slog.e(TAG, "error in onSessionCreated", exception);
}
@@ -834,7 +839,7 @@ public final class TvInputManagerService extends SystemService {
return;
}
default: {
- Log.w(TAG, "Unhandled message code: " + msg.what);
+ Slog.w(TAG, "Unhandled message code: " + msg.what);
return;
}
}