A doc/os_api/endpoints/pure/security_endpoint.md => doc/os_api/endpoints/pure/security_endpoint.md +124 -0
@@ 0,0 1,124 @@
+Security endpoint (13)
+=============================
+
+* [Parameters explanation](#parameters-explanation)
+* [Usage examples](#usage-examples)
+ * [Get phone lock status](#get-phone-lock-status)
+ * [Get phone lock time](#get-phone-lock-time)
+ * [Set phone lock off](#set-phone-lock-off)
+
+## Parameters explanation
+
+[Common parameters explanation](../../protocol_description/common_parameters_explanation.md)
+
+## Usage examples
+
+### Get phone lock status
+
+**Request Payload Structure**
+
+```json
+{
+ "endpoint":13,
+ "method":1,
+ "uuid":123,
+ "body":{
+ "category":"phoneLockStatus"
+ }
+}
+```
+
+**Response Payload Structure**
+
+```json
+{
+ "endpoint":13,
+ "status":204,
+ "uuid":123
+}
+```
+
+Parameters:
+ - *status* - 423 when the EULA is not accepted or battery level is critical otherwise 204 when phone is unlocked or 403 when phone is locked
+
+Access to all edpoints is blocked when:
+- device is locked - 403 status is returned
+- EULA is not accepted - 423 status is returned
+- Critical battery level - 423 status is returned
+
+### Get phone lock time
+
+**Request Payload Structure**
+
+```json
+{
+ "endpoint":13,
+ "method":1,
+ "uuid":123,
+ "body":{
+ "category":"phoneLockTime"
+ }
+}
+```
+
+**Response Payload Structure**
+
+```json
+{
+ "endpoint":13,
+ "status":200,
+ "uuid":123,
+ "body":{
+ "phoneLockTime":1630919524,
+ "timeLeftToNextAttempt":120
+ }
+}
+```
+
+Parameters:
+- *phoneLockTime* - timestamp in seconds when the next attempt of phone unlock will be possible
+- *timeLeftToNextAttempt* - time left in seconds, after which the next attempt of phone unlock will be possible
+
+**Response Payload Structure when phone is not time locked**
+
+```json
+{
+ "endpoint":13,
+ "status":422,
+ "uuid":123
+}
+```
+
+Parameters:
+- *status* - 422 when phone is unlocked, or unlocking phone is possible at this moment
+
+### Set phone lock off
+
+**Request Payload Structure**
+
+```json
+{
+ "endpoint":13,
+ "method":3,
+ "uuid":123,
+ "body":{
+ "phoneLockCode":[1, 1, 1, 1]
+ }
+}
+```
+
+**Response Payload Structure**
+
+```json
+{
+ "endpoint":13,
+ "status":204,
+ "uuid":123
+}
+```
+
+Parameters:
+- *phoneLockCode* - code needed to unlock phone as array of integer values
+- *status* - 204 if passed phoneLockCode has a correct format (eg. length), 400 otherwise
+
+It is Mudita Center responsibility to check if phone was successfully unlocked by checking phone lock status.<
\ No newline at end of file
M module-services/service-desktop/USBSecurityModel.cpp => module-services/service-desktop/USBSecurityModel.cpp +14 -4
@@ 6,6 6,7 @@
#include "Service/Service.hpp"
#include "service-desktop/DesktopMessages.hpp"
#include "service-desktop/WorkerDesktop.hpp"
+#include <EventStore.hpp>
#include <service-db/Settings.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
@@ 50,17 51,26 @@ namespace sdesktop
settings->getValue(settings::SystemProperties::eulaAccepted, settings::SettingsScope::Global));
}
+ auto USBSecurityModel::isBatteryLevelCritical() const -> bool
+ {
+ using LevelState = Store::Battery::LevelState;
+
+ return Store::Battery::get().levelState == LevelState::CriticalCharging or
+ Store::Battery::get().levelState == LevelState::CriticalNotCharging;
+ }
+
auto USBSecurityModel::getEndpointSecurity() const -> endpointSecurity_t
{
+ if (isBatteryLevelCritical()) {
+ return {EndpointSecurity::Block, BlockReason::BatteryCriticalLevel};
+ }
if (!isEulaAccepted()) {
return {EndpointSecurity::Block, BlockReason::EulaNotAccepted};
}
- else if (isSecurityEnabled()) {
+ if (isSecurityEnabled()) {
return {EndpointSecurity::Block, BlockReason::DeviceLocked};
}
- else {
- return {EndpointSecurity::Allow, BlockReason::NoReason};
- }
+ return {EndpointSecurity::Allow, BlockReason::NoReason};
}
auto USBSecurityModel::updatePhoneLockTime(const time_t newPhoneLockTime) -> void
M module-services/service-desktop/endpoints/include/endpoints/Endpoint.hpp => module-services/service-desktop/endpoints/include/endpoints/Endpoint.hpp +2 -1
@@ 20,7 20,8 @@ namespace sdesktop::endpoints
{
NoReason,
DeviceLocked,
- EulaNotAccepted
+ EulaNotAccepted,
+ BatteryCriticalLevel
};
enum class OnboardingState
M module-services/service-desktop/endpoints/security/SecurityEndpointHelper.cpp => module-services/service-desktop/endpoints/security/SecurityEndpointHelper.cpp +3 -0
@@ 67,6 67,9 @@ namespace sdesktop::endpoints
case BlockReason::EulaNotAccepted:
result = http::Code::Locked;
break;
+ case BlockReason::BatteryCriticalLevel:
+ result = http::Code::Locked;
+ break;
}
}
return result;
M module-services/service-desktop/include/service-desktop/USBSecurityModel.hpp => module-services/service-desktop/include/service-desktop/USBSecurityModel.hpp +1 -0
@@ 47,6 47,7 @@ namespace sdesktop
auto isPasscodeEnabled() const -> bool;
auto isPhoneLocked() const -> bool;
auto isEulaAccepted() const -> bool;
+ auto isBatteryLevelCritical() const -> bool;
PhoneLockState phoneLocked;
settings::Settings *settings;
M products/PurePhone/services/evtmgr/include/evtmgr/battery/Thresholds.hpp => products/PurePhone/services/evtmgr/include/evtmgr/battery/Thresholds.hpp +1 -1
@@ 7,7 7,7 @@
namespace constants
{
- static constexpr units::Percent criticalThreshold = 10;
+ static constexpr units::Percent criticalThreshold = 5;
static constexpr units::Percent shutdownThreshold = 1;
static constexpr units::Voltage shutdownVoltageThreshold = 3600;
M pure_changelog.md => pure_changelog.md +1 -0
@@ 12,6 12,7 @@
* Made EULA window scroll by a few lines at once
* Updated Bluetooth stack
* Unified GUI flow for adding contact with number already present in another contact
+* Decrease critical battery level from 10% to 5%
### Fixed