Skip to content

Commit b16bead

Browse files
Merge pull request #98 from FrozenAlex/fix
Specify application installer package for Pico devices
2 parents 145f347 + dbd43b4 commit b16bead

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

mbf-agent/src/patching.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,25 @@ fn reinstall_modded_app(
198198
.output()
199199
.context("Uninstalling vanilla APK")?;
200200

201-
Command::new("pm")
202-
.args(["install", &temp_apk_path.to_string_lossy()])
203-
.output()
204-
.context("Installing modded APK")?;
201+
let is_pico = get_android_device_manufacturer()
202+
.map(|v| v.to_lowercase().contains("pico"))
203+
.unwrap_or(false);
204+
205+
if is_pico {
206+
Command::new("pm")
207+
.args([
208+
"install",
209+
"-i", "com.picovr.store", // needed to display game icon in the app launcher
210+
&temp_apk_path.to_string_lossy()
211+
])
212+
.output()
213+
.context("Installing modded APK")?;
214+
} else {
215+
Command::new("pm")
216+
.args(["install", &temp_apk_path.to_string_lossy()])
217+
.output()
218+
.context("Installing modded APK")?;
219+
}
205220

206221
info!("Granting external storage permission");
207222
Command::new("appops")
@@ -490,4 +505,13 @@ fn get_android_sdk_version() -> Result<i32> {
490505
let sdk_version_str = String::from_utf8_lossy(&output.stdout).trim().to_string();
491506
let sdk_version: i32 = sdk_version_str.parse().context("Parsing Android SDK version number")?;
492507
Ok(sdk_version)
508+
}
509+
510+
fn get_android_device_manufacturer() -> Result<String> {
511+
let output = Command::new("getprop")
512+
.arg("ro.product.manufacturer")
513+
.output().context("Getting Android device manufacturer")?;
514+
515+
let manufacturer = String::from_utf8_lossy(&output.stdout).trim().to_string();
516+
Ok(manufacturer)
493517
}

0 commit comments

Comments
 (0)