apkdmverity: build for Android.bp
... and some parts of the source code were revised to satisfy the
stricter lint checks for Android.
Bug: 189785765
Test: cargo test
Test: m apkdmverity
Change-Id: Ic3d80922396fb8e7cba29b092d6f74d17e936f7a
diff --git a/apkverity/src/apksigv4.rs b/apkverity/src/apksigv4.rs
index f1ee0a4..7d8f318 100644
--- a/apkverity/src/apksigv4.rs
+++ b/apkverity/src/apksigv4.rs
@@ -57,7 +57,7 @@
impl Version {
fn from(val: u32) -> Result<Version> {
- Self::from_u32(val).ok_or(anyhow!("{} is an unsupported version", val))
+ Self::from_u32(val).ok_or_else(|| anyhow!("{} is an unsupported version", val))
}
}
@@ -69,7 +69,7 @@
impl HashAlgorithm {
fn from(val: u32) -> Result<HashAlgorithm> {
- Self::from_u32(val).ok_or(anyhow!("{} is an unsupported hash algorithm", val))
+ Self::from_u32(val).ok_or_else(|| anyhow!("{} is an unsupported hash algorithm", val))
}
}
@@ -157,7 +157,7 @@
use std::io::Cursor;
fn hexstring_from(s: &[u8]) -> String {
- s.iter().map(|byte| format!("{:02x}", byte)).reduce(|i, j| i + &j).unwrap_or(String::new())
+ s.iter().map(|byte| format!("{:02x}", byte)).reduce(|i, j| i + &j).unwrap_or_default()
}
#[test]