blob: 83041def170591515190cbb89ded19076e64998e [file] [log] [blame]
Jakub Pawlowski72c8dcc2019-09-06 16:33:21 +02001/******************************************************************************
2 *
3 * Copyright 2019 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19#pragma once
20
Jakub Pawlowskia1f13fc2019-10-24 20:12:35 +020021#include "hci/address_with_type.h"
Jakub Pawlowski72c8dcc2019-09-06 16:33:21 +020022
23// Through this interface we talk to the user, asking for confirmations/acceptance.
24class UI {
25 public:
26 virtual ~UI(){};
27
28 /* Remote device tries to initiate pairing, ask user to confirm */
Jakub Pawlowskia1f13fc2019-10-24 20:12:35 +020029 virtual void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& address, std::string& name) = 0;
Jakub Pawlowski72c8dcc2019-09-06 16:33:21 +020030
31 /* Remove the pairing prompt from DisplayPairingPrompt, i.e. remote device disconnected, or some application requested
32 * bond with this device */
Jakub Pawlowskia1f13fc2019-10-24 20:12:35 +020033 virtual void CancelPairingPrompt(const bluetooth::hci::AddressWithType& address) = 0;
Jakub Pawlowski72c8dcc2019-09-06 16:33:21 +020034
35 /* Display value for Comprision */
36 virtual void DisplayConfirmValue(uint32_t numeric_value) = 0;
37
38 /* Display a dialog box that will let user enter the Passkey */
39 virtual void DisplayEnterPasskeyDialog() = 0;
40
41 /* Present the passkey value to the user */
42 virtual void DisplayPasskey(uint32_t passkey) = 0;
43};
44
45/* Through this interface, UI provides us with user choices. */
46class UICallbacks {
47 public:
48 virtual ~UICallbacks() = 0;
49
50 /* User accepted pairing prompt */
51 virtual void OnPairingPromptAccepted(const bluetooth::hci::Address& address) = 0;
52
53 /* User confirmed that displayed value matches the value on the other device */
54 virtual void OnConfirmYesNo(const bluetooth::hci::Address& address, bool conformed) = 0;
55
56 /* User typed the value displayed on the other device. This is either Passkey or the Confirm value */
57 virtual void OnPasskeyEntry(const bluetooth::hci::Address& address, uint32_t passkey) = 0;
58};