Commit 29b13b51 authored by Robert Ferrese's avatar Robert Ferrese Committed by Commit Bot

Add reboot support for Fuchsia.

Bug: b/140491587
Change-Id: I0bb446e8740c058526c3899b4ec3ec47171d3d25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1956012
Commit-Queue: Robert Ferrese <rferrese@google.com>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726448}
parent 8c6959f0
......@@ -59,11 +59,19 @@ cast_shared_library("libcast_reboot_1.0") {
]
}
cast_source_set("fuchsia") {
sources = [
"reboot_fuchsia.cc",
]
public_deps = [
"//chromecast/public",
]
if (is_fuchsia) {
cast_source_set("fuchsia") {
sources = [
"reboot_fuchsia.cc",
]
public_deps = [
"//chromecast/public",
]
deps = [
"//base",
"//third_party/fuchsia-sdk/sdk:fidl",
"//third_party/fuchsia-sdk/sdk:fidl_cpp",
"//third_party/fuchsia-sdk/sdk:fuchsia-hardware-power-statecontrol",
]
}
}
......@@ -2,34 +2,53 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fuchsia/hardware/power/statecontrol/cpp/fidl.h>
#include "base/fuchsia/fuchsia_logging.h"
#include "base/fuchsia/service_directory_client.h"
#include "base/no_destructor.h"
#include "chromecast/public/reboot_shlib.h"
using fuchsia::hardware::power::statecontrol::Admin_Suspend_Result;
using fuchsia::hardware::power::statecontrol::AdminSyncPtr;
using fuchsia::hardware::power::statecontrol::SystemPowerState;
namespace chromecast {
// RebootShlib implementation:
AdminSyncPtr& GetAdminSyncPtr() {
static base::NoDestructor<AdminSyncPtr> g_admin;
return *g_admin;
}
// static
void RebootShlib::Initialize(const std::vector<std::string>& argv) {}
void RebootShlib::Initialize(const std::vector<std::string>& argv) {
base::fuchsia::ServiceDirectoryClient::ForCurrentProcess()->ConnectToService(
GetAdminSyncPtr().NewRequest());
}
// static
void RebootShlib::Finalize() {}
// static
bool RebootShlib::IsSupported() {
return false;
return true;
}
// static
// Chromecast devices support all RebootSources
bool RebootShlib::IsRebootSourceSupported(
RebootShlib::RebootSource /* reboot_source */) {
return false;
return true;
}
// static
// Chromecast devices support all RebootSources
bool RebootShlib::RebootNow(RebootSource /* reboot_source */) {
// TODO(b/140491587): Implement reboot on Fuchsia.
return false;
bool RebootShlib::RebootNow(RebootSource reboot_source) {
Admin_Suspend_Result out_result;
zx_status_t status =
GetAdminSyncPtr()->Suspend(SystemPowerState::REBOOT, &out_result);
ZX_CHECK(status == ZX_OK, status) << "Failed to suspend device";
return !out_result.is_err();
}
// static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment