Skip to content

Commit

Permalink
Connect keymint.mojom interfaces to ArcBridge
Browse files Browse the repository at this point in the history
Now ash should allow the two sides to connect, although we do not have
the code to actually connect yet.

Bug: b:247941366
Test: autoninja -C out/Default/ ash_components_unittests &&
./out/Default/bin/run_ash_components_unittests
--gtest_filter='*ArcBridgeHostImplTest*'

Change-Id: I4a17024eb4a18bf44deb2aa27f8284cbb04fddc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4121405
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Yury Khmel <khmel@chromium.org>
Reviewed-by: Muhammad Hasan Khan <mhasank@chromium.org>
Commit-Queue: Yao Li <yaohuali@google.com>
Cr-Commit-Position: refs/heads/main@{#1098040}
  • Loading branch information
yaoli-us authored and Chromium LUCI CQ committed Jan 27, 2023
1 parent cc71781 commit afb4042
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ash/components/arc/mojom/arc_bridge.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import "ash/components/arc/mojom/input_method_manager.mojom";
import "ash/components/arc/mojom/intent_helper.mojom";
import "ash/components/arc/mojom/keyboard_shortcut.mojom";
import "ash/components/arc/mojom/keymaster.mojom";
import "ash/components/arc/mojom/keymint.mojom";
import "ash/components/arc/mojom/kiosk.mojom";
import "ash/components/arc/mojom/lock_screen.mojom";
import "ash/components/arc/mojom/media_session.mojom";
Expand Down Expand Up @@ -62,9 +63,9 @@ import "ash/components/arc/mojom/wake_lock.mojom";
import "ash/components/arc/mojom/wallpaper.mojom";
import "ash/components/arc/mojom/webapk.mojom";

// Next MinVersion: 63
// Next MinVersion: 64
// Deprecated method IDs: 101, 105, 121, 132, 136, 153, 154, 160
// Next method ID: 168
// Next method ID: 169
interface ArcBridgeHost {
// Keep the entries alphabetical. In order to do so without breaking
// compatibility with the ARC instance, explicitly assign each interface a
Expand Down Expand Up @@ -165,6 +166,10 @@ interface ArcBridgeHost {
[MinVersion=47] OnKeymasterInstanceReady@152(
pending_remote<KeymasterInstance> instance_remote);

// Notifies Chrome that the KeyMintInstance interface is ready.
[MinVersion=63] OnKeyMintInstanceReady@168(
pending_remote<keymint.KeyMintInstance> instance_remote);

// Notifies Chrome that the KioskInstance interface is ready.
[MinVersion=20] OnKioskInstanceReady@126(
pending_remote<KioskInstance> instance_remote);
Expand Down
6 changes: 6 additions & 0 deletions ash/components/arc/session/arc_bridge_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ash/components/arc/mojom/intent_helper.mojom.h"
#include "ash/components/arc/mojom/keyboard_shortcut.mojom.h"
#include "ash/components/arc/mojom/keymaster.mojom.h"
#include "ash/components/arc/mojom/keymint.mojom.h"
#include "ash/components/arc/mojom/kiosk.mojom.h"
#include "ash/components/arc/mojom/lock_screen.mojom.h"
#include "ash/components/arc/mojom/media_session.mojom.h"
Expand Down Expand Up @@ -232,6 +233,11 @@ void ArcBridgeHostImpl::OnKeymasterInstanceReady(
std::move(keymaster_remote));
}

void ArcBridgeHostImpl::OnKeyMintInstanceReady(
mojo::PendingRemote<mojom::keymint::KeyMintInstance> keymint_remote) {
OnInstanceReady(arc_bridge_service_->keymint(), std::move(keymint_remote));
}

void ArcBridgeHostImpl::OnKioskInstanceReady(
mojo::PendingRemote<mojom::KioskInstance> kiosk_remote) {
OnInstanceReady(arc_bridge_service_->kiosk(), std::move(kiosk_remote));
Expand Down
3 changes: 3 additions & 0 deletions ash/components/arc/session/arc_bridge_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
keyboard_shortcut_remote) override;
void OnKeymasterInstanceReady(
mojo::PendingRemote<mojom::KeymasterInstance> keymaster_remote) override;
void OnKeyMintInstanceReady(
mojo::PendingRemote<mojom::keymint::KeyMintInstance> keymint_remote)
override;
void OnKioskInstanceReady(
mojo::PendingRemote<mojom::KioskInstance> kiosk_remote) override;
void OnLockScreenInstanceReady(mojo::PendingRemote<mojom::LockScreenInstance>
Expand Down
15 changes: 15 additions & 0 deletions ash/components/arc/session/arc_bridge_host_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ TEST_F(ArcBridgeHostImplTest, TestOnInstanceReady) {
EXPECT_EQ(count_before + 1, count_after); \
}

#define MAKE_INSTANCE_READY_WITH_NAMESPACE(name_space, name) \
ScopedPendingReceiver<mojom::name_space::name##Instance> \
pending_receiver_##name(impl); \
{ \
SCOPED_TRACE("mojom::" #name_space "::" #name "Instance"); \
mojo::PendingRemote<mojom::name_space::name##Instance> remote = \
pending_receiver_##name.get().InitWithNewPipeAndPassRemote(); \
const size_t count_before = impl->GetNumMojoChannelsForTesting(); \
proxy->On##name##InstanceReady(std::move(remote)); \
base::RunLoop().RunUntilIdle(); \
const size_t count_after = impl->GetNumMojoChannelsForTesting(); \
EXPECT_EQ(count_before + 1, count_after); \
}

MAKE_INSTANCE_READY(AccessibilityHelper);
MAKE_INSTANCE_READY(AdbdMonitor);
MAKE_INSTANCE_READY(App);
Expand All @@ -130,6 +144,7 @@ TEST_F(ArcBridgeHostImplTest, TestOnInstanceReady) {
MAKE_INSTANCE_READY(InputMethodManager);
MAKE_INSTANCE_READY(IntentHelper);
MAKE_INSTANCE_READY(Keymaster);
MAKE_INSTANCE_READY_WITH_NAMESPACE(keymint, KeyMint);
MAKE_INSTANCE_READY(Kiosk);
MAKE_INSTANCE_READY(LockScreen);
MAKE_INSTANCE_READY(MediaSession);
Expand Down
1 change: 1 addition & 0 deletions ash/components/arc/session/arc_bridge_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ash/components/arc/mojom/intent_helper.mojom.h"
#include "ash/components/arc/mojom/keyboard_shortcut.mojom.h"
#include "ash/components/arc/mojom/keymaster.mojom.h"
#include "ash/components/arc/mojom/keymint.mojom.h"
#include "ash/components/arc/mojom/kiosk.mojom.h"
#include "ash/components/arc/mojom/lock_screen.mojom.h"
#include "ash/components/arc/mojom/media_session.mojom.h"
Expand Down
13 changes: 13 additions & 0 deletions ash/components/arc/session/arc_bridge_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class WakeLockInstance;
class WallpaperHost;
class WallpaperInstance;
class WebApkInstance;

namespace keymint {
class KeyMintHost;
class KeyMintInstance;
} // namespace keymint

} // namespace mojom

// Holds Mojo channels which proxy to ARC side implementation. The actual
Expand Down Expand Up @@ -236,6 +242,11 @@ class ArcBridgeService {
keymaster() {
return &keymaster_;
}
ConnectionHolder<mojom::keymint::KeyMintInstance,
mojom::keymint::KeyMintHost>*
keymint() {
return &keymint_;
}
ConnectionHolder<mojom::KioskInstance, mojom::KioskHost>* kiosk() {
return &kiosk_;
}
Expand Down Expand Up @@ -365,6 +376,8 @@ class ArcBridgeService {
ConnectionHolder<mojom::KeyboardShortcutInstance, mojom::KeyboardShortcutHost>
keyboard_shortcut_;
ConnectionHolder<mojom::KeymasterInstance, mojom::KeymasterHost> keymaster_;
ConnectionHolder<mojom::keymint::KeyMintInstance, mojom::keymint::KeyMintHost>
keymint_;
ConnectionHolder<mojom::KioskInstance, mojom::KioskHost> kiosk_;
ConnectionHolder<mojom::LockScreenInstance> lock_screen_;
ConnectionHolder<mojom::MediaSessionInstance> media_session_;
Expand Down
4 changes: 4 additions & 0 deletions ash/components/arc/test/fake_arc_bridge_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ash/components/arc/mojom/intent_helper.mojom.h"
#include "ash/components/arc/mojom/keyboard_shortcut.mojom.h"
#include "ash/components/arc/mojom/keymaster.mojom.h"
#include "ash/components/arc/mojom/keymint.mojom.h"
#include "ash/components/arc/mojom/kiosk.mojom.h"
#include "ash/components/arc/mojom/lock_screen.mojom.h"
#include "ash/components/arc/mojom/media_session.mojom.h"
Expand Down Expand Up @@ -146,6 +147,9 @@ void FakeArcBridgeHost::OnKeyboardShortcutInstanceReady(
void FakeArcBridgeHost::OnKeymasterInstanceReady(
mojo::PendingRemote<mojom::KeymasterInstance> keymaster_remote) {}

void FakeArcBridgeHost::OnKeyMintInstanceReady(
mojo::PendingRemote<mojom::keymint::KeyMintInstance> keymint_remote) {}

void FakeArcBridgeHost::OnKioskInstanceReady(
mojo::PendingRemote<mojom::KioskInstance> kiosk_remote) {}

Expand Down
3 changes: 3 additions & 0 deletions ash/components/arc/test/fake_arc_bridge_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class FakeArcBridgeHost : public mojom::ArcBridgeHost {
keyboard_shortcut_remote) override;
void OnKeymasterInstanceReady(
mojo::PendingRemote<mojom::KeymasterInstance> keymaster_remote) override;
void OnKeyMintInstanceReady(
mojo::PendingRemote<mojom::keymint::KeyMintInstance> keymint_remote)
override;
void OnKioskInstanceReady(
mojo::PendingRemote<mojom::KioskInstance> kiosk_remote) override;
void OnLockScreenInstanceReady(mojo::PendingRemote<mojom::LockScreenInstance>
Expand Down

0 comments on commit afb4042

Please sign in to comment.