diff options
| author | Chirayu Desai <chirayudesai1@gmail.com> | 2016-02-20 18:33:43 +0530 |
|---|---|---|
| committer | David <Davidteri91@gmail.com> | 2016-10-03 13:09:00 +0200 |
| commit | edd34c03321ea59efdcfe7afc7a7baa946ae2a09 (patch) | |
| tree | e08df45d6f546c0ad305fdac0aaf99144b66a12f | |
| parent | ca5eecb4c791fcbcd340fa0984427114c400b3b5 (diff) | |
Bring in some improvements done previously
* Some changes were done to AOSP macaddrsetup when it was initially
brought in for rhine, see http://review.cyanogenmod.org/117270
* Bring them in again, as they've been done after toying around
with MAC address handling quite a bit, and settling on this,
having tested multiple use cases
Change-Id: I5b2ec650e31f573874e37b4df9bd191e56cec6b8
| -rw-r--r-- | macaddrsetup.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/macaddrsetup.c b/macaddrsetup.c index 58073d5..90f369c 100644 --- a/macaddrsetup.c +++ b/macaddrsetup.c @@ -4,11 +4,15 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> #include <cutils/properties.h> +#include <private/android_filesystem_config.h> #define LOG_TAG "macaddrsetup" #include <cutils/log.h> +#define BT_MAC_FILE "/data/etc/bluetooth_bdaddr" + extern const char *__progname; extern int ta_open(uint8_t p, uint8_t m, uint8_t c); extern int ta_close(void); @@ -20,36 +24,12 @@ int main(int argc, char **argv) uint32_t size; char buf[6]; FILE *fpb, *fpw = NULL; - char record[PROPERTY_VALUE_MAX]; int ret, err, bt_addr, wl_addr; - property_get("ro.hardware",record,""); - SLOGI("Importing BT and WLAN address for %s device\n", record); - - if ((strcmp(record,"seagull")==0)||(strcmp(record,"tianchi")==0)){ - wl_addr=2560; - bt_addr=2568; - } else if ((strcmp(record,"amami")==0)||(strcmp(record,"honami")==0)||(strcmp(record,"togari")==0)){ - wl_addr=2560; - bt_addr=2568; - } else if ((strcmp(record,"sirius")==0)||(strcmp(record,"castor")==0)||(strcmp(record,"castor_windy")==0)||(strcmp(record,"leo")==0) - ||(strcmp(record,"aries")==0)||(strcmp(record,"scorpion")==0)||(strcmp(record,"scorpion_windy")==0)){ - wl_addr=2560; - bt_addr=2568; - } else if ((strcmp(record,"tulip")==0)){ - wl_addr=2560; - bt_addr=2568; - } else if ((strcmp(record,"ivy")==0)||(strcmp(record,"karin")==0)||(strcmp(record,"karin_windy")==0)||(strcmp(record,"sumire")==0) - ||(strcmp(record,"suzuran")==0)||(strcmp(record,"satsuki")==0)){ - wl_addr=2560; - bt_addr=2568; - } else if ((strcmp(record,"kugo")==0)||(strcmp(record,"suzu")==0)){ - wl_addr=2560; - bt_addr=2568; - } else { - SLOGE("Unsupported device\n"); - exit(1); - } + // Sony had a check for ro.hardware here, but since all supported devices were added here anyways, + // and the values are the same, it has been removed. + wl_addr=2560; + bt_addr=2568; for (;;) { err = ta_open(2, 0x1, 1); @@ -60,9 +40,9 @@ int main(int argc, char **argv) sleep(5); } - fpb = fopen("/data/etc/bluetooth_bdaddr", "w"); + fpb = fopen(BT_MAC_FILE, "w"); if (!fpb) { - SLOGE("failed to open /data/etc/bluetooth_bdaddr for writing:\n"); + SLOGE("failed to open %s for writing\n", BT_MAC_FILE); ta_close(); exit(1); } @@ -90,6 +70,8 @@ int main(int argc, char **argv) fclose(fpb); exit(1); } + chown(BT_MAC_FILE, AID_BLUETOOTH, AID_BLUETOOTH); + chmod(BT_MAC_FILE, S_IRUSR | S_IWUSR | S_IRGRP); // 640 if (argc > 1) { fpw = fopen(argv[1], "w"); |
