summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-06-17 13:26:25 +0200
committerDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-06-17 13:26:25 +0200
commit24e474c44c9cf82ed4b4a0b7e06cec4aa0eec408 (patch)
treebbb74f082cd6d44a351342ddec507cb80ff99dff
parenta24f04fafd95854c75097bff12c2030e973662c9 (diff)
downloaddevice_samsung_i9300-24e474c44c9cf82ed4b4a0b7e06cec4aa0eec408.zip
device_samsung_i9300-24e474c44c9cf82ed4b4a0b7e06cec4aa0eec408.tar.gz
device_samsung_i9300-24e474c44c9cf82ed4b4a0b7e06cec4aa0eec408.tar.bz2
added macloader for wifi
-rw-r--r--galaxys3_base.mk1
-rwxr-xr-xinit.smdk4x12.rc8
-rw-r--r--macloader/Android.mk13
-rw-r--r--macloader/macloader.cpp111
4 files changed, 129 insertions, 4 deletions
diff --git a/galaxys3_base.mk b/galaxys3_base.mk
index 4d25e31..dae76e1 100644
--- a/galaxys3_base.mk
+++ b/galaxys3_base.mk
@@ -71,6 +71,7 @@ PRODUCT_PACKAGES := \
audio.a2dp.default \
camera.exynos4 \
Camera \
+ macloader \
com.android.future.usb.accessory \
GalaxyS3Settings \
SamsungServiceMode \
diff --git a/init.smdk4x12.rc b/init.smdk4x12.rc
index a47188a..0006473 100755
--- a/init.smdk4x12.rc
+++ b/init.smdk4x12.rc
@@ -347,10 +347,6 @@ on post-fs-data
mkdir /data/misc/dhcp 0775 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp
- write /data/.cid.info murata
- chown system wifi /data/.cid.info
- chmod 0660 /data/.cid.info
-
# for TRP/TIS
write /data/.psm.info 1
chown system root /data/.psm.info
@@ -469,6 +465,10 @@ service iprenew_bnep0 /system/bin/dhcpcd -n
disabled
oneshot
+service macloader /system/bin/macloader
+ class main
+ oneshot
+
# GPS
service gpsd /system/bin/gpsd -c /system/etc/gps.xml
class main
diff --git a/macloader/Android.mk b/macloader/Android.mk
new file mode 100644
index 0000000..14dc2c6
--- /dev/null
+++ b/macloader/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ macloader.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog libutils
+
+LOCAL_MODULE := macloader
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
diff --git a/macloader/macloader.cpp b/macloader/macloader.cpp
new file mode 100644
index 0000000..de29b0d
--- /dev/null
+++ b/macloader/macloader.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2012, The CyanogenMod Project
+ * Daniel Hillenbrand <codeworkx@cyanogenmod.com>
+ * Marco Hillenbrand <marco.hillenbrand@googlemail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <cutils/log.h>
+
+#define LOG_TAG "macloader"
+#define LOG_NDEBUG 0
+
+#define MACADDR_PATH "/efs/wifi/.mac.info"
+#define CID_PATH "/data/.cid.info"
+
+/*
+ * murata:
+ * 00:37:6d
+ * 88:30:8a
+ *
+ * semcove:
+ *
+ */
+
+int main() {
+ FILE* file;
+ FILE* cidfile;
+ char* str;
+ char mac_addr_half[9];
+ int ret = -1;
+ int amode;
+
+ /* open mac addr file */
+ file = fopen(MACADDR_PATH, "r");
+ if(file == 0) {
+ fprintf(stderr, "open(%s) failed\n", MACADDR_PATH);
+ LOGE("Can't open %s\n", MACADDR_PATH);
+ return -1;
+ }
+
+ /* get and compare mac addr */
+ str = fgets(mac_addr_half, 9, file);
+ if(str == 0) {
+ fprintf(stderr, "fgets() from file %s failed\n", MACADDR_PATH);
+ LOGE("Can't read from %s\n", MACADDR_PATH);
+ return -1;
+ }
+
+ /* murata */
+ if(strncmp(mac_addr_half, "00:37:6d", 9) == 0 || strncmp(mac_addr_half, "88:30:8a", 9) == 0) {
+
+ /* open cid file */
+ cidfile = fopen(CID_PATH, "w");
+ if(cidfile == 0) {
+ fprintf(stderr, "open(%s) failed\n", CID_PATH);
+ LOGE("Can't open %s\n", CID_PATH);
+ return -1;
+ }
+
+ /* write murata to cid file */
+ LOGD("Writing murata to %s\n", CID_PATH);
+ ret = fputs("murata", cidfile);
+ if(ret != 0) {
+ fprintf(stderr, "fputs() to file %s failed\n", CID_PATH);
+ LOGE("Can't write to %s\n", CID_PATH);
+ return -1;
+ }
+ fclose(cidfile);
+
+ /* set permissions on cid file */
+ LOGD("Setting permissions on %s\n", CID_PATH);
+ amode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+ ret = chmod(CID_PATH, amode);
+
+ char* chown_cmd = (char*) malloc(strlen("chown system ") + strlen(CID_PATH));
+ char* chgrp_cmd = (char*) malloc(strlen("chgrp system ") + strlen(CID_PATH));
+ sprintf(chown_cmd, "chown system %s", CID_PATH);
+ sprintf(chgrp_cmd, "chgrp system %s", CID_PATH);
+ system(chown_cmd);
+ system(chgrp_cmd);
+
+ if(ret != 0) {
+ fprintf(stderr, "chmod() on file %s failed\n", CID_PATH);
+ LOGE("Can't set permissions on %s\n", CID_PATH);
+ return ret;
+ }
+
+ } else {
+ /* delete cid file if not murata or semcove */
+ LOGD("Deleting file %s\n", CID_PATH);
+ remove(CID_PATH);
+ }
+ fclose(file);
+ return 0;
+}