diff options
| author | Ujwal P <ujwalp09@gmail.com> | 2018-12-12 21:27:30 +0000 |
|---|---|---|
| committer | Ujwal P <ujwalp09@gmail.com> | 2019-06-17 15:00:26 +0530 |
| commit | bebc0126713484da1c27f2eb33909279f2d13c62 (patch) | |
| tree | 034dbe11e2552966774429a84c2063a062c9baa4 | |
| parent | 4f2b8f3a8be27e95c2e31b515c112bd4f2a3701f (diff) | |
op3: AOSiP-ify
44 files changed, 102 insertions, 2176 deletions
diff --git a/AndroidProducts.mk b/AndroidProducts.mk index 4195adc1..93c2c5ec 100644 --- a/AndroidProducts.mk +++ b/AndroidProducts.mk @@ -14,4 +14,4 @@ # limitations under the License. PRODUCT_MAKEFILES := \ - $(LOCAL_DIR)/lineage_oneplus3.mk + $(LOCAL_DIR)/aosip.mk diff --git a/aosip.dependencies b/aosip.dependencies new file mode 100644 index 00000000..b8eb5808 --- /dev/null +++ b/aosip.dependencies @@ -0,0 +1,15 @@ +[ + { + "repository": "device_oppo_common", + "target_path": "device/oppo/common" + }, + { + "repository": "LineageOS/android_kernel_oneplus_msm8996", + "target_path": "kernel/oneplus/msm8996", + "branch": "lineage-16.0" + }, + { + "repository": "vendor_oneplus_oneplus3", + "target_path": "vendor/oneplus/oneplus3" + } +] diff --git a/lineage_oneplus3.mk b/aosip.mk index cca936de..18f70f50 100644 --- a/lineage_oneplus3.mk +++ b/aosip.mk @@ -20,13 +20,10 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk) # Inherit from oneplus3 device $(call inherit-product, device/oneplus/oneplus3/device.mk) -# Inherit some common Lineage stuff. -$(call inherit-product, vendor/lineage/config/common_full_phone.mk) +# Inherit some common AOSiP stuff. +$(call inherit-product, vendor/aosip/config/common_full_phone.mk) -# Vendor security patch level -VENDOR_SECURITY_PATCH := 2019-04-01 - -PRODUCT_NAME := lineage_oneplus3 +PRODUCT_NAME := aosip_oneplus3 PRODUCT_DEVICE := oneplus3 PRODUCT_MANUFACTURER := OnePlus PRODUCT_BRAND := OnePlus diff --git a/configs/manifest.xml b/configs/manifest.xml index 39574790..5191343c 100644 --- a/configs/manifest.xml +++ b/configs/manifest.xml @@ -766,27 +766,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. </interface> </hal> <hal format="hidl"> - <name>vendor.lineage.livedisplay</name> - <transport>hwbinder</transport> - <version>2.0</version> - <interface> - <name>IAdaptiveBacklight</name> - <instance>default</instance> - </interface> - <interface> - <name>IDisplayModes</name> - <instance>default</instance> - </interface> - <interface> - <name>IPictureAdjustment</name> - <instance>default</instance> - </interface> - <interface> - <name>ISunlightEnhancement</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> <name>vendor.lineage.power</name> <transport>hwbinder</transport> <version>1.0</version> @@ -795,26 +774,4 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <instance>default</instance> </interface> </hal> - <hal format="hidl"> - <name>vendor.lineage.touch</name> - <transport>hwbinder</transport> - <version>1.0</version> - <interface> - <name>IKeyDisabler</name> - <instance>default</instance> - </interface> - <interface> - <name>ITouchscreenGesture</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>vendor.lineage.trust</name> - <transport>hwbinder</transport> - <version>1.0</version> - <interface> - <name>IUsbRestrict</name> - <instance>default</instance> - </interface> - </hal> </manifest> @@ -29,7 +29,7 @@ $(call inherit-product, vendor/oneplus/oneplus3/oneplus3-vendor.mk) # Overlays DEVICE_PACKAGE_OVERLAYS += \ $(LOCAL_PATH)/overlay \ - $(LOCAL_PATH)/overlay-lineage + $(LOCAL_PATH)/overlay-aosip # Permissions PRODUCT_COPY_FILES += \ @@ -314,12 +314,7 @@ PRODUCT_PACKAGES += \ # Lineage hardware PRODUCT_PACKAGES += \ - vendor.lineage.touch@1.0-service.oneplus3 \ - vendor.lineage.trust@1.0-service - -# LiveDisplay -PRODUCT_PACKAGES += \ - vendor.lineage.livedisplay@2.0-service.oneplus3 + libjni_livedisplay # Media PRODUCT_COPY_FILES += \ diff --git a/doze/AndroidManifest.xml b/doze/AndroidManifest.xml index 80f16a47..c478917e 100644 --- a/doze/AndroidManifest.xml +++ b/doze/AndroidManifest.xml @@ -49,10 +49,6 @@ android:name=".DozeSettingsActivity" android:label="@string/ambient_display_title" android:theme="@style/Theme.Main"> - <intent-filter> - <action android:name="org.lineageos.settings.device.DOZE_SETTINGS" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> </activity> </application> diff --git a/keylayout/synaptics.kl b/keylayout/synaptics.kl index eda30b97..215a7e4e 100644 --- a/keylayout/synaptics.kl +++ b/keylayout/synaptics.kl @@ -25,6 +25,6 @@ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -key 580 APP_SWITCH VIRTUAL -key 158 BACK VIRTUAL +key 580 BACK VIRTUAL +key 158 APP_SWTICH VIRTUAL key 143 WAKEUP diff --git a/lineage.dependencies b/lineage.dependencies deleted file mode 100644 index 810a9dc7..00000000 --- a/lineage.dependencies +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "repository": "android_device_oppo_common", - "target_path": "device/oppo/common" - }, - { - "repository": "android_kernel_oneplus_msm8996", - "target_path": "kernel/oneplus/msm8996" - } -] diff --git a/lineagehw/.clang-format b/lineagehw/.clang-format deleted file mode 100644 index 9b3f9d99..00000000 --- a/lineagehw/.clang-format +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (C) 2017 The Android Open Source Project -# -# 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. -# - -BasedOnStyle: Google -CommentPragmas: NOLINT:.* -DerivePointerAlignment: false -AllowShortFunctionsOnASingleLine: Inline -ColumnLimit: 100 -TabWidth: 4 -UseTab: Never -IndentWidth: 4 diff --git a/lineagehw/livedisplay/AdaptiveBacklight.cpp b/lineagehw/livedisplay/AdaptiveBacklight.cpp deleted file mode 100644 index feef3b8e..00000000 --- a/lineagehw/livedisplay/AdaptiveBacklight.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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 <android-base/properties.h> - -#include "AdaptiveBacklight.h" -#include "Utils.h" - -namespace { -constexpr size_t kDppsBufSize = 64; -constexpr char kFossOn[] = "foss:on"; -constexpr char kFossOff[] = "foss:off"; -constexpr char kFossProperty[] = "ro.vendor.display.foss"; -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::base::GetBoolProperty; - -bool AdaptiveBacklight::isSupported() { - return GetBoolProperty(kFossProperty, false); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. -Return<bool> AdaptiveBacklight::isEnabled() { - return mEnabled; -} - -Return<bool> AdaptiveBacklight::setEnabled(bool enabled) { - if (mEnabled == enabled) { - return true; - } - - char buf[kDppsBufSize]; - sprintf(buf, "%s", enabled ? kFossOn : kFossOff); - if (Utils::sendDPPSCommand(buf, kDppsBufSize) == 0) { - if (strncmp(buf, "Success", 7) == 0) { - mEnabled = enabled; - return true; - } - } - - return false; -} - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/livedisplay/AdaptiveBacklight.h b/lineagehw/livedisplay/AdaptiveBacklight.h deleted file mode 100644 index c7ea0f32..00000000 --- a/lineagehw/livedisplay/AdaptiveBacklight.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H - -#include <vendor/lineage/livedisplay/2.0/IAdaptiveBacklight.h> - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::hardware::Return; - -class AdaptiveBacklight : public IAdaptiveBacklight { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. - Return<bool> isEnabled() override; - Return<bool> setEnabled(bool enabled) override; - - private: - bool mEnabled = false; -}; - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H diff --git a/lineagehw/livedisplay/Android.bp b/lineagehw/livedisplay/Android.bp deleted file mode 100644 index dfe9b9c4..00000000 --- a/lineagehw/livedisplay/Android.bp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2019 The LineageOS Project -// -// 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. - -cc_defaults { - name: "livedisplay_oneplus3_defaults", - defaults: ["hidl_defaults"], - relative_install_path: "hw", - srcs: [ - "AdaptiveBacklight.cpp", - "DisplayModes.cpp", - "PictureAdjustment.cpp", - "SDMController.cpp", - "SunlightEnhancement.cpp", - "Utils.cpp", - "service.cpp", - ], - shared_libs: [ - "libbase", - "libbinder", - "libcutils", - "libdl", - "libhidlbase", - "libhidltransport", - "libutils", - "vendor.lineage.livedisplay@2.0", - ], -} - -cc_binary { - name: "vendor.lineage.livedisplay@2.0-service.oneplus3", - init_rc: ["vendor.lineage.livedisplay@2.0-service.oneplus3.rc"], - defaults: ["livedisplay_oneplus3_defaults"], - vendor: true, -} diff --git a/lineagehw/livedisplay/DisplayModes.cpp b/lineagehw/livedisplay/DisplayModes.cpp deleted file mode 100644 index febf18f9..00000000 --- a/lineagehw/livedisplay/DisplayModes.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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 <unordered_map> - -#include <android-base/file.h> - -#include "DisplayModes.h" -#include "PictureAdjustment.h" -#include "Utils.h" - -namespace { -struct sdm_disp_mode { - int32_t id; - int32_t type; - int32_t len; - char* name; - sdm_disp_mode() : id(-1), type(0), len(128) { name = new char[128]; } - ~sdm_disp_mode() { delete[] name; } -}; - -const std::string kSysfsModeBasePath = "/sys/class/graphics/fb0/"; -const std::unordered_map<int32_t, std::string> kSysfsModeMap = { - {601, "srgb"}, - {602, "dci_p3"}, -}; - -inline bool isSysfsMode(int32_t modeId) { - return modeId > 600; -} -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::base::WriteStringToFile; - -DisplayModes::DisplayModes(std::shared_ptr<SDMController> controller, uint64_t cookie) - : mController(std::move(controller)), mCookie(cookie) { - if (!isSupported() || !saveInitialDisplayMode()) { - return; - } - - mActiveModeId = getDefaultDisplayModeId(); - if (isSysfsMode(mActiveModeId)) { - setModeState(mActiveModeId, true); - } -} - -bool DisplayModes::isSupported() { - int32_t count = 0; - uint32_t flags = 0; - static int supported = -1; - - if (supported >= 0) { - goto out; - } - - if (!Utils::checkFeatureVersion(mController, mCookie, FEATURE_VER_SW_SAVEMODES_API)) { - supported = 0; - goto out; - } - - if (mController->get_num_display_modes(mCookie, 0, 0, &count, &flags) != 0) { - supported = 0; - goto out; - } - - supported = (count > 0); -out: - return supported; -} - -std::vector<DisplayMode> DisplayModes::getDisplayModesInternal() { - std::vector<DisplayMode> modes = getDisplayModesQDCM(); - std::vector<DisplayMode> sysfsModes = getDisplayModesSysfs(); - - modes.insert(modes.end(), sysfsModes.begin(), sysfsModes.end()); - - return modes; -} - -std::vector<DisplayMode> DisplayModes::getDisplayModesQDCM() { - std::vector<DisplayMode> modes; - int32_t count = 0; - uint32_t flags = 0; - - if (mController->get_num_display_modes(mCookie, 0, 0, &count, &flags) != 0 || count == 0) { - return modes; - } - - sdm_disp_mode tmp[count]; - - if (mController->get_display_modes(mCookie, 0, 0, tmp, count, &flags) == 0) { - for (int i = 0; i < count; i++) { - modes.push_back({tmp[i].id, std::string(tmp[i].name)}); - } - } - - return modes; -} - -std::vector<DisplayMode> DisplayModes::getDisplayModesSysfs() { - std::vector<DisplayMode> modes; - - for (const auto& entry : kSysfsModeMap) { - if (!access((kSysfsModeBasePath + entry.second).c_str(), F_OK)) { - modes.push_back({entry.first, entry.second}); - } - } - - return modes; -} - -DisplayMode DisplayModes::getDisplayModeById(int32_t id) { - if (id >= 0) { - std::vector<DisplayMode> modes = getDisplayModesInternal(); - - for (const DisplayMode& mode : modes) { - if (mode.id == id) { - return mode; - } - } - } - - return DisplayMode{-1, ""}; -} - -DisplayMode DisplayModes::getCurrentDisplayModeInternal() { - return getDisplayModeById(getCurrentDisplayModeId()); -} - -int32_t DisplayModes::getCurrentDisplayModeId() { - return mActiveModeId; -} - -DisplayMode DisplayModes::getDefaultDisplayModeInternal() { - return getDisplayModeById(getDefaultDisplayModeId()); -} - -int32_t DisplayModes::getDefaultDisplayModeId() { - int32_t id = Utils::readLocalModeId(); - return (id >= 0 ? id : getDefaultDisplayModeIdQDCM()); -} - -int32_t DisplayModes::getDefaultDisplayModeIdQDCM() { - int32_t id = 0; - uint32_t flags = 0; - - if (mController->get_default_display_mode(mCookie, 0, &id, &flags) != 0) { - id = -1; - } - - return id; -} - -bool DisplayModes::setModeState(int32_t modeId, bool on) { - // To set sysfs mode state, just write to the node - if (isSysfsMode(modeId)) { - const auto mode = kSysfsModeMap.find(modeId); - if (mode == kSysfsModeMap.end()) { - return false; - } - return WriteStringToFile(on ? "1" : "0", kSysfsModeBasePath + mode->second); - } - - int32_t id; - if (on) { - // To turn on QDCM mode, just enable it - id = modeId; - } else { - // To turn off QDCM mode, turn on the initial QDCM mode instead - id = Utils::readInitialModeId(); - if (id < 0) { - return false; - } - if (id == modeId) { - // Can't turn off the initial mode - return true; - } - } - return mController->set_active_display_mode(mCookie, 0, id, 0) == 0; -} - -bool DisplayModes::saveInitialDisplayMode() { - int32_t id = Utils::readInitialModeId(); - if (id < 0) { - return Utils::writeInitialModeId(std::max(0, getDefaultDisplayModeIdQDCM())); - } - return true; -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow. -Return<void> DisplayModes::getDisplayModes(getDisplayModes_cb _hidl_cb) { - _hidl_cb(getDisplayModesInternal()); - return Void(); -} - -Return<void> DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb _hidl_cb) { - _hidl_cb(getCurrentDisplayModeInternal()); - return Void(); -} - -Return<void> DisplayModes::getDefaultDisplayMode(getDefaultDisplayMode_cb _hidl_cb) { - _hidl_cb(getDefaultDisplayModeInternal()); - return Void(); -} - -Return<bool> DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) { - int32_t curModeId = getCurrentDisplayModeId(); - - if (curModeId >= 0 && curModeId == modeID) { - return true; - } - - DisplayMode mode = getDisplayModeById(modeID); - if (mode.id < 0) { - return false; - } - - /** - * Sysfs mode is active or switching to sysfs mode, - * turn off the active mode before switching. - */ - if (isSysfsMode(curModeId) || isSysfsMode(modeID)) { - if (!setModeState(curModeId, false)) { - return false; - } - } - - if (!setModeState(modeID, true)) { - return false; - } - - mActiveModeId = modeID; - - if (makeDefault) { - if (!Utils::writeLocalModeId(modeID)) { - return false; - } - - if (isSysfsMode(modeID)) { - modeID = Utils::readInitialModeId(); - if (modeID < 0) { - return false; - } - } - if (mController->set_default_display_mode(mCookie, 0, modeID, 0) != 0) { - return false; - } - } - - PictureAdjustment::updateDefaultPictureAdjustment(); - - return true; -} - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/livedisplay/DisplayModes.h b/lineagehw/livedisplay/DisplayModes.h deleted file mode 100644 index 6c3299b4..00000000 --- a/lineagehw/livedisplay/DisplayModes.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H - -#include <vendor/lineage/livedisplay/2.0/IDisplayModes.h> - -#include "SDMController.h" - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::hardware::Return; -using ::android::hardware::Void; - -class DisplayModes : public IDisplayModes { - public: - DisplayModes(std::shared_ptr<SDMController> controller, uint64_t cookie); - - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow. - Return<void> getDisplayModes(getDisplayModes_cb _hidl_cb) override; - Return<void> getCurrentDisplayMode(getCurrentDisplayMode_cb _hidl_cb) override; - Return<void> getDefaultDisplayMode(getDefaultDisplayMode_cb _hidl_cb) override; - Return<bool> setDisplayMode(int32_t modeID, bool makeDefault) override; - - private: - std::shared_ptr<SDMController> mController; - uint64_t mCookie; - int32_t mActiveModeId; - - std::vector<DisplayMode> getDisplayModesInternal(); - std::vector<DisplayMode> getDisplayModesQDCM(); - std::vector<DisplayMode> getDisplayModesSysfs(); - DisplayMode getDisplayModeById(int32_t id); - DisplayMode getCurrentDisplayModeInternal(); - int32_t getCurrentDisplayModeId(); - DisplayMode getDefaultDisplayModeInternal(); - int32_t getDefaultDisplayModeId(); - int32_t getDefaultDisplayModeIdQDCM(); - bool setModeState(int32_t modeId, bool on); - bool saveInitialDisplayMode(); -}; - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H diff --git a/lineagehw/livedisplay/PictureAdjustment.cpp b/lineagehw/livedisplay/PictureAdjustment.cpp deleted file mode 100644 index 8798b996..00000000 --- a/lineagehw/livedisplay/PictureAdjustment.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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 "PictureAdjustment.h" -#include "Utils.h" - -namespace { -struct hsic_data { - int32_t hue; - float saturation; - float intensity; - float contrast; - float saturationThreshold; -}; - -struct hsic_config { - uint32_t unused; - hsic_data data; -}; - -struct hsic_int_range { - int32_t max; - int32_t min; - uint32_t step; -}; - -struct hsic_float_range { - float max; - float min; - float step; -}; - -struct hsic_ranges { - uint32_t unused; - struct hsic_int_range hue; - struct hsic_float_range saturation; - struct hsic_float_range intensity; - struct hsic_float_range contrast; - struct hsic_float_range saturationThreshold; -}; -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::sp; - -static sp<PictureAdjustment> sInstance; - -PictureAdjustment::PictureAdjustment(std::shared_ptr<SDMController> controller, uint64_t cookie) - : mController(std::move(controller)), mCookie(cookie) { - sInstance = this; - memset(&mDefaultPictureAdjustment, 0, sizeof(HSIC)); -} - -bool PictureAdjustment::isSupported() { - hsic_ranges r; - static int supported = -1; - - if (supported >= 0) { - goto out; - } - - if (!Utils::checkFeatureVersion(mController, mCookie, FEATURE_VER_SW_PA_API)) { - supported = 0; - goto out; - } - - if (mController->get_global_pa_range(mCookie, 0, &r) != 0) { - supported = 0; - goto out; - } - - supported = r.hue.max != 0 && r.hue.min != 0 && r.saturation.max != 0.f && - r.saturation.min != 0.f && r.intensity.max != 0.f && r.intensity.min != 0.f && - r.contrast.max != 0.f && r.contrast.min != 0.f; -out: - return supported; -} - -HSIC PictureAdjustment::getPictureAdjustmentInternal() { - hsic_config config; - uint32_t enable = 0; - - if (mController->get_global_pa_config(mCookie, 0, &enable, &config) == 0) { - return HSIC{static_cast<float>(config.data.hue), config.data.saturation, - config.data.intensity, config.data.contrast, config.data.saturationThreshold}; - } - - return HSIC(); -} - -void PictureAdjustment::updateDefaultPictureAdjustment() { - if (sInstance != nullptr) { - sInstance->mDefaultPictureAdjustment = sInstance->getPictureAdjustmentInternal(); - } -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment follow. -Return<void> PictureAdjustment::getHueRange(getHueRange_cb _hidl_cb) { - FloatRange range; - hsic_ranges r; - - if (mController->get_global_pa_range(mCookie, 0, &r) == 0) { - range.max = r.hue.max; - range.min = r.hue.min; - range.step = r.hue.step; - } - - _hidl_cb(range); - return Void(); -} - -Return<void> PictureAdjustment::getSaturationRange(getSaturationRange_cb _hidl_cb) { - FloatRange range; - hsic_ranges r; - - if (mController->get_global_pa_range(mCookie, 0, &r) == 0) { - range.max = r.saturation.max; - range.min = r.saturation.min; - range.step = r.saturation.step; - } - - _hidl_cb(range); - return Void(); -} - -Return<void> PictureAdjustment::getIntensityRange(getIntensityRange_cb _hidl_cb) { - FloatRange range; - hsic_ranges r; - - if (mController->get_global_pa_range(mCookie, 0, &r) == 0) { - range.max = r.intensity.max; - range.min = r.intensity.min; - range.step = r.intensity.step; - } - - _hidl_cb(range); - return Void(); -} - -Return<void> PictureAdjustment::getContrastRange(getContrastRange_cb _hidl_cb) { - FloatRange range; - hsic_ranges r; - - if (mController->get_global_pa_range(mCookie, 0, &r) == 0) { - range.max = r.contrast.max; - range.min = r.contrast.min; - range.step = r.contrast.step; - } - - _hidl_cb(range); - return Void(); -} - -Return<void> PictureAdjustment::getSaturationThresholdRange( - getSaturationThresholdRange_cb _hidl_cb) { - FloatRange range; - hsic_ranges r; - - if (mController->get_global_pa_range(mCookie, 0, &r) == 0) { - range.max = r.saturationThreshold.max; - range.min = r.saturationThreshold.min; - range.step = r.saturationThreshold.step; - } - - _hidl_cb(range); - return Void(); -} - -Return<void> PictureAdjustment::getPictureAdjustment(getPictureAdjustment_cb _hidl_cb) { - _hidl_cb(getPictureAdjustmentInternal()); - return Void(); -} - -Return<void> PictureAdjustment::getDefaultPictureAdjustment( - getDefaultPictureAdjustment_cb _hidl_cb) { - _hidl_cb(mDefaultPictureAdjustment); - return Void(); -} - -Return<bool> PictureAdjustment::setPictureAdjustment( - const ::vendor::lineage::livedisplay::V2_0::HSIC& hsic) { - hsic_config config = {0, - {static_cast<int32_t>(hsic.hue), hsic.saturation, hsic.intensity, - hsic.contrast, hsic.saturationThreshold}}; - - return mController->set_global_pa_config(mCookie, 0, 1, &config) == 0; -} - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/livedisplay/PictureAdjustment.h b/lineagehw/livedisplay/PictureAdjustment.h deleted file mode 100644 index 3f029c25..00000000 --- a/lineagehw/livedisplay/PictureAdjustment.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_PICTUREADJUSTMENT_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_PICTUREADJUSTMENT_H - -#include <vendor/lineage/livedisplay/2.0/IPictureAdjustment.h> - -#include "SDMController.h" - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::hardware::Return; -using ::android::hardware::Void; - -class PictureAdjustment : public IPictureAdjustment { - public: - PictureAdjustment(std::shared_ptr<SDMController> controller, uint64_t cookie); - - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment follow. - Return<void> getHueRange(getHueRange_cb _hidl_cb) override; - Return<void> getSaturationRange(getSaturationRange_cb _hidl_cb) override; - Return<void> getIntensityRange(getIntensityRange_cb _hidl_cb) override; - Return<void> getContrastRange(getContrastRange_cb _hidl_cb) override; - Return<void> getSaturationThresholdRange(getSaturationThresholdRange_cb _hidl_cb) override; - Return<void> getPictureAdjustment(getPictureAdjustment_cb _hidl_cb) override; - Return<void> getDefaultPictureAdjustment(getDefaultPictureAdjustment_cb _hidl_cb) override; - Return<bool> setPictureAdjustment( - const ::vendor::lineage::livedisplay::V2_0::HSIC& hsic) override; - - static void updateDefaultPictureAdjustment(); - - private: - std::shared_ptr<SDMController> mController; - uint64_t mCookie; - HSIC mDefaultPictureAdjustment; - - HSIC getPictureAdjustmentInternal(); -}; - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_PICTUREADJUSTMENT_H diff --git a/lineagehw/livedisplay/SDMController.cpp b/lineagehw/livedisplay/SDMController.cpp deleted file mode 100644 index 049890a5..00000000 --- a/lineagehw/livedisplay/SDMController.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2018-2019 The LineageOS Project - * - * 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 <android-base/logging.h> -#include <dlfcn.h> - -#include "SDMController.h" - -#define LOAD_SDM_FUNCTION(name) \ - mFn_##name = loadFunction<disp_api_##name>(mHandle, "disp_api_" #name); - -#define CLOSE_SDM_FUNCTION(name) mFn_##name = nullptr; - -#define FOR_EACH_FUNCTION(MACRO) \ - MACRO(init) \ - MACRO(deinit) \ - MACRO(get_global_color_balance_range) \ - MACRO(set_global_color_balance) \ - MACRO(get_global_color_balance) \ - MACRO(get_num_display_modes) \ - MACRO(get_display_modes) \ - MACRO(get_active_display_mode) \ - MACRO(set_active_display_mode) \ - MACRO(set_default_display_mode) \ - MACRO(get_default_display_mode) \ - MACRO(get_global_pa_range) \ - MACRO(get_global_pa_config) \ - MACRO(set_global_pa_config) \ - MACRO(get_feature_version) - -#define CONTROLLER_CHECK(function, ...) \ - if (mFn_##function == nullptr) { \ - return -1; \ - } \ - int err = mFn_##function(__VA_ARGS__); \ - if (err != 0) { \ - return err; \ - } \ - return 0; - -namespace { -#ifdef LIVES_IN_SYSTEM -constexpr char kFilename[] = "libsdm-disp-apis.so"; -#else -constexpr char kFilename[] = "libsdm-disp-vndapis.so"; -#endif - -template <typename Function> -Function loadFunction(std::shared_ptr<void> handle, const char* name) { - void* fn = dlsym(handle.get(), name); - if (fn == nullptr) { - LOG(ERROR) << "loadFunction -- failed to load function " << name; - } - return reinterpret_cast<Function>(fn); -} -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -SDMController::SDMController() { - std::shared_ptr<void> handle(dlopen(kFilename, RTLD_NOW), [this](void* p) { - FOR_EACH_FUNCTION(CLOSE_SDM_FUNCTION) - if (p != nullptr) { - int err = dlclose(p); - p = nullptr; - if (err != 0) { - LOG(ERROR) << "DLCLOSE failed for " << kFilename; - } - } - }); - if (handle == nullptr) { - LOG(ERROR) << "DLOPEN failed for " << kFilename << " (" << dlerror() << ")"; - return; - } - mHandle = handle; - - FOR_EACH_FUNCTION(LOAD_SDM_FUNCTION) -} - -int32_t SDMController::init(uint64_t* hctx, uint32_t flags) { - CONTROLLER_CHECK(init, hctx, flags); -} - -int32_t SDMController::deinit(uint64_t hctx, uint32_t flags) { - CONTROLLER_CHECK(deinit, hctx, flags); -} - -int32_t SDMController::get_global_color_balance_range(uint64_t hctx, uint32_t disp_id, - void* range) { - CONTROLLER_CHECK(get_global_color_balance_range, hctx, disp_id, range); -} - -int32_t SDMController::set_global_color_balance(uint64_t hctx, uint32_t disp_id, int32_t warmness, - uint32_t flags) { - CONTROLLER_CHECK(set_global_color_balance, hctx, disp_id, warmness, flags); -} - -int32_t SDMController::get_global_color_balance(uint64_t hctx, uint32_t disp_id, int32_t* warmness, - uint32_t* flags) { - CONTROLLER_CHECK(get_global_color_balance, hctx, disp_id, warmness, flags); -} - -int32_t SDMController::get_num_display_modes(uint64_t hctx, uint32_t disp_id, uint32_t mode_type, - int32_t* mode_cnt, uint32_t* flags) { - CONTROLLER_CHECK(get_num_display_modes, hctx, disp_id, mode_type, mode_cnt, flags); -} - -int32_t SDMController::get_display_modes(uint64_t hctx, uint32_t disp_id, uint32_t mode_type, - void* modes, int32_t mode_cnt, uint32_t* flags) { - CONTROLLER_CHECK(get_display_modes, hctx, disp_id, mode_type, modes, mode_cnt, flags); -} - -int32_t SDMController::get_active_display_mode(uint64_t hctx, uint32_t disp_id, int32_t* mode_id, - uint32_t* mask, uint32_t* flags) { - CONTROLLER_CHECK(get_active_display_mode, hctx, disp_id, mode_id, mask, flags); -} - -int32_t SDMController::set_active_display_mode(uint64_t hctx, uint32_t disp_id, int32_t mode_id, - uint32_t flags) { - CONTROLLER_CHECK(set_active_display_mode, hctx, disp_id, mode_id, flags); -} - -int32_t SDMController::set_default_display_mode(uint64_t hctx, uint32_t disp_id, int32_t mode_id, - uint32_t flags) { - CONTROLLER_CHECK(set_default_display_mode, hctx, disp_id, mode_id, flags); -} - -int32_t SDMController::get_default_display_mode(uint64_t hctx, uint32_t disp_id, int32_t* mode_id, - uint32_t* flags) { - CONTROLLER_CHECK(get_default_display_mode, hctx, disp_id, mode_id, flags); -} - -int32_t SDMController::get_global_pa_range(uint64_t hctx, uint32_t disp_id, void* range) { - CONTROLLER_CHECK(get_global_pa_range, hctx, disp_id, range); -} - -int32_t SDMController::get_global_pa_config(uint64_t hctx, uint32_t disp_id, uint32_t* enable, - void* cfg) { - CONTROLLER_CHECK(get_global_pa_config, hctx, disp_id, enable, cfg); -} - -int32_t SDMController::set_global_pa_config(uint64_t hctx, uint32_t disp_id, uint32_t enable, - void* cfg) { - CONTROLLER_CHECK(set_global_pa_config, hctx, disp_id, enable, cfg); -} - -int32_t SDMController::get_feature_version(uint64_t hctx, uint32_t feature_id, void* ver, - uint32_t* flags) { - CONTROLLER_CHECK(get_feature_version, hctx, feature_id, ver, flags); -} - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/livedisplay/SDMController.h b/lineagehw/livedisplay/SDMController.h deleted file mode 100644 index b0a1e3dc..00000000 --- a/lineagehw/livedisplay/SDMController.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2018-2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDMCONTROLLER_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDMCONTROLLER_H - -#include <memory> - -#include <stdint.h> - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -class SDMController { - public: - SDMController(); - - int32_t init(uint64_t* hctx, uint32_t flags); - int32_t deinit(uint64_t hctx, uint32_t flags); - int32_t get_global_color_balance_range(uint64_t hctx, uint32_t disp_id, void* range); - int32_t set_global_color_balance(uint64_t hctx, uint32_t disp_id, int32_t warmness, - uint32_t flags); - int32_t get_global_color_balance(uint64_t hctx, uint32_t disp_id, int32_t* warmness, - uint32_t* flags); - int32_t get_num_display_modes(uint64_t hctx, uint32_t disp_id, uint32_t mode_type, - int32_t* mode_cnt, uint32_t* flags); - int32_t get_display_modes(uint64_t hctx, uint32_t disp_id, uint32_t mode_type, void* modes, - int32_t mode_cnt, uint32_t* flags); - int32_t get_active_display_mode(uint64_t hctx, uint32_t disp_id, int32_t* mode_id, - uint32_t* mask, uint32_t* flags); - int32_t set_active_display_mode(uint64_t hctx, uint32_t disp_id, int32_t mode_id, - uint32_t flags); - int32_t set_default_display_mode(uint64_t hctx, uint32_t disp_id, int32_t mode_id, - uint32_t flags); - int32_t get_default_display_mode(uint64_t hctx, uint32_t disp_id, int32_t* mode_id, - uint32_t* flags); - int32_t get_global_pa_range(uint64_t hctx, uint32_t disp_id, void* range); - int32_t get_global_pa_config(uint64_t hctx, uint32_t disp_id, uint32_t* enable, void* cfg); - int32_t set_global_pa_config(uint64_t hctx, uint32_t disp_id, uint32_t enable, void* cfg); - int32_t get_feature_version(uint64_t hctx, uint32_t feature_id, void* ver, uint32_t* flags); - - private: - typedef int32_t (*disp_api_init)(uint64_t*, uint32_t); - typedef int32_t (*disp_api_deinit)(uint64_t, uint32_t); - typedef int32_t (*disp_api_get_global_color_balance_range)(uint64_t, uint32_t, void*); - typedef int32_t (*disp_api_set_global_color_balance)(uint64_t, uint32_t, int32_t, uint32_t); - typedef int32_t (*disp_api_get_global_color_balance)(uint64_t, uint32_t, int32_t*, uint32_t*); - typedef int32_t (*disp_api_get_num_display_modes)(uint64_t, uint32_t, int32_t, int32_t*, - uint32_t*); - typedef int32_t (*disp_api_get_display_modes)(uint64_t, uint32_t, int32_t, void*, int32_t, - uint32_t*); - typedef int32_t (*disp_api_get_active_display_mode)(uint64_t, uint32_t, int32_t*, uint32_t*, - uint32_t*); - typedef int32_t (*disp_api_set_active_display_mode)(uint64_t, uint32_t, int32_t, uint32_t); - typedef int32_t (*disp_api_set_default_display_mode)(uint64_t, uint32_t, int32_t, uint32_t); - typedef int32_t (*disp_api_get_default_display_mode)(uint64_t, uint32_t, int32_t*, uint32_t*); - typedef int32_t (*disp_api_get_global_pa_range)(uint64_t, uint32_t, void*); - typedef int32_t (*disp_api_get_global_pa_config)(uint64_t, uint32_t, uint32_t*, void*); - typedef int32_t (*disp_api_set_global_pa_config)(uint64_t, uint32_t, uint32_t, void*); - typedef int32_t (*disp_api_get_feature_version)(uint64_t, uint32_t, void*, uint32_t*); - - std::shared_ptr<void> mHandle; - disp_api_init mFn_init; - disp_api_deinit mFn_deinit; - disp_api_get_global_color_balance_range mFn_get_global_color_balance_range; - disp_api_set_global_color_balance mFn_set_global_color_balance; - disp_api_get_global_color_balance mFn_get_global_color_balance; - disp_api_get_num_display_modes mFn_get_num_display_modes; - disp_api_get_display_modes mFn_get_display_modes; - disp_api_get_active_display_mode mFn_get_active_display_mode; - disp_api_set_active_display_mode mFn_set_active_display_mode; - disp_api_set_default_display_mode mFn_set_default_display_mode; - disp_api_get_default_display_mode mFn_get_default_display_mode; - disp_api_get_global_pa_range mFn_get_global_pa_range; - disp_api_get_global_pa_config mFn_get_global_pa_config; - disp_api_set_global_pa_config mFn_set_global_pa_config; - disp_api_get_feature_version mFn_get_feature_version; -}; - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDMCONTROLLER_H diff --git a/lineagehw/livedisplay/SunlightEnhancement.cpp b/lineagehw/livedisplay/SunlightEnhancement.cpp deleted file mode 100644 index e972f9f5..00000000 --- a/lineagehw/livedisplay/SunlightEnhancement.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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 <android-base/file.h> -#include <android-base/strings.h> - -#include "SunlightEnhancement.h" - -using android::base::ReadFileToString; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sysfs { - -constexpr char kFileHBM[] = "/sys/class/graphics/fb0/hbm"; - -bool SunlightEnhancement::isSupported() { - return !access(kFileHBM, F_OK); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. -Return<bool> SunlightEnhancement::isEnabled() { - std::string tmp; - int32_t contents = 0; - - if (ReadFileToString(kFileHBM, &tmp)) { - contents = std::stoi(Trim(tmp)); - } - - return contents > 0; -} - -Return<bool> SunlightEnhancement::setEnabled(bool enabled) { - return WriteStringToFile(enabled ? "1" : "0", kFileHBM, true); -} - -} // namespace sysfs -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/livedisplay/SunlightEnhancement.h b/lineagehw/livedisplay/SunlightEnhancement.h deleted file mode 100644 index f4af1fe0..00000000 --- a/lineagehw/livedisplay/SunlightEnhancement.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H - -#include <vendor/lineage/livedisplay/2.0/ISunlightEnhancement.h> - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sysfs { - -using ::android::hardware::Return; -using ::android::hardware::Void; - -class SunlightEnhancement : public ISunlightEnhancement { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. - Return<bool> isEnabled() override; - Return<bool> setEnabled(bool enabled) override; -}; - -} // namespace sysfs -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H diff --git a/lineagehw/livedisplay/Types.h b/lineagehw/livedisplay/Types.h deleted file mode 100644 index f1619d02..00000000 --- a/lineagehw/livedisplay/Types.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDM_TYPES_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDM_TYPES_H - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -enum feature_ver_sw { - FEATURE_VER_SW_API, - FEATURE_VER_SW_PA_API, - FEATURE_VER_SW_MEMCOLOR_API, - FEATURE_VER_SW_COLORBAL_API, - FEATURE_VER_SW_SAVEMODES_API, - FEATURE_VER_SW_ADAPT_BACKLIGHT_API, - FEATURE_VER_SW_SVI_API, - FEATURE_VER_SW_DISP_INFO_API -}; - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDM_TYPES_H diff --git a/lineagehw/livedisplay/Utils.cpp b/lineagehw/livedisplay/Utils.cpp deleted file mode 100644 index d4a1709d..00000000 --- a/lineagehw/livedisplay/Utils.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * 2017-2019 The LineageOS Project - * - * 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 <poll.h> -#include <unistd.h> - -#include <android-base/file.h> -#include <android-base/strings.h> -#include <cutils/sockets.h> - -#include "Utils.h" - -namespace { -struct sdm_feature_version { - uint8_t x, y; - uint16_t z; -}; - -const std::string kLocalStoragePath = "/data/vendor/display/"; -const std::string kLocalModeId = "livedisplay_mode"; -const std::string kLocalInitialModeId = "livedisplay_initial_mode"; - -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -using ::android::base::ReadFileToString; -using ::android::base::Trim; -using ::android::base::WriteStringToFile; - -int32_t Utils::readLocalModeId() { - std::string buf; - if (ReadFileToString(kLocalStoragePath + kLocalModeId, &buf)) { - return std::stoi(Trim(buf)); - } - return -1; -} - -bool Utils::writeLocalModeId(int32_t id) { - return WriteStringToFile(std::to_string(id), kLocalStoragePath + kLocalModeId); -} - -int32_t Utils::readInitialModeId() { - std::string buf; - if (ReadFileToString(kLocalStoragePath + kLocalInitialModeId, &buf)) { - return std::stoi(Trim(buf)); - } - return -1; -} - -bool Utils::writeInitialModeId(int32_t id) { - return WriteStringToFile(std::to_string(id), kLocalStoragePath + kLocalInitialModeId); -} - -int Utils::sendDPPSCommand(char* buf, size_t len) { - int rc = 0; - int sock = socket_local_client("pps", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); - if (sock < 0) { - return sock; - } - - if (write(sock, buf, strlen(buf) + 1) > 0) { - memset(buf, 0, len); - ssize_t ret; - while ((ret = read(sock, buf, len)) > 0) { - if ((size_t)ret == len) { - break; - } - len -= ret; - buf += ret; - - struct pollfd p = {.fd = sock, .events = POLLIN, .revents = 0}; - - ret = poll(&p, 1, 20); - if ((ret <= 0) || !(p.revents & POLLIN)) { - break; - } - } - } else { - rc = -EIO; - } - - close(sock); - return rc; -} - -bool Utils::checkFeatureVersion(const std::shared_ptr<SDMController>& controller, uint64_t cookie, - feature_ver_sw feature) { - sdm_feature_version version; - uint32_t flags = 0; - - if (controller->get_feature_version(cookie, feature, &version, &flags) != 0) { - return false; - } - - if (version.x <= 0 && version.y <= 0 && version.z <= 0) { - return false; - } - - return true; -} - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/livedisplay/Utils.h b/lineagehw/livedisplay/Utils.h deleted file mode 100644 index 795f44b3..00000000 --- a/lineagehw/livedisplay/Utils.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * 2017-2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDM_UTILS_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDM_UTILS_H - -#include "SDMController.h" -#include "Types.h" - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace sdm { - -class Utils { - public: - static int32_t readLocalModeId(); - static bool writeLocalModeId(int32_t id); - static int32_t readInitialModeId(); - static bool writeInitialModeId(int32_t id); - static int sendDPPSCommand(char* buf, size_t len); - static bool checkFeatureVersion(const std::shared_ptr<SDMController>& controller, - uint64_t cookie, feature_ver_sw feature); -}; - -} // namespace sdm -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SDM_UTILS_H diff --git a/lineagehw/livedisplay/service.cpp b/lineagehw/livedisplay/service.cpp deleted file mode 100644 index 18a633fd..00000000 --- a/lineagehw/livedisplay/service.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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 <dlfcn.h> - -#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.oneplus3" - -#include <android-base/logging.h> -#include <binder/ProcessState.h> -#include <hidl/HidlTransportSupport.h> - -#include "AdaptiveBacklight.h" -#include "DisplayModes.h" -#include "PictureAdjustment.h" -#include "SDMController.h" -#include "SunlightEnhancement.h" - -using android::OK; -using android::sp; -using android::status_t; -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; - -using ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight; -using ::vendor::lineage::livedisplay::V2_0::IDisplayModes; -using ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment; -using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement; -using ::vendor::lineage::livedisplay::V2_0::sdm::AdaptiveBacklight; -using ::vendor::lineage::livedisplay::V2_0::sdm::DisplayModes; -using ::vendor::lineage::livedisplay::V2_0::sdm::PictureAdjustment; -using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController; -using ::vendor::lineage::livedisplay::V2_0::sysfs::SunlightEnhancement; - -int main() { - // Vendor backend - std::shared_ptr<SDMController> controller; - uint64_t cookie = 0; - - // HIDL frontend - sp<AdaptiveBacklight> ab; - sp<DisplayModes> dm; - sp<PictureAdjustment> pa; - sp<SunlightEnhancement> se; - - status_t status = OK; - - android::ProcessState::initWithDriver("/dev/vndbinder"); - - LOG(INFO) << "LiveDisplay HAL service is starting."; - - controller = std::make_shared<SDMController>(); - if (controller == nullptr) { - LOG(ERROR) << "Failed to create SDMController"; - goto shutdown; - } - - status = controller->init(&cookie, 0); - if (status != OK) { - LOG(ERROR) << "Failed to initialize SDMController"; - goto shutdown; - } - - ab = new AdaptiveBacklight(); - if (ab == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, exiting."; - goto shutdown; - } - - dm = new DisplayModes(controller, cookie); - if (dm == nullptr) { - LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting."; - goto shutdown; - } - - pa = new PictureAdjustment(controller, cookie); - if (pa == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL PictureAdjustment Iface, exiting."; - goto shutdown; - } - - se = new SunlightEnhancement(); - if (se == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, exiting."; - goto shutdown; - } - - if (!dm->isSupported() && !pa->isSupported()) { - // Backend isn't ready yet, so restart and try again - goto shutdown; - } - - configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (ab->isSupported()) { - status = ab->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface (" - << status << ")"; - goto shutdown; - } - } - - if (dm->isSupported()) { - status = dm->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface (" - << status << ")"; - goto shutdown; - } - } - - if (pa->isSupported()) { - status = pa->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface (" - << status << ")"; - goto shutdown; - } - } - - if (se->isSupported()) { - status = se->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface" - << " (" << status << ")"; - goto shutdown; - } - } - - LOG(INFO) << "LiveDisplay HAL service is ready."; - joinRpcThreadpool(); - // Should not pass this line - -shutdown: - // Cleanup what we started - controller->deinit(cookie, 0); - - // In normal operation, we don't expect the thread pool to shutdown - LOG(ERROR) << "LiveDisplay HAL service is shutting down."; - return 1; -} diff --git a/lineagehw/livedisplay/vendor.lineage.livedisplay@2.0-service.oneplus3.rc b/lineagehw/livedisplay/vendor.lineage.livedisplay@2.0-service.oneplus3.rc deleted file mode 100644 index 89f00d24..00000000 --- a/lineagehw/livedisplay/vendor.lineage.livedisplay@2.0-service.oneplus3.rc +++ /dev/null @@ -1,10 +0,0 @@ -on boot - chown system system /sys/class/graphics/fb0/srgb - chmod 0660 /sys/class/graphics/fb0/srgb - chown system system /sys/class/graphics/fb0/dci_p3 - chmod 0660 /sys/class/graphics/fb0/dci_p3 - -service vendor.livedisplay-oneplus3-hal-2-0 /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.oneplus3 - class late_start - user system - group system diff --git a/lineagehw/touch/Android.bp b/lineagehw/touch/Android.bp deleted file mode 100644 index 1e4bd6dd..00000000 --- a/lineagehw/touch/Android.bp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (C) 2019 The LineageOS Project -// -// 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. - -cc_binary { - name: "vendor.lineage.touch@1.0-service.oneplus3", - init_rc: ["vendor.lineage.touch@1.0-service.oneplus3.rc"], - defaults: ["hidl_defaults"], - relative_install_path: "hw", - vendor: true, - srcs: [ - "KeyDisabler.cpp", - "TouchscreenGesture.cpp", - "service.cpp", - ], - shared_libs: [ - "libbase", - "libhidlbase", - "libhidltransport", - "libutils", - "vendor.lineage.touch@1.0", - ], -} diff --git a/lineagehw/touch/KeyDisabler.cpp b/lineagehw/touch/KeyDisabler.cpp deleted file mode 100644 index cf1c2986..00000000 --- a/lineagehw/touch/KeyDisabler.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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 <android-base/file.h> -#include <android-base/logging.h> -#include <android-base/strings.h> - -#include "KeyDisabler.h" - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace implementation { - -constexpr const char kControlPath[] = "/proc/s1302/virtual_key"; - -KeyDisabler::KeyDisabler() { - mHasKeyDisabler = !access(kControlPath, F_OK); -} - -// Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. -Return<bool> KeyDisabler::isEnabled() { - std::string buf; - - if (!mHasKeyDisabler) return false; - - if (!android::base::ReadFileToString(kControlPath, &buf)) { - LOG(ERROR) << "Failed to read " << kControlPath; - return false; - } - - return std::stoi(android::base::Trim(buf)) == 1; -} - -Return<bool> KeyDisabler::setEnabled(bool enabled) { - if (!mHasKeyDisabler) return false; - - if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kControlPath)) { - LOG(ERROR) << "Failed to write " << kControlPath; - return false; - } - - return true; -} - -} // namespace implementation -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/touch/KeyDisabler.h b/lineagehw/touch/KeyDisabler.h deleted file mode 100644 index 2e00e91c..00000000 --- a/lineagehw/touch/KeyDisabler.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H -#define VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H - -#include <vendor/lineage/touch/1.0/IKeyDisabler.h> - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::Return; - -class KeyDisabler : public IKeyDisabler { - public: - KeyDisabler(); - // Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. - Return<bool> isEnabled() override; - Return<bool> setEnabled(bool enabled) override; - - private: - bool mHasKeyDisabler; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H diff --git a/lineagehw/touch/TouchscreenGesture.cpp b/lineagehw/touch/TouchscreenGesture.cpp deleted file mode 100644 index bf240a58..00000000 --- a/lineagehw/touch/TouchscreenGesture.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#define LOG_TAG "TouchscreenGestureService" - -#include <unordered_map> - -#include <android-base/file.h> -#include <android-base/logging.h> - -#include "TouchscreenGesture.h" - -namespace { -typedef struct { - int32_t keycode; - const char* name; - const char* path; -} GestureInfo; - -// id -> info -const std::unordered_map<int32_t, GestureInfo> kGestureInfoMap = { - {0, {255, "Up arrow", "/proc/touchpanel/up_arrow_enable"}}, - {1, {252, "Down arrow", "/proc/touchpanel/down_arrow_enable"}}, - {2, {253, "Left arrow", "/proc/touchpanel/left_arrow_enable"}}, - {3, {254, "Right arrow", "/proc/touchpanel/right_arrow_enable"}}, - {4, {251, "Two finger down swipe", "/proc/touchpanel/double_swipe_enable"}}, - {5, {66, "One finger up swipe", "/proc/touchpanel/up_swipe_enable"}}, - {6, {65, "One finger down swipe", "/proc/touchpanel/down_swipe_enable"}}, - {7, {64, "One finger left swipe", "/proc/touchpanel/left_swipe_enable"}}, - {8, {63, "One finger right swipe", "/proc/touchpanel/right_swipe_enable"}}, - {9, {250, "Letter O", "/proc/touchpanel/letter_o_enable"}}, -}; -} // anonymous namespace - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace implementation { - -Return<void> TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) { - std::vector<Gesture> gestures; - - for (const auto& entry : kGestureInfoMap) { - gestures.push_back({entry.first, entry.second.name, entry.second.keycode}); - } - resultCb(gestures); - - return Void(); -} - -Return<bool> TouchscreenGesture::setGestureEnabled( - const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enabled) { - const auto entry = kGestureInfoMap.find(gesture.id); - if (entry == kGestureInfoMap.end()) { - return false; - } - - if (!android::base::WriteStringToFile((enabled ? "1" : "0"), entry->second.path)) { - LOG(ERROR) << "Wrote file " << entry->second.path << " failed"; - return false; - } - return true; -} - -} // namespace implementation -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/touch/TouchscreenGesture.h b/lineagehw/touch/TouchscreenGesture.h deleted file mode 100644 index 0071243c..00000000 --- a/lineagehw/touch/TouchscreenGesture.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#ifndef VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H -#define VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H - -#include <vendor/lineage/touch/1.0/ITouchscreenGesture.h> - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::Return; -using ::android::hardware::Void; - -class TouchscreenGesture : public ITouchscreenGesture { - public: - // Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow. - Return<void> getSupportedGestures(getSupportedGestures_cb resultCb) override; - Return<bool> setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture, - bool enabled) override; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H diff --git a/lineagehw/touch/service.cpp b/lineagehw/touch/service.cpp deleted file mode 100644 index 360125e1..00000000 --- a/lineagehw/touch/service.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * 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. - */ - -#define LOG_TAG "vendor.lineage.touch@1.0-service.oneplus3" - -#include <android-base/logging.h> -#include <hidl/HidlTransportSupport.h> - -#include "KeyDisabler.h" -#include "TouchscreenGesture.h" - -using ::android::OK; -using ::android::sp; - -using ::vendor::lineage::touch::V1_0::IKeyDisabler; -using ::vendor::lineage::touch::V1_0::ITouchscreenGesture; -using ::vendor::lineage::touch::V1_0::implementation::KeyDisabler; -using ::vendor::lineage::touch::V1_0::implementation::TouchscreenGesture; - -int main() { - sp<ITouchscreenGesture> gestureService = new TouchscreenGesture(); - sp<IKeyDisabler> keyDisabler = new KeyDisabler(); - - android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (gestureService->registerAsService() != OK) { - LOG(ERROR) << "Cannot register touchscreen gesture HAL service."; - return 1; - } - - if (keyDisabler->registerAsService() != OK) { - LOG(ERROR) << "Cannot register keydisabler HAL service."; - return 1; - } - - LOG(INFO) << "Touchscreen HAL service ready."; - - android::hardware::joinRpcThreadpool(); - - LOG(ERROR) << "Touchscreen HAL service failed to join thread pool."; - return 1; -} diff --git a/lineagehw/touch/vendor.lineage.touch@1.0-service.oneplus3.rc b/lineagehw/touch/vendor.lineage.touch@1.0-service.oneplus3.rc deleted file mode 100644 index c619d03e..00000000 --- a/lineagehw/touch/vendor.lineage.touch@1.0-service.oneplus3.rc +++ /dev/null @@ -1,29 +0,0 @@ -on boot - chown system system /proc/s1302/virtual_key - chmod 0660 /proc/s1302/virtual_key - - chown system system /proc/touchpanel/up_swipe_enable - chmod 0660 /proc/touchpanel/up_swipe_enable - chown system system /proc/touchpanel/down_swipe_enable - chmod 0660 /proc/touchpanel/down_swipe_enable - chown system system /proc/touchpanel/left_swipe_enable - chmod 0660 /proc/touchpanel/left_swipe_enable - chown system system /proc/touchpanel/right_swipe_enable - chmod 0660 /proc/touchpanel/right_swipe_enable - chown system system /proc/touchpanel/double_swipe_enable - chmod 0660 /proc/touchpanel/double_swipe_enable - chown system system /proc/touchpanel/up_arrow_enable - chmod 0660 /proc/touchpanel/up_arrow_enable - chown system system /proc/touchpanel/down_arrow_enable - chmod 0660 /proc/touchpanel/down_arrow_enable - chown system system /proc/touchpanel/left_arrow_enable - chmod 0660 /proc/touchpanel/left_arrow_enable - chown system system /proc/touchpanel/right_arrow_enable - chmod 0660 /proc/touchpanel/right_arrow_enable - chown system system /proc/touchpanel/letter_o_enable - chmod 0660 /proc/touchpanel/letter_o_enable - -service touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.oneplus3 - class hal - user system - group system diff --git a/overlay-aosip/frameworks/base/core/res/res/values/config.xml b/overlay-aosip/frameworks/base/core/res/res/values/config.xml new file mode 100644 index 00000000..427c6ea6 --- /dev/null +++ b/overlay-aosip/frameworks/base/core/res/res/values/config.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2013, The Android Open Source Project +** +** 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. +*/ +--> + <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <bool name="config_button_brightness_support">true</bool> + <!-- Hardware keys present on the device, stored as a bit field. + This integer should equal the sum of the corresponding value for each + of the following keys present: + 1 - Home + 2 - Back + 4 - Menu + 8 - Assistant (search) + 16 - App switch + 32 - Camera + 64 - Volume rocker + For example, a device with Home, Back and Menu keys would set this + config to 7. --> + <integer name="config_deviceHardwareKeys">83</integer> + <!-- Whether notify fingerprint client of successful cancelled authentication --> + <bool name="config_notifyClientOnFingerprintCancelSuccess">true</bool> + <!-- Whether device has dash charging support --> + <bool name="config_hasDashCharger">true</bool> + <!-- Stop listening to the fingerprint reader when NON-WAKEUP proximity sensor is covered & screen is off. + config_proximityCheckOnWake must be true. --> + <bool name="config_proximityCheckOnFingerprintWake">true</bool> + <!-- Default value for proximity check on screen wake + NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)--> + <bool name="config_proximityCheckOnWake">true</bool> + <integer name="config_proximityCheckTimeout">100</integer> + <bool name="config_proximityCheckOnWakeEnabledByDefault">true</bool> + </resources>
\ No newline at end of file diff --git a/overlay-lineage/frameworks/base/core/res/res/values/lineage_config.xml b/overlay-lineage/frameworks/base/core/res/res/values/lineage_config.xml deleted file mode 100644 index a002baff..00000000 --- a/overlay-lineage/frameworks/base/core/res/res/values/lineage_config.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2018 The LineageOS Project - - 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. ---> -<resources> - <!-- Button backlight --> - <bool name="config_deviceHasVariableButtonBrightness">true</bool> -</resources> diff --git a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml b/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml deleted file mode 100644 index c12fe998..00000000 --- a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml +++ /dev/null @@ -1,141 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2015-2016 The CyanogenMod Project - - 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. ---> -<resources> - - <!-- Default value for proximity check on screen wake - NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)--> - <bool name="config_proximityCheckOnWake">true</bool> - <integer name="config_proximityCheckTimeout">100</integer> - <bool name="config_proximityCheckOnWakeEnabledByDefault">true</bool> - - <!-- All the capabilities of the LEDs on this device, stored as a bit field. - This integer should equal the sum of the corresponding value for each - of the following capabilities present: - - // Device has a color adjustable notification light. - LIGHTS_RGB_NOTIFICATION_LED = 1 - - // Device has a color adjustable battery light. - LIGHTS_RGB_BATTERY_LED = 2 - - LIGHTS_MULTIPLE_NOTIFICATION_LED = 4 (deprecated) - - // The notification light has adjustable pulsing capability. - LIGHTS_PULSATING_LED = 8 - - // Device has a multi-segment battery light that is able to - // use the light brightness value to determine how many - // segments to show (in order to represent battery level). - LIGHTS_SEGMENTED_BATTERY_LED = 16 - - // The notification light supports HAL adjustable brightness - // via the alpha channel. - // Note: if a device notification light supports LIGHTS_RGB_NOTIFICATION_LED - // then HAL support is not necessary for brightness control. In this case, - // brightness support will be provided by lineage-sdk through the scaling of - // RGB color values. - LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32 - - // Device has a battery light. - LIGHTS_BATTERY_LED = 64 - - // The battery light supports HAL adjustable brightness via - // the alpha channel. - // Note: if a device battery light supports LIGHTS_RGB_BATTERY_LED then HAL - // support is not necessary for brightness control. In this case, - // brightness support will be provided by lineage-sdk through the scaling of - // RGB color values. - LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS = 128 - - For example, a device with notification and battery lights that supports - pulsating and RGB control would set this config to 75. --> - <integer name="config_deviceLightCapabilities">75</integer> - - <!-- For high brightness mode --> - <integer name="config_outdoorAmbientLux">20000</integer> - - <!-- Turn on LiveDisplay auto mode by default --> - <integer name="config_defaultLiveDisplayMode">2</integer> - - <!-- Display mode remapping table. - If the mode names returned by the backend do not match - the predefined and translated strings in the Settings - app, they can be remapped here. The format is - "oldname:newname", one per entry. --> - <string-array name="config_displayModeMappings" translatable="false"> - <item>standard:standard</item> - <item>dynamic:dynamic</item> - <item>cinema:cinema</item> - <item>astronomy:astronomy</item> - <item>photography:photography</item> - <item>basic:basic</item> - <item>srgb:srgb</item> - <item>dci_p3:dci_p3</item> - </string-array> - - <!-- Should we filter any display modes which are unampped? --> - <bool name="config_filterDisplayModes">true</bool> - - <!-- Hardware keys present on the device, stored as a bit field. - This integer should equal the sum of the corresponding value for each - of the following keys present: - 1 - Home - 2 - Back - 4 - Menu - 8 - Assistant (search) - 16 - App switch - 32 - Camera - 64 - Volume rocker - For example, a device with Home, Back and Menu keys would set this - config to 7. --> - <integer name="config_deviceHardwareKeys">83</integer> - - <!-- Hardware keys present on the device with the ability to wake, stored as a bit field. - This integer should equal the sum of the corresponding value for each - of the following keys present: - 1 - Home - 2 - Back - 4 - Menu - 8 - Assistant (search) - 16 - App switch - 32 - Camera - 64 - Volume rocker - For example, a device with Home, Back and Menu keys would set this - config to 7. --> - <integer name="config_deviceHardwareWakeKeys">64</integer> - - <!-- Control the behavior when the user long presses the app switch button. - 0 - Nothing - 1 - Menu key - 2 - Recent apps view in SystemUI - 3 - Launch assist intent - 4 - Voice Search - 5 - In-app Search - 6 - Launch camera - 7 - Sleep - 8 - Last app - 9 - Toggle split screen - This needs to match the enums in - sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java. - --> - <integer name="config_longPressOnAppSwitchBehavior">1</integer> - - <!-- Whether device needs to wait for Qualcomm MPCTL service to start - before setting power profiles on boot. --> - <bool name="config_waitForMpctlOnBoot">true</bool> - -</resources> diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml index 53f00d47..309ed35d 100644 --- a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml +++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml @@ -32,4 +32,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <resources> <!-- Enable doze mode --> <bool name="doze_display_state_supported">true</bool> + + <!-- Allow devices override audio panel location to the left side --> + <bool name="config_audioPanelOnLeftSide">true</bool> </resources> diff --git a/overlay/packages/apps/Settings/res/values/config.xml b/overlay/packages/apps/Settings/res/values/config.xml index 88ade9fc..46b0b4c5 100644 --- a/overlay/packages/apps/Settings/res/values/config.xml +++ b/overlay/packages/apps/Settings/res/values/config.xml @@ -24,4 +24,7 @@ 3 = right side --> <integer name="config_fingerprintSensorLocation">1</integer> + + <!-- Device specific doze package --> + <string name="config_customDozePackage">org.lineageos.settings.doze/org.lineageos.settings.doze.DozeSettingsActivity</string> </resources> diff --git a/pocketmode/Android.mk b/pocketmode/Android.mk index cb0c9947..2bfec747 100644 --- a/pocketmode/Android.mk +++ b/pocketmode/Android.mk @@ -17,9 +17,6 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \ android-support-v7-recyclerview \ android-support-v14-preference -LOCAL_STATIC_JAVA_LIBRARIES := \ - org.lineageos.platform.internal - LOCAL_PROGUARD_FLAG_FILES := proguard.flags include $(BUILD_PACKAGE) diff --git a/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java b/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java index ef1a2d29..7dc9fa7c 100644 --- a/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java +++ b/pocketmode/src/org/lineageos/pocketmode/PocketSensor.java @@ -24,10 +24,9 @@ import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.text.TextUtils; import android.util.Log; - import java.util.List; -import org.lineageos.internal.util.FileUtils; +import com.android.internal.util.aosip.FileUtils; public class PocketSensor implements SensorEventListener { diff --git a/rootdir/etc/init.oneplus3.rc b/rootdir/etc/init.oneplus3.rc index 888d1f02..6ae1609b 100644 --- a/rootdir/etc/init.oneplus3.rc +++ b/rootdir/etc/init.oneplus3.rc @@ -92,6 +92,26 @@ on boot # Touchscreen chown system system /proc/touchpanel/double_tap_enable chmod 0660 /proc/touchpanel/double_tap_enable + chown system system /proc/touchpanel/up_swipe_enable + chmod 0660 /proc/touchpanel/up_swipe_enable + chown system system /proc/touchpanel/down_swipe_enable + chmod 0660 /proc/touchpanel/down_swipe_enable + chown system system /proc/touchpanel/left_swipe_enable + chmod 0660 /proc/touchpanel/left_swipe_enable + chown system system /proc/touchpanel/right_swipe_enable + chmod 0660 /proc/touchpanel/right_swipe_enable + chown system system /proc/touchpanel/double_swipe_enable + chmod 0660 /proc/touchpanel/double_swipe_enable + chown system system /proc/touchpanel/up_arrow_enable + chmod 0660 /proc/touchpanel/up_arrow_enable + chown system system /proc/touchpanel/down_arrow_enable + chmod 0660 /proc/touchpanel/down_arrow_enable + chown system system /proc/touchpanel/left_arrow_enable + chmod 0660 /proc/touchpanel/left_arrow_enable + chown system system /proc/touchpanel/right_arrow_enable + chmod 0660 /proc/touchpanel/right_arrow_enable + chown system system /proc/touchpanel/letter_o_enable + chmod 0660 /proc/touchpanel/letter_o_enable # Buttons chown system system /proc/s1302/key_rep diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index ef254c51..1fe68281 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -15,9 +15,12 @@ # FRP partition /dev/block/platform/soc/624000.ufshc/by-name/config u:object_r:frp_block_device:s0 -# Lineage hardware -/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service\.oneplus3 u:object_r:hal_lineage_livedisplay_qti_exec:s0 -/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.oneplus3 u:object_r:hal_lineage_touch_default_exec:s0 +# Healthd +/sys/devices/soc/soc:qcom,bcl/power_supply/bcl/type u:object_r:sysfs_batteryinfo:s0 +/sys/devices/soc/msm-bcl-14/power_supply/fg_adc/type u:object_r:sysfs_batteryinfo:s0 + +# LEDs +/sys/devices/soc/leds-qpnp-[0-9]+/leds(/.*)? u:object_r:sysfs_leds:s0 # OTA /system/bin/move_time_data\.sh u:object_r:move-time-data-sh_exec:s0 diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts index ec8ef654..3e0aff30 100644 --- a/sepolicy/genfs_contexts +++ b/sepolicy/genfs_contexts @@ -10,10 +10,6 @@ genfscon sysfs /devices/soc/leds-qpnp-18/leds u:object_r:sysfs_leds:s0 genfscon sysfs /devices/soc/leds-qpnp-24/leds u:object_r:sysfs_leds:s0 genfscon sysfs /devices/soc/leds-qpnp-25/leds u:object_r:sysfs_leds:s0 -# LiveDisplay -genfscon sysfs /devices/virtual/graphics/fb0/dci_p3 u:object_r:sysfs_livedisplay_tuneable:s0 -genfscon sysfs /devices/virtual/graphics/fb0/srgb u:object_r:sysfs_livedisplay_tuneable:s0 - # Ril genfscon debugfs /rmt_storage u:object_r:debugfs_rmt_storage:s0 diff --git a/sepolicy/hal_lineage_livedisplay_qti.te b/sepolicy/hal_lineage_livedisplay_qti.te deleted file mode 100644 index 78a0dd34..00000000 --- a/sepolicy/hal_lineage_livedisplay_qti.te +++ /dev/null @@ -1,2 +0,0 @@ -# Grant access over LiveDisplay tuneables -allow hal_lineage_livedisplay_qti sysfs_livedisplay_tuneable:file rw_file_perms; diff --git a/sepolicy/hal_lineage_touch_default.te b/sepolicy/hal_lineage_touch_default.te deleted file mode 100644 index 2782309b..00000000 --- a/sepolicy/hal_lineage_touch_default.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_lineage_touch_default proc_touchpanel:dir search; -allow hal_lineage_touch_default proc_touchpanel:file rw_file_perms; |
