diff --git a/charger/Android.mk b/charger/Android.mk deleted file mode 100644 index 5d42e6a0..00000000 --- a/charger/Android.mk +++ /dev/null @@ -1,71 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -# Set healthd_density to the density bucket of the device. -healthd_density := unknown -ifneq (,$(TARGET_RECOVERY_DENSITY)) -healthd_density := $(filter %dpi,$(TARGET_RECOVERY_DENSITY)) -else -ifneq (,$(PRODUCT_AAPT_PREF_CONFIG)) -# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value. -healthd_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG)) -else -# Otherwise, use the default medium density. -healthd_density := mdpi -endif -endif - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := healthd_board_lineage.cpp -LOCAL_MODULE := libhealthd.lineage -LOCAL_CFLAGS := -Werror -LOCAL_C_INCLUDES := \ - system/core/healthd/include \ - system/core/base/include \ - bootable/recovery/minui/include -ifneq ($(BACKLIGHT_PATH),) - LOCAL_CFLAGS += -DHEALTHD_BACKLIGHT_PATH=\"$(BACKLIGHT_PATH)\" -endif -ifneq ($(SECONDARY_BACKLIGHT_PATH),) - LOCAL_CFLAGS += -DHEALTHD_SECONDARY_BACKLIGHT_PATH=\"$(SECONDARY_BACKLIGHT_PATH)\" -endif -ifneq ($(HEALTHD_BACKLIGHT_LEVEL),) - LOCAL_CFLAGS += -DHEALTHD_BACKLIGHT_LEVEL=$(HEALTHD_BACKLIGHT_LEVEL) -endif -include $(BUILD_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := font_log.png -LOCAL_SRC_FILES := fonts/$(healthd_density)/font_log.png -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)/res/images -include $(BUILD_PREBUILT) - -include $(CLEAR_VARS) - -define _add-charger-image -include $$(CLEAR_VARS) -LOCAL_MODULE := vendor_lineage_charger_$(notdir $(1)) -LOCAL_MODULE_STEM := $(notdir $(1)) -_img_modules += $$(LOCAL_MODULE) -LOCAL_SRC_FILES := $1 -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $$(TARGET_ROOT_OUT)/res/images/charger -include $$(BUILD_PREBUILT) -endef - -_img_modules := -_images := -$(foreach _img, $(call find-subdir-subdir-files, "images/$(healthd_density)", "*.png"), \ - $(eval $(call _add-charger-image,$(_img)))) - -include $(CLEAR_VARS) -LOCAL_MODULE := lineage_charger_res_images -LOCAL_MODULE_TAGS := optional -LOCAL_REQUIRED_MODULES := $(_img_modules) -LOCAL_OVERRIDES_PACKAGES := charger_res_images -include $(BUILD_PHONY_PACKAGE) - -_add-charger-image := -_img_modules := diff --git a/charger/fonts/560dpi b/charger/fonts/560dpi deleted file mode 120000 index 17ef829d..00000000 --- a/charger/fonts/560dpi +++ /dev/null @@ -1 +0,0 @@ -xxhdpi \ No newline at end of file diff --git a/charger/fonts/640dpi b/charger/fonts/640dpi deleted file mode 120000 index af2d1fe7..00000000 --- a/charger/fonts/640dpi +++ /dev/null @@ -1 +0,0 @@ -xxxhdpi \ No newline at end of file diff --git a/charger/fonts/hdpi/font_log.png b/charger/fonts/hdpi/font_log.png deleted file mode 100644 index ddf9bc7a..00000000 Binary files a/charger/fonts/hdpi/font_log.png and /dev/null differ diff --git a/charger/fonts/ldpi/font_log.png b/charger/fonts/ldpi/font_log.png deleted file mode 100644 index 72fa8cb5..00000000 Binary files a/charger/fonts/ldpi/font_log.png and /dev/null differ diff --git a/charger/fonts/mdpi/font_log.png b/charger/fonts/mdpi/font_log.png deleted file mode 100644 index d727fa1f..00000000 Binary files a/charger/fonts/mdpi/font_log.png and /dev/null differ diff --git a/charger/fonts/xhdpi/font_log.png b/charger/fonts/xhdpi/font_log.png deleted file mode 100644 index 9c16b772..00000000 Binary files a/charger/fonts/xhdpi/font_log.png and /dev/null differ diff --git a/charger/fonts/xxhdpi/font_log.png b/charger/fonts/xxhdpi/font_log.png deleted file mode 100644 index 5d122b72..00000000 Binary files a/charger/fonts/xxhdpi/font_log.png and /dev/null differ diff --git a/charger/fonts/xxxhdpi/font_log.png b/charger/fonts/xxxhdpi/font_log.png deleted file mode 100644 index 60dacec1..00000000 Binary files a/charger/fonts/xxxhdpi/font_log.png and /dev/null differ diff --git a/charger/healthd_board_lineage.cpp b/charger/healthd_board_lineage.cpp deleted file mode 100644 index dcfbc4a6..00000000 --- a/charger/healthd_board_lineage.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * 2017 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "healthd/healthd.h" -#include "minui/minui.h" - -#define LOGE(x...) do { KLOG_ERROR("charger", x); } while (0) -#define LOGW(x...) do { KLOG_WARNING("charger", x); } while (0) -#define LOGI(x...) do { KLOG_INFO("charger", x); } while (0) -#define LOGV(x...) do { KLOG_DEBUG("charger", x); } while (0) - -static const GRFont* gr_font = NULL; - -struct frame { - int min_capacity; - GRSurface *surface; -}; - -struct animation { - struct frame *frames; - int cur_frame; - int num_frames; -}; - -static struct animation anim = { - .frames = NULL, - .cur_frame = 0, - .num_frames = 0, -}; - -static const GRFont* get_font() -{ - return gr_font; -} - -static int draw_surface_centered(GRSurface* surface) -{ - int w, h, x, y; - - w = gr_get_width(surface); - h = gr_get_height(surface); - x = (gr_fb_width() - w) / 2 ; - y = (gr_fb_height() - h) / 2 ; - - gr_blit(surface, 0, 0, w, h, x, y); - return y + h; -} - -#define STR_LEN 64 -static void draw_capacity(int capacity) -{ - char cap_str[STR_LEN]; - snprintf(cap_str, (STR_LEN - 1), "%d%%", capacity); - - struct frame *f = &anim.frames[0]; - int font_x, font_y; - gr_font_size(get_font(), &font_x, &font_y); - int w = gr_measure(get_font(), cap_str); - int h = gr_get_height(f->surface); - int x = (gr_fb_width() - w) / 2; - int y = (gr_fb_height() + h) / 2; - - gr_color(255, 255, 255, 255); - gr_text(get_font(), x, y + font_y / 2, cap_str, 0); -} - -#ifdef QCOM_HARDWARE -enum alarm_time_type { - ALARM_TIME, - RTC_TIME, -}; - -static int alarm_get_time(enum alarm_time_type time_type, - time_t *secs) -{ - struct tm tm; - unsigned int cmd; - int rc, fd = -1; - - if (!secs) - return -1; - - fd = open("/dev/rtc0", O_RDONLY); - if (fd < 0) { - LOGE("Can't open rtc devfs node\n"); - return -1; - } - - switch (time_type) { - case ALARM_TIME: - cmd = RTC_ALM_READ; - break; - case RTC_TIME: - cmd = RTC_RD_TIME; - break; - default: - LOGE("Invalid time type\n"); - goto err; - } - - rc = ioctl(fd, cmd, &tm); - if (rc < 0) { - LOGE("Unable to get time\n"); - goto err; - } - - *secs = mktime(&tm) + tm.tm_gmtoff; - if (*secs < 0) { - LOGE("Invalid seconds = %ld\n", *secs); - goto err; - } - - close(fd); - return 0; - -err: - close(fd); - return -1; -} - -static void alarm_reboot(void) -{ - LOGI("alarm time is up, reboot the phone!\n"); - syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, - LINUX_REBOOT_CMD_RESTART2, "rtc"); -} - -static int alarm_set_reboot_time_and_wait(time_t secs) -{ - int rc, epollfd, nevents; - int fd = 0; - struct timespec ts; - epoll_event event, events[1]; - struct itimerspec itval; - - epollfd = epoll_create(1); - if (epollfd < 0) { - LOGE("epoll_create failed\n"); - goto err; - } - - fd = timerfd_create(CLOCK_REALTIME_ALARM, 0); - if (fd < 0) { - LOGE("timerfd_create failed\n"); - goto err; - } - - event.events = EPOLLIN | EPOLLWAKEUP; - event.data.ptr = (void *)alarm_reboot; - rc = epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &event); - if (rc < 0) { - LOGE("epoll_ctl(EPOLL_CTL_ADD) failed \n"); - goto err; - } - - itval.it_value.tv_sec = secs; - itval.it_value.tv_nsec = 0; - - itval.it_interval.tv_sec = 0; - itval.it_interval.tv_nsec = 0; - - rc = timerfd_settime(fd, TFD_TIMER_ABSTIME, &itval, NULL); - if (rc < 0) { - LOGE("timerfd_settime failed %d\n",rc); - goto err; - } - - nevents = epoll_wait(epollfd, events, 1, -1); - - if (nevents <= 0) { - LOGE("Unable to wait on alarm\n"); - goto err; - } else { - (*(void (*)())events[0].data.ptr)(); - } - - close(epollfd); - close(fd); - return 0; - -err: - if (epollfd > 0) - close(epollfd); - - if (fd >= 0) - close(fd); - return -1; -} - -/* - * 10s the estimated time from timestamp of alarm thread start - * to timestamp of android boot completed. - */ -#define TIME_DELTA 10 - -/* seconds of 1 minute*/ -#define ONE_MINUTE 60 -static void *alarm_thread(void *) -{ - time_t rtc_secs, alarm_secs; - int rc; - timespec ts; - - /* - * to support power off alarm, the time - * stored in alarm register at latest - * shutdown time should be some time - * earlier than the actual alarm time - * set by user - */ - rc = alarm_get_time(ALARM_TIME, &alarm_secs); - if (rc < 0 || !alarm_secs) - goto err; - - rc = alarm_get_time(RTC_TIME, &rtc_secs); - if (rc < 0 || !rtc_secs) - goto err; - LOGI("alarm time in rtc is %ld, rtc time is %ld\n", alarm_secs, rtc_secs); - - if (alarm_secs <= rtc_secs) { - clock_gettime(CLOCK_BOOTTIME, &ts); - - /* - * It is possible that last power off alarm time is up at this point. - * (alarm_secs + ONE_MINUTE) is the final alarm time to fire. - * (rtc_secs + ts.tv_sec + TIME_DELTA) is the estimated time of next - * boot completed to fire alarm. - * If the final alarm time is less than the estimated time of next boot - * completed to fire, that means it is not able to fire the last power - * off alarm at the right time, so just miss it. - */ - if (alarm_secs + ONE_MINUTE < rtc_secs + ts.tv_sec + TIME_DELTA) { - LOGE("alarm is missed\n"); - goto err; - } - - alarm_reboot(); - } - - rc = alarm_set_reboot_time_and_wait(alarm_secs); - if (rc < 0) - goto err; - -err: - LOGE("Exit from alarm thread\n"); - return NULL; -} -#endif - -void healthd_board_init(struct healthd_config*) -{ - pthread_t tid; - char value[PROP_VALUE_MAX]; - int rc = 0, scale_count = 0, i; - GRSurface **scale_frames; - int scale_fps; // Not in use (charger/lineage_battery_scale doesn't have FPS text - // chunk). We are using hard-coded frame.disp_time instead. - - rc = res_create_multi_display_surface("charger/lineage_battery_scale", - &scale_count, &scale_fps, &scale_frames); - if (rc < 0) { - LOGE("%s: Unable to load battery scale image", __func__); - return; - } - - anim.frames = new frame[scale_count]; - anim.num_frames = scale_count; - for (i = 0; i < anim.num_frames; i++) { - anim.frames[i].surface = scale_frames[i]; - anim.frames[i].min_capacity = 100/(scale_count-1) * i; - } - -#ifdef QCOM_HARDWARE - property_get("ro.bootmode", value, ""); - if (!strcmp("charger", value)) { - rc = pthread_create(&tid, NULL, alarm_thread, NULL); - if (rc < 0) - LOGE("Create alarm thread failed\n"); - } -#endif -} - -int healthd_board_battery_update(struct android::BatteryProperties*) -{ - // return 0 to log periodic polled battery status to kernel log - return 1; -} - -void healthd_board_mode_charger_draw_battery( - struct android::BatteryProperties *batt_prop) -{ - int start_frame = 0; - int capacity = -1; - - if (batt_prop && batt_prop->batteryLevel >= 0) { - capacity = batt_prop->batteryLevel; - } - - if (anim.num_frames == 0 || capacity < 0) { - LOGE("%s: Unable to draw battery", __func__); - return; - } - - // Find starting frame to display based on current capacity - for (start_frame = 1; start_frame < anim.num_frames; start_frame++) { - if (capacity < anim.frames[start_frame].min_capacity) - break; - } - // Always start from the level just below the current capacity - start_frame--; - - if (anim.cur_frame < start_frame) - anim.cur_frame = start_frame; - - draw_surface_centered(anim.frames[anim.cur_frame].surface); - draw_capacity(capacity); - // Move to next frame, with max possible frame at max_idx - anim.cur_frame = ((anim.cur_frame + 1) % anim.num_frames); -} - -void healthd_board_mode_charger_battery_update( - struct android::BatteryProperties*) -{ -} - -#ifdef HEALTHD_BACKLIGHT_PATH -#ifndef HEALTHD_BACKLIGHT_LEVEL -#define HEALTHD_BACKLIGHT_LEVEL 100 -#endif - -void healthd_board_mode_charger_set_backlight(bool on) -{ - int fd; - char buffer[10]; - - memset(buffer, '\0', sizeof(buffer)); - fd = open(HEALTHD_BACKLIGHT_PATH, O_RDWR); - if (fd < 0) { - LOGE("Could not open backlight node : %s\n", strerror(errno)); - return; - } - LOGV("Enabling backlight\n"); - snprintf(buffer, sizeof(buffer), "%d\n", on ? HEALTHD_BACKLIGHT_LEVEL : 0); - if (write(fd, buffer, strlen(buffer)) < 0) { - LOGE("Could not write to backlight : %s\n", strerror(errno)); - } - close(fd); - -#ifdef HEALTHD_SECONDARY_BACKLIGHT_PATH - fd = open(HEALTHD_SECONDARY_BACKLIGHT_PATH, O_RDWR); - if (fd < 0) { - LOGE("Could not open second backlight node : %s\n", strerror(errno)); - return; - } - LOGV("Enabling secondary backlight\n"); - if (write(fd, buffer, strlen(buffer)) < 0) { - LOGE("Could not write to second backlight : %s\n", strerror(errno)); - return; - } - close(fd); -#endif -} - -#else -void healthd_board_mode_charger_set_backlight(bool) -{ -} -#endif - -void healthd_board_mode_charger_init(void) -{ - GRFont* tmp_font; - int res = gr_init_font("font_log", &tmp_font); - if (res == 0) { - gr_font = tmp_font; - } else { - LOGW("Couldn't open font, falling back to default!\n"); - gr_font = gr_sys_font(); - } - -} diff --git a/charger/images/400dpi b/charger/images/400dpi deleted file mode 120000 index 17ef829d..00000000 --- a/charger/images/400dpi +++ /dev/null @@ -1 +0,0 @@ -xxhdpi \ No newline at end of file diff --git a/charger/images/420dpi b/charger/images/420dpi deleted file mode 120000 index 17ef829d..00000000 --- a/charger/images/420dpi +++ /dev/null @@ -1 +0,0 @@ -xxhdpi \ No newline at end of file diff --git a/charger/images/560dpi b/charger/images/560dpi deleted file mode 120000 index af2d1fe7..00000000 --- a/charger/images/560dpi +++ /dev/null @@ -1 +0,0 @@ -xxxhdpi \ No newline at end of file diff --git a/charger/images/640dpi b/charger/images/640dpi deleted file mode 120000 index af2d1fe7..00000000 --- a/charger/images/640dpi +++ /dev/null @@ -1 +0,0 @@ -xxxhdpi \ No newline at end of file diff --git a/charger/images/hdpi/lineage_battery_scale.png b/charger/images/hdpi/lineage_battery_scale.png deleted file mode 100644 index 0052c0ae..00000000 Binary files a/charger/images/hdpi/lineage_battery_scale.png and /dev/null differ diff --git a/charger/images/ldpi/lineage_battery_scale.png b/charger/images/ldpi/lineage_battery_scale.png deleted file mode 100644 index b93c3af9..00000000 Binary files a/charger/images/ldpi/lineage_battery_scale.png and /dev/null differ diff --git a/charger/images/mdpi/lineage_battery_scale.png b/charger/images/mdpi/lineage_battery_scale.png deleted file mode 100644 index eb16a292..00000000 Binary files a/charger/images/mdpi/lineage_battery_scale.png and /dev/null differ diff --git a/charger/images/xhdpi/lineage_battery_scale.png b/charger/images/xhdpi/lineage_battery_scale.png deleted file mode 100644 index 078b2a66..00000000 Binary files a/charger/images/xhdpi/lineage_battery_scale.png and /dev/null differ diff --git a/charger/images/xxhdpi/lineage_battery_scale.png b/charger/images/xxhdpi/lineage_battery_scale.png deleted file mode 100644 index 2e6553ed..00000000 Binary files a/charger/images/xxhdpi/lineage_battery_scale.png and /dev/null differ diff --git a/charger/images/xxxhdpi/lineage_battery_scale.png b/charger/images/xxxhdpi/lineage_battery_scale.png deleted file mode 100644 index 90c627d4..00000000 Binary files a/charger/images/xxxhdpi/lineage_battery_scale.png and /dev/null differ diff --git a/config/BoardConfigLineage.mk b/config/BoardConfigLineage.mk index 547792fd..d407bcbe 100644 --- a/config/BoardConfigLineage.mk +++ b/config/BoardConfigLineage.mk @@ -1,8 +1,3 @@ -# Charger -ifeq ($(WITH_LINEAGE_CHARGER),true) - BOARD_HAL_STATIC_LIBRARIES := libhealthd.lineage -endif - include vendor/lineage/config/BoardConfigKernel.mk ifeq ($(BOARD_USES_QCOM_HARDWARE),true) diff --git a/config/common_mobile.mk b/config/common_mobile.mk index 7fe415e7..2b28d7c9 100644 --- a/config/common_mobile.mk +++ b/config/common_mobile.mk @@ -53,14 +53,6 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ charger_res_images -# Custom off-mode charger -ifeq ($(WITH_LINEAGE_CHARGER),true) -PRODUCT_PACKAGES += \ - lineage_charger_res_images \ - font_log.png \ - libhealthd.lineage -endif - # Customizations PRODUCT_PACKAGES += \ LineageNavigationBarNoHint \