[feat] add privacy unlock controls and remote relocking

This commit is contained in:
dijunkun
2026-10-27 10:22:25 +08:00
parent d1e4a31efb
commit ea3a2e1faa
41 changed files with 470 additions and 72 deletions
@@ -14,7 +14,7 @@
namespace crossdesk::mobile_controller {
inline std::string PrivacyMessage(int flag, bool block_local_input) {
if (flag < 0 || flag > 2) return {};
if (flag < 0 || flag > 3) return {};
RemoteAction action{};
action.type = privacy_command;
action.pc = {static_cast<PrivacyCommandFlag>(flag), block_local_input};
+3 -1
View File
@@ -157,7 +157,7 @@ struct ServiceCommand {
};
enum class PrivacyState { unsupported, off, starting, on, stopping, failed };
enum class PrivacyCommandFlag { query, enable, disable };
enum class PrivacyCommandFlag { query, enable, disable, lock };
struct PrivacyCommand {
PrivacyCommandFlag flag;
bool block_local_input;
@@ -171,6 +171,8 @@ struct PrivacyStatus {
bool remote_paused;
uint32_t revision;
char reason[256];
// Monotonic event counter retained across status heartbeats and recovery.
uint32_t local_unlock_revision;
};
struct VideoSettings {
+9 -2
View File
@@ -224,7 +224,8 @@ std::string RemoteAction::ToJson(const RemoteAction& action) {
{"overlay_active", action.ps.overlay_active},
{"input_blocked", action.ps.input_blocked},
{"remote_paused", action.ps.remote_paused},
{"revision", action.ps.revision}, {"reason", action.ps.reason}};
{"revision", action.ps.revision}, {"reason", action.ps.reason},
{"local_unlock_revision", action.ps.local_unlock_revision}};
break;
case ControlType::host_infomation: {
json displays = json::array();
@@ -409,7 +410,7 @@ bool RemoteAction::FromJson(const std::string& json_string,
case ControlType::privacy_command: {
const auto& command = object.at("privacy_command");
const int flag = command.at("flag").get<int>();
if (flag < 0 || flag > 2) return false;
if (flag < 0 || flag > 3) return false;
output.pc.flag = static_cast<PrivacyCommandFlag>(flag);
output.pc.block_local_input = command.at("block_local_input").get<bool>();
break;
@@ -427,6 +428,12 @@ bool RemoteAction::FromJson(const std::string& json_string,
output.ps.input_blocked = status.at("input_blocked").get<bool>();
output.ps.remote_paused = status.at("remote_paused").get<bool>();
output.ps.revision = status.at("revision").get<uint32_t>();
output.ps.local_unlock_revision = 0;
if (const auto event = status.find("local_unlock_revision"); event != status.end()) {
if (!event->is_number_integer() || event->get<int64_t>() < 0 ||
event->get<uint64_t>() > UINT32_MAX) return false;
output.ps.local_unlock_revision = event->get<uint32_t>();
}
std::memcpy(output.ps.reason, reason.c_str(), reason.size() + 1);
// Never render a contradictory success from a malformed peer.
if (output.ps.state == PrivacyState::on &&