|
|
@ -1,5 +1,5 @@ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 The LineageOS Project |
|
|
|
* Copyright (C) 2020-2021 The LineageOS Project |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -18,6 +18,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "FastCharge.h" |
|
|
|
#include "FastCharge.h" |
|
|
|
#include <android-base/logging.h> |
|
|
|
#include <android-base/logging.h> |
|
|
|
|
|
|
|
#include <cutils/properties.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <fstream> |
|
|
|
#include <fstream> |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include "samsung_fastcharge.h" |
|
|
|
#include "samsung_fastcharge.h" |
|
|
@ -28,6 +30,8 @@ namespace fastcharge { |
|
|
|
namespace V1_0 { |
|
|
|
namespace V1_0 { |
|
|
|
namespace implementation { |
|
|
|
namespace implementation { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static constexpr const char* kFastChargingProp = "persist.vendor.sec.fastchg_enabled"; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Write value to path and close file. |
|
|
|
* Write value to path and close file. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -71,6 +75,10 @@ static T get(const std::string& path, const T& def) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FastCharge::FastCharge() { |
|
|
|
|
|
|
|
setEnabled(property_get_bool(kFastChargingProp, FASTCHARGE_DEFAULT_SETTING)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Return<bool> FastCharge::isEnabled() { |
|
|
|
Return<bool> FastCharge::isEnabled() { |
|
|
|
return get(FASTCHARGE_PATH, 0) < 1; |
|
|
|
return get(FASTCHARGE_PATH, 0) < 1; |
|
|
|
} |
|
|
|
} |
|
|
@ -78,7 +86,10 @@ Return<bool> FastCharge::isEnabled() { |
|
|
|
Return<bool> FastCharge::setEnabled(bool enable) { |
|
|
|
Return<bool> FastCharge::setEnabled(bool enable) { |
|
|
|
set(FASTCHARGE_PATH, enable ? 0 : 1); |
|
|
|
set(FASTCHARGE_PATH, enable ? 0 : 1); |
|
|
|
|
|
|
|
|
|
|
|
return isEnabled(); |
|
|
|
bool enabled = isEnabled(); |
|
|
|
|
|
|
|
property_set(kFastChargingProp, enabled ? "true" : "false"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return enabled; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace implementation
|
|
|
|
} // namespace implementation
|
|
|
|