4 Commits

Author SHA1 Message Date
LIAUD Corentin
d0e0f46571 chore: version v2.1.8 2025-02-27 10:04:00 +01:00
Yohane
727f3a3eb4 Fix:Regex expression parsing usb incorrectly (#94) 2025-02-27 10:02:49 +01:00
Otto Zell
ab77db5cc8 Fix for android clients that do not expect encrypted connections (#93)
* Fix for adb clients that do not want encrypted connections

---------

Co-authored-by: Otto Zell <otto.zell@drivec.se>
Co-authored-by: LIAUD Corentin <corentinliaud26@gmail.com>
2025-02-27 09:54:04 +01:00
cocool97
1255f2b5d6 feat: improve python-build.yml (#92) 2025-02-11 15:26:19 +01:00
5 changed files with 30 additions and 34 deletions

View File

@@ -7,43 +7,28 @@ on:
types: [created]
jobs:
gen-stubs:
name: "build-release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build project
run: cargo run --bin stub_gen
build-python-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Python stubs
run: cargo run --bin stub_gen
- name: Install Python build dependencies
run: pip install maturin==1.8.2
- name: Build Python packages
run: maturin build --sdist --release -m pyadb_client/Cargo.toml
publish-python-packages:
runs-on: ubuntu-latest
needs: [build-python-packages]
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- uses: actions/checkout@v4
- name: Install Python build dependencies
run: pip install maturin==1.8.2
- name: Publish Python packages
if: github.event_name == 'release' && github.event.action == 'created'
run: maturin publish -m pyadb_client/Cargo.toml --non-interactive
env:
MATURIN_PYPI_TOKEN: ${{ secrets.MATURIN_PYPI_TOKEN }}
- name: "Publish GitHub artefacts"
if: github.event_name == 'release' && github.event.action == 'created'
uses: softprops/action-gh-release@v2
with:
files: |

View File

@@ -9,7 +9,7 @@ homepage = "https://github.com/cocool97/adb_client"
keywords = ["adb", "android", "tcp", "usb"]
license = "MIT"
repository = "https://github.com/cocool97/adb_client"
version = "2.1.7"
version = "2.1.8"
# To build locally when working on a new release
[patch.crates-io]

View File

@@ -38,18 +38,26 @@ impl ADBTcpDevice {
self.get_transport_mut().write_message(message)?;
// At this point, we should have received a STLS command indicating that the device wants to upgrade connection with TLS
self.get_transport_mut()
.read_message()
.and_then(|message| message.assert_command(MessageCommand::Stls))?;
let message = self.get_transport_mut().read_message()?;
self.get_transport_mut()
.write_message(ADBTransportMessage::new(MessageCommand::Stls, 1, 0, &[]))?;
// Upgrade TCP connection to TLS
self.get_transport_mut().upgrade_connection()?;
log::debug!("Connection successfully upgraded from TCP to TLS");
// Check if client is requesting a secure connection and upgrade it if necessary
match message.header().command() {
MessageCommand::Stls => {
self.get_transport_mut()
.write_message(ADBTransportMessage::new(MessageCommand::Stls, 1, 0, &[]))?;
self.get_transport_mut().upgrade_connection()?;
log::debug!("Connection successfully upgraded from TCP to TLS");
}
MessageCommand::Cnxn => {
log::debug!("Unencrypted connection established");
}
_ => {
return Err(crate::RustADBError::WrongResponseReceived(
"Expected CNXN or STLS command".to_string(),
message.header().command().to_string(),
));
}
}
Ok(())
}

View File

@@ -6,7 +6,7 @@ use crate::{DeviceState, RustADBError};
use regex::bytes::Regex;
static DEVICES_LONG_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new("^(?P<identifier>\\S+)\\s+(?P<state>\\w+) ((usb:(?P<usb1>.*)|(?P<usb2>\\d-\\d)) )?(product:(?P<product>\\w+) model:(?P<model>\\w+) device:(?P<device>\\w+) )?transport_id:(?P<transport_id>\\d+)$").expect("cannot build devices long regex")
Regex::new(r"^(?P<identifier>\S+)\s+(?P<state>\w+)\s+(usb:(?P<usb1>\S+)|(?P<usb2>\S+))?\s*(product:(?P<product>\w+)\s+model:(?P<model>\w+)\s+device:(?P<device>\w+)\s+)?transport_id:(?P<transport_id>\d+)$").expect("cannot build devices long regex")
});
/// Represents a new device with more informations.

View File

@@ -42,7 +42,10 @@ mod tests {
#[test]
fn test_static_devices_long() {
let inputs = ["7a5158f05122195aa device 1-5 product:gts210vewifixx model:SM_T813 device:gts210vewifi transport_id:4"];
let inputs = ["7a5158f05122195aa device 1-5 product:gts210vewifixx model:SM_T813 device:gts210vewifi transport_id:4",
"n311r05e device usb:0-1.5 product:alioth model:M2012K11AC device:alioth transport_id:58",
"192.168.100.192:5555 device product:alioth model:M2012K11AC device:alioth transport_id:97",
"emulator-5554 device product:sdk_gphone64_arm64 model:sdk_gphone64_arm64 device:emu64a transport_id:101"];
for input in inputs {
DeviceLong::try_from(input.as_bytes().to_vec())
.expect(&format!("cannot parse input: '{input}'"));