add platform list of platform api

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-04-22 10:40:24 +02:00
parent 3cc02a3292
commit 1f2de8b60d
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
15 changed files with 654199 additions and 11 deletions

View file

@ -0,0 +1,9 @@
[package]
name = "androscalpel_platform_api_list"
version = "0.1.0"
edition = "2024"
[dependencies]
[features]
sdk34 = []

View file

@ -0,0 +1,5 @@
# Android Platform API
List of android platform API (API that are either in the android SDK or hidden API).
The list is extracted from the default android emulator the respective SDKs.

View file

@ -0,0 +1,20 @@
pub mod sdk34;
pub use sdk34::*;
// TODO: automate addign a new SDK
// TODO: different version with different features
/// Test if the class is part of the platform classes.
pub fn is_platform_class(smali: &str) -> bool {
is_sdk34_platform_class(smali)
}
/// Test if the field is part of the platform classes.
pub fn is_platform_field(smali: &str) -> bool {
is_sdk34_platform_field(smali)
}
/// Test if the method is part of the platform classes.
pub fn is_platform_method(smali: &str) -> bool {
is_sdk34_platform_method(smali)
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,60 @@
use std::collections::HashSet;
use std::sync::LazyLock;
pub static PLATFORM_CLASSES_SDK34: LazyLock<HashSet<&'static str>> =
LazyLock::new(|| include_str!("classes.txt").lines().collect());
pub static PLATFORM_FIELDS_SDK34: LazyLock<HashSet<&'static str>> =
LazyLock::new(|| include_str!("fields.txt").lines().collect());
pub static PLATFORM_METHODS_SDK34: LazyLock<HashSet<&'static str>> =
LazyLock::new(|| include_str!("methods.txt").lines().collect());
/// Test if the class is part of the platform classes of the SDK 34.
pub fn is_sdk34_platform_class(smali: &str) -> bool {
PLATFORM_CLASSES_SDK34.contains(smali)
}
/// Test if the field is part of the platform classes of the SDK 34.
pub fn is_sdk34_platform_field(smali: &str) -> bool {
PLATFORM_FIELDS_SDK34.contains(smali)
}
/// Test if the method is part of the platform classes of the SDK 34.
pub fn is_sdk34_platform_method(smali: &str) -> bool {
PLATFORM_METHODS_SDK34.contains(smali)
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_classes_sdk34_set() {
assert!(PLATFORM_CLASSES_SDK34
.contains("Landroid/accessibilityservice/AccessibilityGestureEvent;"));
let s: String = "Landroid/accessibilityservice/AccessibilityInputMethodSession;".into();
assert!(PLATFORM_CLASSES_SDK34.contains(s.as_str()));
}
#[test]
fn test_fields_sdk34_set() {
assert!(PLATFORM_FIELDS_SDK34.contains(
"Landroid/accessibilityservice/AccessibilityButtonController$$\
ExternalSyntheticLambda1;->f$0:Landroid/accessibilityservice/\
AccessibilityButtonController;"
));
let s: String = "Landroid/accessibilityservice/AccessibilityButtonController;->mLock:Ljava/lang/Object;".into();
assert!(PLATFORM_FIELDS_SDK34.contains(s.as_str()));
}
#[test]
fn test_methods_sdk34_set() {
assert!(PLATFORM_METHODS_SDK34
.contains("Landroid/accessibilityservice/AccessibilityButtonController$$ExternalSyntheticLambda1;->run()V"));
let s: String = "Landroid/accessibilityservice/AccessibilityButtonController;->\
$r8$lambda$h5Na0_pkg6ffhlKQPqxrTXannSI(\
Landroid/accessibilityservice/AccessibilityButtonController;\
Landroid/accessibilityservice/AccessibilityButtonController$AccessibilityButtonCallback;\
)V".into();
assert!(PLATFORM_METHODS_SDK34.contains(s.as_str()));
}
}