diff --git a/universal7885-common/configs/props/vendor.prop b/universal7885-common/configs/props/vendor.prop index 7c98142..5e16674 100644 --- a/universal7885-common/configs/props/vendor.prop +++ b/universal7885-common/configs/props/vendor.prop @@ -27,18 +27,18 @@ wifi.direct.interface=p2p0 # Audio (APTX) # A2DP offload supported -ro.bluetooth.a2dp_offload.supported=true +ro.bluetooth.a2dp_offload.supported=false # A2DP offload disabled (UI toggle property) -persist.bluetooth.a2dp_offload.disabled=false +persist.bluetooth.a2dp_offload.disabled=true # A2DP offload DSP supported encoder list persist.bluetooth.a2dp_offload.cap=sbc-aac-aptx-aptxhd-ldac persist.vendor.bt.a2dp_offload_cap=sbc-aptx-aptxhd-aac-ldac persist.vendor.btstack.a2dp_offload_cap=sbc-aptx-aptxhd-aac-ldac -vendor.audio.feature.a2dp_offload.enable=true -persist.vendor.btstack.enable.splita2dp=true -vendor.audio.feature.a2dp_offload.enable=true +vendor.audio.feature.a2dp_offload.enable=false +persist.vendor.btstack.enable.splita2dp=false +vendor.audio.feature.a2dp_offload.enable=false audio.offload.min.duration.secs=30 vendor.audio.flac.sw.decoder.24bit=true vendor.audio.hal.boot.timeout.ms=20000 @@ -57,7 +57,7 @@ aaudio.mmap_exclusive_policy=2 aaudio.hw_burst_min_usec=2000 vendor.audio.enable.mirrorlink=false persist.vendor.bt.aac_frm_ctl.enabled=true -vendor.audio.feature.a2dp_offload.enable=true +vendor.audio.feature.a2dp_offload.enable=false vendor.audio.feature.afe_proxy.enable=true vendor.audio.feature.anc_headset.enable=true vendor.audio.feature.battery_listener.enable=true diff --git a/universal7885-common/inputmonitor/Android.bp b/universal7885-common/inputmonitor/Android.bp new file mode 100644 index 0000000..b455ea9 --- /dev/null +++ b/universal7885-common/inputmonitor/Android.bp @@ -0,0 +1,13 @@ +cc_binary { + name: "inputmonitor", + srcs: ["inputmonitor.cpp"], + shared_libs: [ + "libutils", + "liblog", + ], + cflags: [ + "-Wall", + "-Werror", + ], + init_rc: ["inputmonitor.rc"], +} diff --git a/universal7885-common/inputmonitor/inputmonitor.cpp b/universal7885-common/inputmonitor/inputmonitor.cpp new file mode 100755 index 0000000..160925d --- /dev/null +++ b/universal7885-common/inputmonitor/inputmonitor.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2021 Soo-Hean Na "Royna" + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define LOG_TAG "InputMonitor" +#include +#include + +static const char *const evval[3] = { + "RELEASED", + "PRESSED ", + "REPEATED" +}; + +using std::vector; +using std::string; +using namespace std::this_thread; // sleep_for, sleep_until +using namespace std::chrono; // nanoseconds, system_clock, seconds + +vector globVector(const string& pattern){ + glob_t glob_result; + glob(pattern.c_str(), GLOB_TILDE, NULL, &glob_result); + vector files; + for(unsigned int i = 0;i < glob_result.gl_pathc; ++i){ + files.push_back(string(glob_result.gl_pathv[i])); + } + globfree(&glob_result); + return files; +} +int detect_totalevents(){ + vector inputs = globVector("/sys/devices/virtual/input/"); + int count = 0; + for (int i = 0; i < inputs.size(); i++){ + if (inputs[i].rfind("input", 0) == 0) { + count++; + } + } + return count; +} + +char get_eventname(const char& sysfs_input){ + int fd; + char name; + ssize_t n; + fd = open(&sysfs_input, O_RDONLY); + if (fd == -1) { + ALOGE("Cannot open %c: errno %s.", sysfs_input, strerror(errno)); + return EXIT_FAILURE; + } + n = read(fd, &name, sizeof name); + if (n == (ssize_t) -1) { + ALOGE("Cannot read from %c.", sysfs_input); + } + return name; +} + +void monitor_input(const char& dev_node, const char& sysfs_input) +{ + struct input_event ev; + ssize_t n; + int fd; + bool fail; + fd = open(&dev_node, O_RDONLY); + if (fd == -1) { + ALOGE("Cannot open %c: errno %s.", dev_node, strerror(errno)); + } + fail = false; + while (fd != -1) { + n = read(fd, &ev, sizeof ev); + if (n == (ssize_t)-1) { + if (errno == EINTR) + continue; + else + fail = true; + break; + } else if (n != sizeof ev) { + errno = EIO; + break; + } + if (ev.type == EV_KEY && ev.value >= 0 && ev.value <= 2){ + ALOGI("%c (dev: %c) got keyevent %s (Keycode %d)", get_eventname(sysfs_input), dev_node, evval[ev.value], (int) ev.code); + } + sleep_until(system_clock::now() + milliseconds(100)); + + } + if (fail){ + ALOGE("Monitoring %c failed, errno = %s", dev_node, strerror(errno)); + } +} +int main(){ + int totalevents = detect_totalevents(); + vector eventlist = globVector("/sys/devices/virtual/input/"); + std::vector::iterator position = std::find(eventlist.begin(), eventlist.end(), "mice"); + if (position != eventlist.end()) // == eventlist.end() means the element was not found + eventlist.erase(position); + vector threads; + for (int k = 0; k < totalevents; k++){ + string number = eventlist[k].substr(5, 6); + auto dev_node = "/dev/input/event" + number; + auto sysfs_node = "/sys/devices/virtual/input/input" + number + "/name"; + threads.push_back(std::thread(monitor_input, *dev_node.c_str(), *sysfs_node.c_str())); + } + for (int k = 0; k < totalevents; k++){ + threads[k].join(); + } +} + + diff --git a/universal7885-common/inputmonitor/inputmonitor.rc b/universal7885-common/inputmonitor/inputmonitor.rc new file mode 100644 index 0000000..3a97483 --- /dev/null +++ b/universal7885-common/inputmonitor/inputmonitor.rc @@ -0,0 +1,5 @@ +service inputmonitor /system/bin/inputmonitor + class main + user root + group system + diff --git a/universal7885-common/sepolicy/private/file_contexts b/universal7885-common/sepolicy/private/file_contexts index d0618ad..9ad778a 100644 --- a/universal7885-common/sepolicy/private/file_contexts +++ b/universal7885-common/sepolicy/private/file_contexts @@ -2,3 +2,6 @@ ### DATA /data/zram(/.*)? u:object_r:zram_data_file:s0 + +### SYSTEM +/system/bin/inputmonitor u:object_r:inputmonitor_exec:s0 diff --git a/universal7885-common/sepolicy/private/inputmonitor.te b/universal7885-common/sepolicy/private/inputmonitor.te new file mode 100644 index 0000000..3b34d2c --- /dev/null +++ b/universal7885-common/sepolicy/private/inputmonitor.te @@ -0,0 +1,3 @@ +type inputmonitor, domain, coredomain; +type inputmonitor_exec, exec_type, file_type, system_file_type; +init_daemon_domain(inputmonitor)