Add opt-in physical USB device enrollment and remembered choices in 0.2.7
This commit is contained in:
1 parent
dc29a20a41
commit
208d37b7d8
20 files changed
+515
-18
No files matched your search
@@ -67,6 +67,15 @@ enum Agents {
|
||||
enum Devices {
|
||||
/// Discover devices already known to the Agent host ADB server
|
||||
Discover,
|
||||
/// Enable or disable automatic registration of authorized physical USB phones
|
||||
AutoUsb {
|
||||
#[arg(value_parser=["on","off"])]
|
||||
mode: String,
|
||||
},
|
||||
/// Allow a previously removed USB phone to be registered again
|
||||
Unignore {
|
||||
serial: String,
|
||||
},
|
||||
List,
|
||||
Add {
|
||||
#[arg(long)]
|
||||
@@ -190,6 +199,9 @@ async fn main() -> Result<()> {
|
||||
allow_insecure: args.network.allow_insecure,
|
||||
adb_server: "127.0.0.1:5037".into(),
|
||||
devices: vec![],
|
||||
auto_register_usb: false,
|
||||
ignored_usb_serials: vec![],
|
||||
usb_device_ids: Default::default(),
|
||||
};
|
||||
cfg.validate()?;
|
||||
let source = args
|
||||
@@ -327,6 +339,26 @@ async fn main() -> Result<()> {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
Devices::AutoUsb { mode } => {
|
||||
let mut config: AgentConfig =
|
||||
serde_json::from_value(invoke(&args, &Request::ConfigGet).await?.value()?)?;
|
||||
let expected_config = Some(config.clone());
|
||||
config.auto_register_usb = mode == "on";
|
||||
Request::ConfigSet {
|
||||
config,
|
||||
expected_config,
|
||||
}
|
||||
}
|
||||
Devices::Unignore { serial } => {
|
||||
let mut config: AgentConfig =
|
||||
serde_json::from_value(invoke(&args, &Request::ConfigGet).await?.value()?)?;
|
||||
let expected_config = Some(config.clone());
|
||||
config.ignored_usb_serials.retain(|s| s != &serial);
|
||||
Request::ConfigSet {
|
||||
config,
|
||||
expected_config,
|
||||
}
|
||||
}
|
||||
Devices::Remove { id } => Request::DeviceRemove { id },
|
||||
Devices::Enable { id } => Request::DeviceEnable { id, enabled: true },
|
||||
Devices::Disable { id } => Request::DeviceEnable { id, enabled: false },
|
||||
@@ -338,6 +370,7 @@ async fn main() -> Result<()> {
|
||||
command: Config::Set { ref file },
|
||||
} => Request::ConfigSet {
|
||||
config: AgentConfig::load(file)?,
|
||||
expected_config: None,
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user