summaryrefslogtreecommitdiffstats
path: root/wear_touch.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2017-09-08 13:50:54 +0200
committerEthan Yonker <dees_troy@teamw.in>2017-09-08 14:14:59 +0200
commit8373cfe28cf1b5ad758faa1d502e21787c3665e4 (patch)
tree2f567c52cd6f89e1052481497d236b58d230b7e2 /wear_touch.cpp
parentDO NOT MERGE Android 8.0 stuff (diff)
parentrelease-request-f4ecf242-5d1c-45e0-8c7c-ede48d1a9e82-for-git_oc-release-4111650 snap-temp-L02200000075283731 (diff)
downloadandroid_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.gz
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.bz2
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.lz
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.xz
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.zst
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.zip
Diffstat (limited to 'wear_touch.cpp')
-rw-r--r--wear_touch.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/wear_touch.cpp b/wear_touch.cpp
index f22d40b88..e2ab44d2d 100644
--- a/wear_touch.cpp
+++ b/wear_touch.cpp
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-#include "common.h"
-#include "wear_touch.h"
-
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
@@ -25,8 +22,11 @@
#include <errno.h>
#include <string.h>
+#include <android-base/logging.h>
#include <linux/input.h>
+#include "wear_touch.h"
+
#define DEVICE_PATH "/dev/input"
WearSwipeDetector::WearSwipeDetector(int low, int high, OnSwipeCallback callback, void* cookie):
@@ -49,11 +49,11 @@ void WearSwipeDetector::detect(int dx, int dy) {
} else if (abs(dx) < mLowThreshold && abs(dy) > mHighThreshold) {
direction = dy < 0 ? UP : DOWN;
} else {
- LOGD("Ignore %d %d\n", dx, dy);
+ LOG(DEBUG) << "Ignore " << dx << " " << dy;
return;
}
- LOGD("Swipe direction=%d\n", direction);
+ LOG(DEBUG) << "Swipe direction=" << direction;
mCallback(mCookie, direction);
}
@@ -105,7 +105,7 @@ void WearSwipeDetector::process(struct input_event *event) {
void WearSwipeDetector::run() {
int fd = findDevice(DEVICE_PATH);
if (fd < 0) {
- LOGE("no input devices found\n");
+ LOG(ERROR) << "no input devices found";
return;
}
@@ -118,23 +118,23 @@ void WearSwipeDetector::run() {
}
void* WearSwipeDetector::touch_thread(void* cookie) {
- ((WearSwipeDetector*)cookie)->run();
+ (static_cast<WearSwipeDetector*>(cookie))->run();
return NULL;
}
-#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
+#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
int WearSwipeDetector::openDevice(const char *device) {
int fd = open(device, O_RDONLY);
if (fd < 0) {
- LOGE("could not open %s, %s\n", device, strerror(errno));
+ PLOG(ERROR) << "could not open " << device;
return false;
}
char name[80];
name[sizeof(name) - 1] = '\0';
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
- LOGE("could not get device name for %s, %s\n", device, strerror(errno));
+ PLOG(ERROR) << "could not get device name for " << device;
name[0] = '\0';
}
@@ -143,7 +143,7 @@ int WearSwipeDetector::openDevice(const char *device) {
int ret = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits);
if (ret > 0) {
if (test_bit(ABS_MT_POSITION_X, bits) && test_bit(ABS_MT_POSITION_Y, bits)) {
- LOGD("Found %s %s\n", device, name);
+ LOG(DEBUG) << "Found " << device << " " << name;
return fd;
}
}
@@ -155,7 +155,7 @@ int WearSwipeDetector::openDevice(const char *device) {
int WearSwipeDetector::findDevice(const char* path) {
DIR* dir = opendir(path);
if (dir == NULL) {
- LOGE("Could not open directory %s", path);
+ PLOG(ERROR) << "Could not open directory " << path;
return false;
}