#
-# Copyright (C) 2020 The LineageOS Project
+# Copyright (C) 2020-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.
LOCAL_SHARED_LIBRARIES := \
libbase \
libbinder \
+ libcutils \
libhidlbase \
libutils \
vendor.lineage.fastcharge@1.0
/*
- * Copyright (C) 2020 The LineageOS Project
+ * Copyright (C) 2020-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.
#include "FastCharge.h"
#include <android-base/logging.h>
+#include <cutils/properties.h>
+
#include <fstream>
#include <iostream>
#include "samsung_fastcharge.h"
namespace V1_0 {
namespace implementation {
+static constexpr const char* kFastChargingProp = "persist.vendor.sec.fastchg_enabled";
+
/*
* Write value to path and close file.
*/
}
}
+FastCharge::FastCharge() {
+ setEnabled(property_get_bool(kFastChargingProp, FASTCHARGE_DEFAULT_SETTING));
+}
+
Return<bool> FastCharge::isEnabled() {
return get(FASTCHARGE_PATH, 0) < 1;
}
Return<bool> FastCharge::setEnabled(bool enable) {
set(FASTCHARGE_PATH, enable ? 0 : 1);
- return isEnabled();
+ bool enabled = isEnabled();
+ property_set(kFastChargingProp, enabled ? "true" : "false");
+
+ return enabled;
}
} // namespace implementation
/*
- * Copyright (C) 2020 The LineageOS Project
+ * Copyright (C) 2020-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.
struct FastCharge : public IFastCharge {
+ FastCharge();
+
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enable) override;
};
/*
- * Copyright (C) 2020 The LineageOS Project
+ * Copyright (C) 2020-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.
#ifndef SAMSUNG_FASTCHARGE_H
#define SAMSUNG_FASTCHARGE_H
+#define FASTCHARGE_DEFAULT_SETTING true
#define FASTCHARGE_PATH "/sys/class/sec/switch/afc_disable"
#endif // SAMSUNG_FASTCHARGE_H