android_tools_rs/bundletool/
extract_apks.rs

1use crate::error::*;
2use std::path::{Path, PathBuf};
3use std::process::Command;
4
5/// To measure the estimated download sizes of APKs in an APK set as they would be served
6/// compressed over-the-wire, use the get-size total command: ```
7/// bundletool get-size total --apks=/MyApp/my_app.apks ```
8/// You can modify the behavior of the get-size total command using the following flags:
9pub struct ExtractApks {
10    apks: PathBuf,
11    device_spec: PathBuf,
12    output_dir: PathBuf,
13}
14
15impl ExtractApks {
16    /// Specifies the path to the device spec file (from get-device-spec or constructed
17    /// manually) to use for matching.
18    pub fn new(apks: &Path, device_spec: &Path, output_dir: &Path) -> Self {
19        Self {
20            apks: apks.to_owned(),
21            device_spec: device_spec.to_owned(),
22            output_dir: output_dir.to_owned(),
23        }
24    }
25
26    pub fn run(&self) -> Result<()> {
27        let mut extract_apks = Command::new("extract-apks");
28        extract_apks.arg("--apks");
29        extract_apks.arg(&self.apks);
30        extract_apks.arg("--device-spec");
31        extract_apks.arg(&self.device_spec);
32        extract_apks.arg("--output-dir");
33        extract_apks.arg(&self.output_dir);
34        extract_apks.output_err(true)?;
35        Ok(())
36    }
37}