platform_system_core/adb/socket_spec.h

36 lines
1.3 KiB
C
Raw Normal View History

/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <string>
#include <tuple>
#include "adb_unique_fd.h"
// Returns true if the argument starts with a plausible socket prefix.
bool is_socket_spec(std::string_view spec);
bool is_local_socket_spec(std::string_view spec);
bool socket_spec_connect(unique_fd* fd, std::string_view address, int* port, std::string* serial,
std::string* error);
int socket_spec_listen(std::string_view spec, std::string* error, int* resolved_tcp_port = nullptr);
bool parse_tcp_socket_spec(std::string_view spec, std::string* hostname, int* port,
std::string* serial, std::string* error);
Enable "localfilesystem" UNIX domain socket for ADB. This patch introduce "service.adb.listen_addrs", a new string type property, while keeping the old properties. The new property added in this patch is used to listen on UNIX domain socket "localfilesystem". "service.adb.listen_addrs" can be used to listen on multiple addresses, such as tcp:5555 and tcp:5556. It is separated by ',' (comma) character. In the process of introducing the new socket type, the method tcp_connect is removed and combined into socket_spec_connect. Without specifying using the new property, adb will try to listen on both tcp and vsock (following the previous implementation). Some examples of the new property value are: - "tcp:5555" - "vsock:5555" - "localfilesystem:/tmp/test" - "tcp:5555,vsock:5555" Bug: 133378083 Test: On master-arc-dev: adb root; setprop service.adb.listen_addrs localfilesystem: <path_to_socket>; adb connect localfilesystem:<path_to_socket>; adb -s localfilesystem:<path_to_socket> shell; inside Chrome OS. Test: On aosp_bluefin: setprop service.adb.listen_addr tcp:5555; adb connect <IP>:5555; adb shell; Test: On aosp_bluefin: setprop service.adb.tcp.port 5555; adb connect <IP>:5555; adb shell; Test: On aosp_bluefin: setprop service.adb.listen_addrs tcp:5555,tcp:6666; adb connect <IP>:5555; adb shell; adb connect <IP>:6666; adb shell; Test: On aosp_bluefin: ./adb_test; Test: On cuttlefish: launch_cvd; adb -s 127.0.0.1:6520 shell; Test: Ran host tests: ./adb_test; ./adb_integration_test_adb; ./adb_integration_test_device; Change-Id: I8289bf0ab3305cf23ce5695ffba46845d58ef6bb
2019-07-19 05:44:39 +02:00
int get_host_socket_spec_port(std::string_view spec, std::string* error);