• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Révisione88c967073070679cc114579023cd0dbe0ddb5f7 (tree)
l'heure2016-07-27 03:49:13
AuteurAndrew Boie <andrew.p.boie@inte...>
CommiterJaap Jan Meijer

Message de Log

adb: reserve a wakelock when clients are connected over socket

USB OTG connections already have a wakelock reserved, but if a network
socket connection is made, the device can unexpectedly suspend
in the middle of a session. The lock is released when the client
disconnects.

Change-Id: Id5ac01699fab9350955c9814042259542fc6a694
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>

Change Summary

Modification

--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -44,7 +44,46 @@
4444 ADB_MUTEX_DEFINE( local_transports_lock );
4545
4646 static atransport* local_transports[ ADB_LOCAL_TRANSPORT_MAX ];
47-#endif /* ADB_HOST */
47+#else /* !ADB_HOST */
48+
49+#define WAKE_LOCK_NAME "adb-socket-connection"
50+#define WAKE_LOCK_ACQUIRE "/sys/power/wake_lock"
51+#define WAKE_LOCK_RELEASE "/sys/power/wake_unlock"
52+
53+static int sysfs_write(const char *node, const char *message)
54+{
55+ int fd;
56+ ssize_t to_write;
57+ int ret = 0;
58+
59+ fd = adb_open(node, O_RDWR);
60+ if (!fd) {
61+ D("open '%s' failed: %s\n", node, strerror(errno));
62+ return -1;
63+ }
64+
65+ to_write = strlen(message);
66+ if (adb_write(fd, message, to_write) != to_write) {
67+ D("write '%s' failed: %s\n", node, strerror(errno));
68+ ret = -1;
69+ }
70+ adb_close(fd);
71+ return ret;
72+}
73+
74+static void get_wakelock(void)
75+{
76+ if (sysfs_write(WAKE_LOCK_ACQUIRE, WAKE_LOCK_NAME))
77+ D("couldn't reserve wakelock for socket connection\n");
78+}
79+
80+static void release_wakelock(void)
81+{
82+ if (sysfs_write(WAKE_LOCK_RELEASE, WAKE_LOCK_NAME))
83+ D("couldn't release wakelock for socket connection\n");
84+}
85+
86+#endif /* !ADB_HOST */
4887
4988 static int remote_read(apacket *p, atransport *t)
5089 {
@@ -157,6 +196,9 @@ static void *server_socket_thread(void * arg)
157196 fd = adb_socket_accept(serverfd, &addr, &alen);
158197 if(fd >= 0) {
159198 D("server: new connection on fd %d\n", fd);
199+#if !ADB_HOST
200+ get_wakelock();
201+#endif
160202 close_on_exec(fd);
161203 disable_tcp_nagle(fd);
162204 register_socket_transport(fd, "host", port, 1);
@@ -334,6 +376,9 @@ static void remote_kick(atransport *t)
334376
335377 static void remote_close(atransport *t)
336378 {
379+#if !ADB_HOST
380+ release_wakelock();
381+#endif
337382 adb_close(t->fd);
338383 }
339384