Merge "vibrator: fix issue with ledtrig-transient support" am: 60849b8da4 am: 95d22ed018

am: fdfbcda7ad

Change-Id: Ib2df8e109d5842e3d3eaa0846a153c997908d967
This commit is contained in:
David Lin 2017-03-11 01:35:14 +00:00 committed by android-build-merger
commit 488c55c858

View file

@ -32,16 +32,20 @@
static const char THE_DEVICE[] = "/sys/class/timed_output/vibrator/enable"; static const char THE_DEVICE[] = "/sys/class/timed_output/vibrator/enable";
static int vibra_exists() { static bool device_exists(const char *file) {
int fd; int fd;
fd = TEMP_FAILURE_RETRY(open(THE_DEVICE, O_RDWR)); fd = TEMP_FAILURE_RETRY(open(file, O_RDWR));
if(fd < 0) { if(fd < 0) {
return 0; return false;
} }
close(fd); close(fd);
return 1; return true;
}
static bool vibra_exists() {
return device_exists(THE_DEVICE);
} }
static int write_value(const char *file, const char *value) static int write_value(const char *file, const char *value)
@ -102,9 +106,13 @@ static int write_led_file(const char *file, const char *value)
return write_value(file_str, value); return write_value(file_str, value);
} }
static int vibra_led_exists() static bool vibra_led_exists()
{ {
return !write_led_file("trigger", "transient"); int fd;
char file_str[50];
snprintf(file_str, sizeof(file_str), "%s/%s", LED_DEVICE, "activate");
return device_exists(file_str);
} }
static int vibra_led_on(vibrator_device_t* vibradev __unused, unsigned int timeout_ms) static int vibra_led_on(vibrator_device_t* vibradev __unused, unsigned int timeout_ms)