Android-cuttlefish cvd tool
adb_wifi.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <string>
20
21#include "adb.h"
22#include "adb_known_hosts.pb.h"
23
24void adb_wifi_pair_device(const std::string& host, const std::string& password,
25 std::string& response);
26
27// An accessor to the list of known hosts (known_host). Nothing is cached, every operation
28// hits the disk.
29// TODO: Convert this to a write-through cache.
31 public:
33
34 // For testing, we allow a custom known_host location
35 explicit KnownWifiHostsFile(const std::string& keystore_path) : keystore_path_(keystore_path) {}
36
37 // Location of the known_host file
38 std::string KeyStorePath() const { return keystore_path_; }
39
40 // Add host to the known_host file
41 bool AddKnownHost(const std::string& host);
42
43 // Load known_host file and return true if that host is considered paired.
44 bool IsKnownHost(const std::string& host);
45
46 // Delete known_host file
47 void Clear();
48
49 private:
50 std::string keystore_path_;
51 adb::proto::AdbKnownHosts Load();
52};
53
void adb_wifi_pair_device(const std::string &host, const std::string &password, std::string &response)
Definition: adb_wifi.cpp:178
KnownWifiHostsFile known_wifi_hosts_file
Definition: adb_wifi.cpp:41
Definition: adb_wifi.h:30
void Clear()
Definition: adb_wifi.cpp:125
std::string KeyStorePath() const
Definition: adb_wifi.h:38
KnownWifiHostsFile()
Definition: adb_wifi.cpp:159
std::string keystore_path_
Definition: adb_wifi.h:50
KnownWifiHostsFile(const std::string &keystore_path)
Definition: adb_wifi.h:35
bool AddKnownHost(const std::string &host)
Definition: adb_wifi.cpp:129
bool IsKnownHost(const std::string &host)
Definition: adb_wifi.cpp:162
adb::proto::AdbKnownHosts Load()
Definition: adb_wifi.cpp:100