mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-30 09:29:58 -07:00
installer: add pinephone and pinephonepro support
This commit is contained in:
committed by
Cooper Quintin
parent
d3bd8d9dfc
commit
8583064e46
@@ -4,12 +4,12 @@ use std::time::Duration;
|
||||
|
||||
use adb_client::{ADBDeviceExt, ADBUSBDevice, RustADBError};
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use nusb::Interface;
|
||||
use nusb::transfer::{Control, ControlType, Recipient, RequestBuffer};
|
||||
use nusb::{Device, Interface};
|
||||
use sha2::{Digest, Sha256};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::util::echo;
|
||||
use crate::util::{echo, open_usb_device};
|
||||
use crate::{CONFIG_TOML, RAYHUNTER_DAEMON_INIT};
|
||||
|
||||
pub const ORBIC_NOT_FOUND: &str = r#"No Orbic device found.
|
||||
@@ -138,7 +138,8 @@ async fn setup_rayhunter(mut adb_device: ADBUSBDevice) -> Result<ADBUSBDevice> {
|
||||
get_adb().await
|
||||
}
|
||||
|
||||
async fn test_rayhunter(adb_device: &mut ADBUSBDevice) -> Result<()> {
|
||||
/// Test rayhunter on the device over adb without forwarding.
|
||||
pub async fn test_rayhunter(adb_device: &mut ADBUSBDevice) -> Result<()> {
|
||||
const MAX_FAILURES: u32 = 10;
|
||||
let mut failures = 0;
|
||||
while failures < MAX_FAILURES {
|
||||
@@ -474,22 +475,3 @@ pub fn open_orbic() -> Result<Option<Interface>> {
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// General function to open a USB device
|
||||
fn open_usb_device(vid: u16, pid: u16) -> Result<Option<Device>> {
|
||||
let devices = match nusb::list_devices() {
|
||||
Ok(d) => d,
|
||||
Err(_) => return Ok(None),
|
||||
};
|
||||
|
||||
for device in devices {
|
||||
if device.vendor_id() == vid && device.product_id() == pid {
|
||||
match device.open() {
|
||||
Ok(d) => return Ok(Some(d)),
|
||||
Err(e) => bail!("device found but failed to open: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user