• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

system/core


Commit MetaInfo

Revisionadbd6c30a6e37938e5c0f3b0699f4a5990209f13 (tree)
Zeit2010-02-27 16:12:49
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

hotplug.c: handle add bluetooth rfkill events

Change the permission and owner of state to be bluetooth service accessible.

Ändern Zusammenfassung

Diff

--- a/toolbox/hotplug.c
+++ b/toolbox/hotplug.c
@@ -1,7 +1,7 @@
11 /*
22 * Simple hotplug tool
33 *
4- * by Chih-Wei Huang <cwhuang@linux.org.tw> 2009/08/03
4+ * by Chih-Wei Huang <cwhuang@linux.org.tw> 2009/11/06
55 *
66 */
77
@@ -12,6 +12,8 @@
1212 #include <sys/stat.h>
1313 #include <unistd.h>
1414
15+#include "private/android_filesystem_config.h"
16+
1517 #define HOTPLUG_LOG "/tmp/hotplug.log"
1618 #define FIRMWARE_PATH "/system/lib/firmware"
1719
@@ -46,8 +48,7 @@ static int load_firmware()
4648 goto clean3;
4749 }
4850 }
49- if (write(loading_fd, "0", 1) == 1)
50- ret = 0;
51+ ret = !(write(loading_fd, "0", 1) == 1);
5152
5253 clean3:
5354 close(data_fd);
@@ -59,6 +60,25 @@ static int load_firmware()
5960 return ret;
6061 }
6162
63+static int set_rfkill()
64+{
65+ int ret = -1;
66+ if (strcmp(getenv("RFKILL_TYPE"), "bluetooth") == 0) {
67+ chdir("/sys");
68+ chdir(getenv("DEVPATH") + 1);
69+ ret = chown("state", AID_BLUETOOTH, AID_BLUETOOTH);
70+ ret |= chmod("state", S_IRUSR|S_IRGRP|S_IWUSR|S_IWGRP);
71+#if 0 /* we may not need the hack */
72+ if (!strncmp(getenv("RFKILL_NAME"), "hci", 3) && !strcmp(getenv("RFKILL_STATE"), "0")) {
73+ int fd = open("state", O_WRONLY);
74+ if (fd >= 0)
75+ ret |= !(write(fd, "1", 1) == 1);
76+ }
77+#endif
78+ }
79+ return ret;
80+}
81+
6282 int hotplug_main(int argc, char **argv)
6383 {
6484 int ret = -1;
@@ -88,6 +108,8 @@ int hotplug_main(int argc, char **argv)
88108 if (strcmp(action, "add") == 0) {
89109 if (strcmp(argv[1], "firmware") == 0)
90110 ret = load_firmware();
111+ else if (strcmp(argv[1], "rfkill") == 0)
112+ ret = set_rfkill();
91113 }
92114 }
93115 return ret;