Skip to content

Commit

Permalink
Revert "raphael: Remove livedisplay"
Browse files Browse the repository at this point in the history
This reverts commit cd185ec.
  • Loading branch information
kondors1995 committed Feb 8, 2024
1 parent 37bb535 commit ac79613
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 3 deletions.
4 changes: 4 additions & 0 deletions device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ PRODUCT_PROPERTY_OVERRIDES += \
PRODUCT_PACKAGES += \
android.hardware.light-service.xiaomi

# Livedisplay
PRODUCT_PACKAGES += \
[email protected]

# Media
PRODUCT_PACKAGES += \
libavservices_minijail \
Expand Down
40 changes: 40 additions & 0 deletions livedisplay/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright (C) 2019-2020 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: "[email protected]",
defaults: ["hidl_defaults"],
vintf_fragments: ["[email protected]"],
init_rc: ["[email protected]"],
relative_install_path: "hw",
srcs: [
":[email protected]",
"AntiFlicker.cpp",
"SunlightEnhancement.cpp",
"service.cpp",
],
vendor: true,
shared_libs: [
"libbase",
"libbinder",
"libhidlbase",
"libutils",
"[email protected]",
"[email protected]",
],
header_libs: [
"[email protected]",
],
}
51 changes: 51 additions & 0 deletions livedisplay/AntiFlicker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2021 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 "AntiFlickerService"

#include "AntiFlicker.h"
#include <android-base/logging.h>
#include <fstream>

namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {

static constexpr const char* kDcDimmingPath =
"/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dc_dim";

Return<bool> AntiFlicker::isEnabled() {
std::ifstream file(kDcDimmingPath);
int result = -1;
file >> result;
LOG(DEBUG) << "Got result " << result << " fail " << file.fail();
return !file.fail() && result > 0;
}

Return<bool> AntiFlicker::setEnabled(bool enabled) {
std::ofstream file(kDcDimmingPath);
file << (enabled ? "1" : "0");
LOG(DEBUG) << "setEnabled fail " << file.fail();
return !file.fail();
}

} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor
47 changes: 47 additions & 0 deletions livedisplay/AntiFlicker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2021 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_1_ANTIFLICKER_H
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H

#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/livedisplay/2.1/IAntiFlicker.h>

namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {

using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;

class AntiFlicker : public IAntiFlicker {
public:
// Methods from ::vendor::lineage::livedisplay::V2_1::IAntiFlicker follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
};

} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H
55 changes: 55 additions & 0 deletions livedisplay/SunlightEnhancement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2019-2020 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 "SunlightEnhancementService"

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/strings.h>

#include "SunlightEnhancement.h"

namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {

static constexpr const char* kHbmStatusPath =
"/sys/devices/platform/soc/soc:qcom,dsi-display-primary/hbm";

Return<bool> SunlightEnhancement::isEnabled() {
std::string buf;
if (!android::base::ReadFileToString(kHbmStatusPath, &buf)) {
LOG(ERROR) << "Failed to read " << kHbmStatusPath;
return false;
}
return std::stoi(android::base::Trim(buf)) == 1;
}

Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kHbmStatusPath)) {
LOG(ERROR) << "Failed to write " << kHbmStatusPath;
return false;
}
return true;
}

} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor
47 changes: 47 additions & 0 deletions livedisplay/SunlightEnhancement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2019-2020 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_1_SUNLIGHTENHANCEMENT_H
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H

#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/livedisplay/2.1/ISunlightEnhancement.h>

namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {

using ::android::sp;
using ::android::hardware::Return;
using ::android::hardware::Void;

class SunlightEnhancement : public ISunlightEnhancement {
public:
// Methods from ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
};

} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H
66 changes: 66 additions & 0 deletions livedisplay/service.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2019-2020 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 "[email protected]"

#include <android-base/logging.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>

#include "AntiFlicker.h"
#include "SunlightEnhancement.h"
#include "livedisplay/sdm/SDMController.h"

using android::OK;
using android::sp;
using android::status_t;

using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController;
using ::vendor::lineage::livedisplay::V2_1::IAntiFlicker;
using ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement;
using ::vendor::lineage::livedisplay::V2_1::implementation::AntiFlicker;
using ::vendor::lineage::livedisplay::V2_1::implementation::SunlightEnhancement;

int main() {
status_t status = OK;
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
sp<AntiFlicker> af = new AntiFlicker();
sp<SunlightEnhancement> se = new SunlightEnhancement();
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);

// AntiFlicker service
status = af->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL AntiFlicker Iface ("
<< status << ")";
return 1;
}

// SunlightEnhancement service
status = se->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
<< status << ")";
return 1;
}

LOG(INFO) << "LiveDisplay HAL service is ready.";

android::hardware::joinRpcThreadpool();

LOG(ERROR) << "LiveDisplay HAL service failed to join thread pool.";
return 1;
}
10 changes: 10 additions & 0 deletions livedisplay/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
on boot
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/hbm
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dc_dim
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/hbm
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dc_dim

service vendor.livedisplay-hal-2-1 /vendor/bin/hw/[email protected]
class hal
user system
group system
8 changes: 8 additions & 0 deletions livedisplay/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.livedisplay</name>
<transport>hwbinder</transport>
<fqname>@2.1::IAntiFlicker/default</fqname>
<fqname>@2.1::ISunlightEnhancement/default</fqname>
</hal>
</manifest>
6 changes: 3 additions & 3 deletions sepolicy/vendor/file.te
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ type persist_camera_file, vendor_persist_type, file_type;
type proc_last_kmsg, fs_type, proc_type;
type public_adsprpcd_file, file_type;

# Livedisplay
type vendor_sysfs_hbm, sysfs_type, fs_type;

# Nodes
type sysfs_fod, sysfs_type, fs_type;
type sysfs_kgsl, sysfs_type, fs_type;
type sysfs_msm_boot, fs_type, sysfs_type;
type sysfs_touchpanel, fs_type, sysfs_type;

# HBM
type vendor_sysfs_hbm, sysfs_type, fs_type;
3 changes: 3 additions & 0 deletions sepolicy/vendor/file_contexts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
# LEDs
/sys/devices/platform/soc/[a-z0-9]+.qcom,spmi/spmi-[0-1]/spmi0-0[0-9]/[a-z0-9]+.qcom,spmi:qcom,[a-z0-9]+@[0-9]:qcom,leds@d000/leds(/.*)? u:object_r:sysfs_leds:s0

# Livedisplay
/vendor/bin/hw/vendor\.lineage\.livedisplay@2\.1-service\.raphael u:object_r:hal_lineage_livedisplay_qti_exec:s0

# MAC
/vendor/bin/nv_mac u:object_r:vendor_wcnss_service_exec:s0
/data/vendor/mac_addr(/.*)? u:object_r:vendor_wifi_vendor_data_file:s0
Expand Down
3 changes: 3 additions & 0 deletions sepolicy/vendor/hal_lineage_livedisplay_qti.te
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allow hal_lineage_livedisplay_qti vendor_sysfs_hbm:file rw_file_perms;
allow hal_lineage_livedisplay_qti vendor_sysfs_graphics:dir r_dir_perms;
allow hal_lineage_livedisplay_qti vendor_sysfs_graphics:file rw_file_perms;

0 comments on commit ac79613

Please sign in to comment.