Skip to content

Commit

Permalink
Refactor dbus SessionManagerInterface.StartArcInterface
Browse files Browse the repository at this point in the history
Now we use a proto message as parameter for the dbus interface
to start ARC instances.

BUG=b:37989086
TEST=locally build and flash, start ARC

Review-Url: https://codereview.chromium.org/2869163002
Cr-Commit-Position: refs/heads/master@{#475722}
  • Loading branch information
xiaohuic authored and Commit Bot committed May 31, 2017
1 parent 64a9be3 commit 2f57e3f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
9 changes: 9 additions & 0 deletions chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ component("chromeos") {
":authpolicy_proto",
":biod_proto",
":cryptohome_proto",
":login_manager_proto",
":media_perception_proto",
":power_manager_proto",
"//base",
Expand Down Expand Up @@ -749,6 +750,14 @@ proto_library("cryptohome_proto") {
proto_out_dir = "chromeos/dbus/cryptohome"
}

proto_library("login_manager_proto") {
sources = [
"//third_party/cros_system_api/dbus/login_manager/arc.proto",
]

proto_out_dir = "chromeos/dbus/login_manager"
}

proto_library("attestation_proto") {
sources = [
"dbus/proto/attestation.proto",
Expand Down
15 changes: 10 additions & 5 deletions chromeos/dbus/session_manager_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/blocking_method_caller.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/login_manager/arc.pb.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "crypto/sha2.h"
#include "dbus/bus.h"
Expand Down Expand Up @@ -402,16 +403,20 @@ class SessionManagerClientImpl : public SessionManagerClient {
}

void StartArcInstance(const cryptohome::Identification& cryptohome_id,
bool disable_boot_completed_broadcast,
bool enable_vendor_privileged,
bool skip_boot_completed_broadcast,
bool scan_vendor_priv_app,
const StartArcInstanceCallback& callback) override {
dbus::MethodCall method_call(
login_manager::kSessionManagerInterface,
login_manager::kSessionManagerStartArcInstance);
dbus::MessageWriter writer(&method_call);
writer.AppendString(cryptohome_id.id());
writer.AppendBool(disable_boot_completed_broadcast);
writer.AppendBool(enable_vendor_privileged);

login_manager::StartArcInstanceRequest request;
request.set_account_id(cryptohome_id.id());
request.set_skip_boot_completed_broadcast(skip_boot_completed_broadcast);
request.set_scan_vendor_priv_app(scan_vendor_priv_app);
writer.AppendProtoAsArrayOfBytes(request);

session_manager_proxy_->CallMethodWithErrorCallback(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&SessionManagerClientImpl::OnStartArcInstanceSucceeded,
Expand Down
4 changes: 2 additions & 2 deletions chromeos/dbus/session_manager_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
base::Callback<void(StartArcInstanceResult result,
const std::string& container_instance_id)>;
virtual void StartArcInstance(const cryptohome::Identification& cryptohome_id,
bool disable_boot_completed_broadcast,
bool enable_vendor_privileged,
bool skip_boot_completed_broadcast,
bool scan_vendor_priv_app,
const StartArcInstanceCallback& callback) = 0;

// Asynchronously stops the ARC instance. Upon completion, invokes
Expand Down
1 change: 1 addition & 0 deletions components/arc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static_library("arc") {
"//ash/shared:app_types",
"//base",
"//chromeos",
"//chromeos:login_manager_proto",
"//chromeos:power_manager_proto",
"//components/exo",
"//components/google/core/browser",
Expand Down
6 changes: 3 additions & 3 deletions components/arc/arc_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,18 @@ void ArcSessionImpl::OnSocketCreated(
const cryptohome::Identification cryptohome_id(
user_manager->GetPrimaryUser()->GetAccountId());

bool disable_boot_completed_broadcast =
const bool skip_boot_completed_broadcast =
!base::FeatureList::IsEnabled(arc::kBootCompletedBroadcastFeature);

// We only enable /vendor/priv-app when voice interaction is enabled because
// voice interaction service apk would be bundled in this location.
bool enable_vendor_privileged =
const bool scan_vendor_priv_app =
chromeos::switches::IsVoiceInteractionEnabled();

chromeos::SessionManagerClient* session_manager_client =
chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
session_manager_client->StartArcInstance(
cryptohome_id, disable_boot_completed_broadcast, enable_vendor_privileged,
cryptohome_id, skip_boot_completed_broadcast, scan_vendor_priv_app,
base::Bind(&ArcSessionImpl::OnInstanceStarted, weak_factory_.GetWeakPtr(),
base::Passed(&socket_fd)));
}
Expand Down

0 comments on commit 2f57e3f

Please sign in to comment.