|
1 | 1 | //! The main structure that represents the `apk` file. |
2 | 2 |
|
| 3 | +use std::collections::HashSet; |
3 | 4 | use std::fs::File; |
4 | 5 | use std::io::{self, BufReader, Read}; |
5 | 6 | use std::path::Path; |
@@ -312,6 +313,20 @@ impl Apk { |
312 | 313 | .get_attribute_value("manifest", "platformBuildVersionName", self.arsc.as_ref()) |
313 | 314 | } |
314 | 315 |
|
| 316 | + /// Retrieves the `compileSdkVersion` from the `<manifest>` element. |
| 317 | + #[inline] |
| 318 | + pub fn get_compile_sdk_version(&self) -> Option<String> { |
| 319 | + self.axml |
| 320 | + .get_attribute_value("manifest", "compileSdkVersion", self.arsc.as_ref()) |
| 321 | + } |
| 322 | + |
| 323 | + /// Retrieves the `compileSdkVersionCodename` from the `<manifest>` element. |
| 324 | + #[inline] |
| 325 | + pub fn get_compile_sdk_version_codename(&self) -> Option<String> { |
| 326 | + self.axml |
| 327 | + .get_attribute_value("manifest", "compileSdkVersionCodename", self.arsc.as_ref()) |
| 328 | + } |
| 329 | + |
315 | 330 | /// Extracts the `android:allowTaskReparenting` attribute from `<application>`. |
316 | 331 | /// |
317 | 332 | /// See: <https://developer.android.com/guide/topics/manifest/application-element#reparent> |
@@ -697,4 +712,22 @@ impl Apk { |
697 | 712 |
|
698 | 713 | Ok(signatures) |
699 | 714 | } |
| 715 | + |
| 716 | + // Information about the native code (.so libraries) of the APK file |
| 717 | + pub fn get_native_codes(&self) -> Vec<String> { |
| 718 | + let mut native_codes_set = HashSet::new(); |
| 719 | + for filename in self.zip.namelist() { |
| 720 | + if filename.starts_with("lib/") && filename.ends_with(".so") { |
| 721 | + let parts: Vec<&str> = filename.split('/').collect(); |
| 722 | + // The structure is usually lib/<abi>/<libname>.so |
| 723 | + if parts.len() == 3 { |
| 724 | + let abi: String = parts[1].to_string(); |
| 725 | + native_codes_set.insert(abi); |
| 726 | + } |
| 727 | + } |
| 728 | + } |
| 729 | + let mut native_codes: Vec<String> = native_codes_set.into_iter().collect(); |
| 730 | + native_codes.sort(); |
| 731 | + native_codes |
| 732 | + } |
700 | 733 | } |
0 commit comments