-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implemented uninstall command
- Loading branch information
Showing
13 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ mod push; | |
mod reboot; | ||
mod shell; | ||
mod stat; | ||
mod uninstall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::{device::adb_message_device::ADBMessageDevice, ADBMessageTransport, Result}; | ||
|
||
impl<T: ADBMessageTransport> ADBMessageDevice<T> { | ||
pub(crate) fn uninstall(&mut self, package_name: &str) -> Result<()> { | ||
self.open_session(format!("exec:cmd package 'uninstall' {}\0", package_name).as_bytes())?; | ||
|
||
let final_status = self.get_transport_mut().read_message()?; | ||
|
||
match final_status.into_payload().as_slice() { | ||
b"Success\n" => { | ||
log::info!("Package {} successfully uninstalled", package_name); | ||
Ok(()) | ||
} | ||
d => Err(crate::RustADBError::ADBRequestFailed(String::from_utf8( | ||
d.to_vec(), | ||
)?)), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ mod send; | |
mod stat; | ||
mod tcpip; | ||
mod transport; | ||
mod uninstall; | ||
mod usb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::io::Read; | ||
|
||
use crate::{models::AdbServerCommand, server_device::ADBServerDevice, Result}; | ||
|
||
impl ADBServerDevice { | ||
/// Uninstall a package from device | ||
pub fn uninstall(&mut self, package_name: &str) -> Result<()> { | ||
let serial: String = self.identifier.clone(); | ||
self.connect()? | ||
.send_adb_request(AdbServerCommand::TransportSerial(serial))?; | ||
|
||
self.transport | ||
.send_adb_request(AdbServerCommand::Uninstall(package_name.to_string()))?; | ||
|
||
let mut data = [0; 1024]; | ||
let read_amount = self.transport.get_raw_connection()?.read(&mut data)?; | ||
|
||
match &data[0..read_amount] { | ||
b"Success\n" => { | ||
log::info!("Package {} successfully uninstalled", package_name); | ||
Ok(()) | ||
} | ||
d => Err(crate::RustADBError::ADBRequestFailed(String::from_utf8( | ||
d.to_vec(), | ||
)?)), | ||
} | ||
} | ||
} |