Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc3c72a3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tool to validate sdk artifacts" into main

parents 45917c2e 7dc158dd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
/Cargo.lock
/target
+21 −0
Original line number Diff line number Diff line
package {
    default_applicable_licenses: ["Android-Apache-2.0"],
    default_team: "trendy_team_updatable_sdk_apis",
}

rust_binary_host {
    name: "sdk-artifact-verifier",
    edition: "2021",
    clippy_lints: "android",
    lints: "android",
    srcs: [
        "src/main.rs",
    ],
    rustlibs: [
        "libanyhow",
        "libclap",
        "libitertools",
        "libserde",
        "libserde_xml_rs",
    ],
}
+11 −0
Original line number Diff line number Diff line
[package]
name = "sdk-artifact-verifier"
version = "0.1.0"
edition = "2024"

[dependencies]
anyhow = "1.0.98"
clap = { version = "4.5.38", features = ["derive"] }
itertools = "0.14.0"
serde = { version = "1.0.219" , features = ["derive"] }
serde-xml-rs = "0.6.0"
+118 −0
Original line number Diff line number Diff line
android/adservices/customaudience/ScheduleCustomAudienceUpdateRequest$Builder#<init>(Landroid/net/Uri;Ljava/time/Duration;Ljava/util/List;)V 36
android/app/ActivityManager$RunningAppProcessInfo#IMPORTANCE_TOP_SLEEPING_PRE_28 28
android/app/Service#STOP_FOREGROUND_LEGACY 33
android/content/Context#sendStickyBroadcast(Landroid/content/Intent;Landroid/os/Bundle;)V 31
android/content/pm/Checksum#TYPE_WHOLE_MD5 31
android/content/pm/Checksum#TYPE_WHOLE_SHA1 31
android/content/pm/Checksum#TYPE_WHOLE_SHA256 31
android/content/pm/Checksum#TYPE_WHOLE_SHA512 31
android/content/pm/PackageInstaller$Session#setChecksums(Ljava/lang/String;Ljava/util/List;[B)V 31
android/hardware/Camera#CAMERA_ERROR_EVICTED 23
android/hardware/Sensor#STRING_TYPE_ORIENTATION 20
android/hardware/Sensor#STRING_TYPE_TEMPERATURE 20
android/location/GpsStatus#create(Landroid/location/GnssStatus;I)Landroid/location/GpsStatus; 30
android/media/ThumbnailUtils#createAudioThumbnail(Ljava/lang/String;I)Landroid/graphics/Bitmap; 29
android/media/ThumbnailUtils#createImageThumbnail(Ljava/lang/String;I)Landroid/graphics/Bitmap; 29
android/net/NetworkInfo#<init>(IILjava/lang/String;Ljava/lang/String;)V 30
android/net/NetworkInfo#setDetailedState(Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;Ljava/lang/String;)V 30
android/net/wifi/WifiConfiguration#RANDOMIZATION_AUTO 33
android/net/wifi/WifiConfiguration#RANDOMIZATION_NONE 33
android/net/wifi/WifiConfiguration#RANDOMIZATION_NON_PERSISTENT 33
android/net/wifi/WifiConfiguration#RANDOMIZATION_PERSISTENT 33
android/net/wifi/WifiConfiguration#SECURITY_TYPE_DPP 33
android/net/wifi/WifiConfiguration#SECURITY_TYPE_EAP 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_EAP_SUITE_B 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_EAP_WPA3_ENTERPRISE 31
android/net/wifi/WifiConfiguration#SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT 31
android/net/wifi/WifiConfiguration#SECURITY_TYPE_OPEN 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_OWE 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_PSK 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_SAE 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_WAPI_CERT 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_WAPI_PSK 30
android/net/wifi/WifiConfiguration#SECURITY_TYPE_WEP 30
android/net/wifi/WifiConfiguration#<init>(Landroid/net/wifi/WifiConfiguration;)V 30
android/net/wifi/WifiConfiguration#getKey()Ljava/lang/String; 30
android/net/wifi/WifiConfiguration#getMacRandomizationSetting()I 33
android/net/wifi/WifiConfiguration#isDppConfigurator()Z 33
android/net/wifi/WifiConfiguration#setIpConfiguration(Landroid/net/IpConfiguration;)V 33
android/net/wifi/WifiConfiguration#setMacRandomizationSetting(I)V 33
android/net/wifi/WifiConfiguration#setSecurityParams(I)V 30
android/net/wifi/WifiConfiguration$AuthAlgorithm#SAE 30
android/net/wifi/WifiConfiguration$GroupCipher#GCMP_128 31
android/net/wifi/WifiConfiguration$GroupCipher#SMS4 30
android/net/wifi/WifiConfiguration$GroupMgmtCipher 29
android/net/wifi/WifiConfiguration$KeyMgmt#DPP 34
android/net/wifi/WifiConfiguration$KeyMgmt#FILS_SHA256 34
android/net/wifi/WifiConfiguration$KeyMgmt#FILS_SHA384 34
android/net/wifi/WifiConfiguration$KeyMgmt#FT_EAP 34
android/net/wifi/WifiConfiguration$KeyMgmt#FT_PSK 34
android/net/wifi/WifiConfiguration$KeyMgmt#OSEN 34
android/net/wifi/WifiConfiguration$KeyMgmt#WAPI_CERT 34
android/net/wifi/WifiConfiguration$KeyMgmt#WAPI_PSK 34
android/net/wifi/WifiConfiguration$KeyMgmt#WPA2_PSK 34
android/net/wifi/WifiConfiguration$KeyMgmt#WPA_EAP_SHA256 34
android/net/wifi/WifiConfiguration$KeyMgmt#WPA_PSK_SHA256 34
android/net/wifi/WifiConfiguration$PairwiseCipher#GCMP_128 31
android/net/wifi/WifiConfiguration$PairwiseCipher#SMS4 30
android/net/wifi/WifiConfiguration$Protocol#WAPI 30
android/provider/Contacts$PresenceColumns#AVAILABLE 8
android/provider/Contacts$PresenceColumns#AWAY 8
android/provider/Contacts$PresenceColumns#DO_NOT_DISTURB 8
android/provider/Contacts$PresenceColumns#IDLE 8
android/provider/Contacts$PresenceColumns#INVISIBLE 8
android/provider/Contacts$PresenceColumns#OFFLINE 8
android/provider/Contacts$PresenceColumns#PRESENCE_CUSTOM_STATUS 8
android/provider/Contacts$PresenceColumns#PRESENCE_STATUS 8
android/provider/Contacts$PresenceColumns#PRIORITY 8
android/provider/ContactsContract$Presence 5
android/provider/MediaStore$Audio$AlbumColumns#ARTIST_KEY 30
android/provider/MediaStore$Audio$AudioColumns#GENRE_KEY 30
android/provider/MediaStore$Images$Thumbnails#getKindSize(I)Landroid/util/Size; 30
android/provider/MediaStore$Video$Thumbnails#getKindSize(I)Landroid/util/Size; 30
android/security/keystore/KeyProperties#KEY_ALGORITHM_3DES 28
android/service/voice/VoiceInteractionSession$AbortVoiceRequest#getMessage()Ljava/lang/CharSequence; 23
android/service/voice/VoiceInteractionSession$CompleteVoiceRequest#getMessage()Ljava/lang/CharSequence; 23
android/service/voice/VoiceInteractionSession$ConfirmationRequest#getPrompt()Ljava/lang/CharSequence; 23
android/service/voice/VoiceInteractionSession$PickOptionRequest#getPrompt()Ljava/lang/CharSequence; 23
android/test/AndroidTestCase#getTestContext()Landroid/content/Context; 36
android/test/AndroidTestCase#setTestContext(Landroid/content/Context;)V 36
android/test/InstrumentationTestRunner#addTestListener(Ljunit/framework/TestListener;)V 36
android/test/LaunchPerformanceBase 36
android/test/RepetitiveTest 36
android/test/mock/MockAccountManager 36
android/test/mock/MockContentProvider#attachInfoForTesting(Landroid/content/ContentProvider;Landroid/content/Context;Landroid/content/pm/ProviderInfo;)V 36
android/test/mock/MockPackageManager#resolveServiceAsUser(Landroid/content/Intent;II)Landroid/content/pm/ResolveInfo; 36
android/test/mock/MockPackageManager#setInstantAppCookie([B)Z 36
android/test/mock/MockService 36
android/test/suitebuilder/UnitTestSuiteBuilder 36
android/view/accessibility/AccessibilityNodeInfo#removeAction(I)V 21
android/webkit/WebIconDatabase#<init>()V 22
android/widget/AbsoluteLayout#<init>(Landroid/content/Context;Landroid/util/AttributeSet;II)V 21
android/widget/AnalogClock#getDialTintBlendMode()Landroid/graphics/BlendMode; 31
android/widget/AnalogClock#getDialTintList()Landroid/content/res/ColorStateList; 31
android/widget/AnalogClock#getHourHandTintBlendMode()Landroid/graphics/BlendMode; 31
android/widget/AnalogClock#getHourHandTintList()Landroid/content/res/ColorStateList; 31
android/widget/AnalogClock#getMinuteHandTintBlendMode()Landroid/graphics/BlendMode; 31
android/widget/AnalogClock#getMinuteHandTintList()Landroid/content/res/ColorStateList; 31
android/widget/AnalogClock#getSecondHandTintBlendMode()Landroid/graphics/BlendMode; 31
android/widget/AnalogClock#getSecondHandTintList()Landroid/content/res/ColorStateList; 31
android/widget/AnalogClock#getTimeZone()Ljava/lang/String; 31
android/widget/AnalogClock#setDial(Landroid/graphics/drawable/Icon;)V 31
android/widget/AnalogClock#setDialTintBlendMode(Landroid/graphics/BlendMode;)V 31
android/widget/AnalogClock#setDialTintList(Landroid/content/res/ColorStateList;)V 31
android/widget/AnalogClock#setHourHand(Landroid/graphics/drawable/Icon;)V 31
android/widget/AnalogClock#setHourHandTintBlendMode(Landroid/graphics/BlendMode;)V 31
android/widget/AnalogClock#setHourHandTintList(Landroid/content/res/ColorStateList;)V 31
android/widget/AnalogClock#setMinuteHand(Landroid/graphics/drawable/Icon;)V 31
android/widget/AnalogClock#setMinuteHandTintBlendMode(Landroid/graphics/BlendMode;)V 31
android/widget/AnalogClock#setMinuteHandTintList(Landroid/content/res/ColorStateList;)V 31
android/widget/AnalogClock#setSecondHand(Landroid/graphics/drawable/Icon;)V 31
android/widget/AnalogClock#setSecondHandTintBlendMode(Landroid/graphics/BlendMode;)V 31
android/widget/AnalogClock#setSecondHandTintList(Landroid/content/res/ColorStateList;)V 31
android/widget/AnalogClock#setTimeZone(Ljava/lang/String;)V 31
android/widget/Gallery#<init>(Landroid/content/Context;Landroid/util/AttributeSet;II)V 21
android/widget/SlidingDrawer#<init>(Landroid/content/Context;Landroid/util/AttributeSet;II)V 21
android/widget/TwoLineListItem#<init>(Landroid/content/Context;Landroid/util/AttributeSet;II)V 21
java/io/LineNumberInputStream 1
java/io/StringBufferInputStream 1
+135 −0
Original line number Diff line number Diff line
use anyhow::Result;
use serde::{Deserialize, Deserializer};
use serde_xml_rs::{from_reader, from_str};
use std::collections::BTreeMap;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Api {
    #[serde(rename = "version")]
    pub version: String,
    #[serde(rename = "sdk")]
    pub sdks: Vec<Sdk>,
    #[serde(rename = "class", deserialize_with = "to_map_using_name")]
    pub classes: BTreeMap<String, Class>,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Class {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "since")]
    pub since: String,
    #[serde(rename = "deprecated")]
    pub deprecated: Option<String>,
    #[serde(rename = "sdks")]
    pub sdks: Option<String>,
    #[serde(rename = "module")]
    pub modelue_text: Option<String>,
    #[serde(default)]
    pub extends: Vec<Extends>,
    #[serde(rename = "method", deserialize_with = "to_map_using_name", default)]
    pub methods: BTreeMap<String, Method>,

    #[serde(rename = "field", deserialize_with = "to_map_using_name", default)]
    pub fields: BTreeMap<String, Field>,
    #[serde(default)]
    pub implements: Vec<Implements>,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Method {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "since")]
    pub since: Option<String>,
    #[serde(rename = "deprecated")]
    pub deprecated: Option<String>,
    #[serde(rename = "sdks")]
    pub sdks: Option<String>,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Sdk {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "shortname")]
    pub shortname: String,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "reference")]
    pub reference: String,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Extends {
    #[serde(rename = "name")]
    pub name: String,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Field {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "since")]
    pub since: Option<String>,
    #[serde(rename = "deprecated")]
    pub deprecated: Option<String>,
    #[serde(rename = "sdks")]
    pub sdks: Option<String>,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Implements {
    #[serde(rename = "name")]
    pub name: String,
}

trait Named {
    fn get_name(&self) -> String;
}

macro_rules! impl_Named {
    ($($t:ty),+) => {
        $(impl Named for $t {
            fn get_name(&self) -> String {
                self.name.clone()
            }
        })*
    }
}

impl_Named!(Class, Field, Method);

fn to_map_using_name<'de, D, T>(deserializer: D) -> Result<BTreeMap<String, T>, D::Error>
where
    D: Deserializer<'de>,
    T: Named + Deserialize<'de>,
{
    let as_vec: Vec<T> = Deserialize::deserialize(deserializer)?;
    let as_map = as_vec.into_iter().map(|x| (x.get_name(), x)).collect::<BTreeMap<_, _>>();
    Ok(as_map)
}

/// Load an api file
pub fn load<P: AsRef<Path>>(filename: P) -> Result<Api> {
    let file = File::open(filename)?;
    let file = BufReader::new(file);
    let api: Api = from_reader(file)?;
    Ok(api)
}

#[allow(dead_code)]
pub fn parse_class(xml: &str) -> Result<Class> {
    let class: Class = from_str(xml)?;
    Ok(class)
}
Loading