Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
1
third-party/vendor/android-properties/.cargo-checksum.json
vendored
Normal file
1
third-party/vendor/android-properties/.cargo-checksum.json
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"files":{"Cargo.lock":"ca4c4498907a9ce08ce1b661cbf28e41ec36b54085a8e0706708a4515e50f7eb","Cargo.toml":"f597d8302ab0c3cef92f909ccfc88318d02484e65d1db2cf54eca018c2a1079d","LICENSE":"e6cf2125132847ba7e2f46d64e64869873d0c097493329e2b4af3db04793151f","README.md":"d3c1686d159a5c8653f0cdab207ac85214def74973a2572f7437c1a20c5bb294","examples/property_foreach.rs":"45611d0c7212d4f863ab150e1c3a69e65e79dbbf1e51562b0b9e331a025acdfd","examples/property_get.rs":"b4d724c426fbd3dae103a2bf749d291d147840e9df289c467775e497f439ad93","examples/property_refresh.rs":"e8717531a7ab98b5e3a125100962ffdbee47b66a03728d1cc501190aa2c365d0","examples/property_set.rs":"eb6874723fe9aebe9ac1a33e11da62131a96a03dede644a2d9ccc984897f0d9d","rustfmt.toml":"54a1ee2cc0ef13c6ea346c5f91228bad9fa2b5800965d9c70571727cf1490152","src/android/mod.rs":"92354cb65310f2b9c5018dc3ece071c4d1e6f1e511a214efd50e19eb7b6c1b02","src/lib.rs":"b0ccd26aaaea7a43176bb6468a4ae037d6627185bbf7ede7d245f7e7873d1174","src/mock/mod.rs":"0670271b6a3b7248eb850f878f4af5ed50ca46b3fc2745db359093b7c0dfd6fd","workspace.code-workspace":"4f888fe1084d2a9091583d5093693d81453c0b8d06dfd6192b096972bae551d4"},"package":"fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"}
|
||||
5
third-party/vendor/android-properties/Cargo.lock
generated
vendored
Normal file
5
third-party/vendor/android-properties/Cargo.lock
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "android-properties"
|
||||
version = "0.2.2"
|
||||
31
third-party/vendor/android-properties/Cargo.toml
vendored
Normal file
31
third-party/vendor/android-properties/Cargo.toml
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "android-properties"
|
||||
version = "0.2.2"
|
||||
authors = ["Mikhail Lappo <mikhail.lappo@esrlabs.com>"]
|
||||
exclude = [".travis.yml", "check.sh"]
|
||||
description = "Rust-based Android properties wrapper"
|
||||
homepage = "https://github.com/miklelappo/android-properties"
|
||||
documentation = "https://docs.rs/android-properties/0.2.2"
|
||||
readme = "README.md"
|
||||
keywords = ["android", "properties", "cutils", "bionic", "persistent"]
|
||||
categories = ["external-ffi-bindings", "os", "os::linux-apis"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/miklelappo/android-properties"
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["arm-linux-androideabi", "armv7-linux-androideabi", "aarch64-linux-android", "i686-linux-android", "x86_64-unknown-linux-gnu"]
|
||||
|
||||
[features]
|
||||
bionic-deprecated = []
|
||||
21
third-party/vendor/android-properties/LICENSE
vendored
Normal file
21
third-party/vendor/android-properties/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Mikhail Lappo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
6
third-party/vendor/android-properties/README.md
vendored
Normal file
6
third-party/vendor/android-properties/README.md
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[](https://travis-ci.org/miklelappo/android-properties)
|
||||
[](https://crates.io/crates/android-properties)
|
||||
[](https://github.com/miklelappo/android-properties/blob/master/LICENSE)
|
||||
|
||||
Rust-based Android properties wrapper
|
||||
=====================================
|
||||
5
third-party/vendor/android-properties/examples/property_foreach.rs
vendored
Normal file
5
third-party/vendor/android-properties/examples/property_foreach.rs
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
for property in android_properties::prop_values() {
|
||||
println!("{}", property);
|
||||
}
|
||||
}
|
||||
11
third-party/vendor/android-properties/examples/property_get.rs
vendored
Normal file
11
third-party/vendor/android-properties/examples/property_get.rs
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use android_properties::AndroidProperty;
|
||||
|
||||
const HELLO_WORLD_PROPERTY: &str = "hello.world";
|
||||
|
||||
fn main() {
|
||||
let mut hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
|
||||
match hello_world.value() {
|
||||
Some(_value) => println!("{}", hello_world),
|
||||
None => println!("Property {} not found", hello_world.name()),
|
||||
};
|
||||
}
|
||||
12
third-party/vendor/android-properties/examples/property_refresh.rs
vendored
Normal file
12
third-party/vendor/android-properties/examples/property_refresh.rs
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use android_properties::{setprop, AndroidProperty};
|
||||
|
||||
const HELLO_WORLD_PROPERTY: &str = "hello.world";
|
||||
|
||||
fn main() {
|
||||
setprop(HELLO_WORLD_PROPERTY, "initial value").expect("Cannot set android property");
|
||||
let hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
|
||||
println!("Initial property: {}", hello_world);
|
||||
|
||||
setprop(HELLO_WORLD_PROPERTY, "refreshed value").expect("Cannot set android property");
|
||||
println!("Refreshed property: {}", hello_world);
|
||||
}
|
||||
3
third-party/vendor/android-properties/examples/property_set.rs
vendored
Normal file
3
third-party/vendor/android-properties/examples/property_set.rs
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
android_properties::setprop("hello.world", "hello").expect("Cannot set android property");
|
||||
}
|
||||
2
third-party/vendor/android-properties/rustfmt.toml
vendored
Normal file
2
third-party/vendor/android-properties/rustfmt.toml
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
merge_imports = true
|
||||
max_width = 130
|
||||
111
third-party/vendor/android-properties/src/android/mod.rs
vendored
Normal file
111
third-party/vendor/android-properties/src/android/mod.rs
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
use crate::AndroidProperty;
|
||||
|
||||
use std::{
|
||||
ffi::{CStr, CString},
|
||||
os::raw::{c_char, c_int, c_void},
|
||||
};
|
||||
|
||||
type Callback = unsafe fn(*mut ValuePair, *const c_char, *const c_char, u32);
|
||||
type ForEachCallback = unsafe fn(*const c_void, *mut Vec<AndroidProperty>);
|
||||
|
||||
struct ValuePair {
|
||||
name: String,
|
||||
value: String,
|
||||
}
|
||||
|
||||
unsafe fn property_callback(cookie: *mut ValuePair, name: *const c_char, value: *const c_char, _serial: u32) {
|
||||
let cname = CStr::from_ptr(name);
|
||||
let cvalue = CStr::from_ptr(value);
|
||||
(*cookie).name = cname.to_str().unwrap().to_string();
|
||||
(*cookie).value = cvalue.to_str().unwrap().to_string();
|
||||
}
|
||||
|
||||
unsafe fn foreach_property_callback(pi: *const c_void, cookie: *mut Vec<AndroidProperty>) {
|
||||
let mut result = Box::new(ValuePair {
|
||||
name: String::new(),
|
||||
value: String::new(),
|
||||
});
|
||||
__system_property_read_callback(pi, property_callback, &mut *result);
|
||||
(*cookie).push(AndroidProperty {
|
||||
name: (*result).name,
|
||||
property_info: pi,
|
||||
});
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn __system_property_set(name: *const c_char, value: *const c_char) -> c_int;
|
||||
fn __system_property_find(name: *const c_char) -> *const c_void;
|
||||
fn __system_property_read_callback(pi: *const c_void, callback: Callback, cookie: *mut ValuePair);
|
||||
fn __system_property_foreach(callback: ForEachCallback, cookie: *mut Vec<AndroidProperty>) -> c_int;
|
||||
}
|
||||
|
||||
#[cfg(feature = "bionic-deprecated")]
|
||||
extern "C" {
|
||||
/* Deprecated. Use __system_property_read_callback instead. */
|
||||
fn __system_property_get(name: *const c_char, value: *mut c_char) -> c_int;
|
||||
}
|
||||
|
||||
/// Set system property `name` to `value`, creating the system property if it doesn't already exist
|
||||
pub fn plat_setprop(name: &str, value: &str) -> Result<(), String> {
|
||||
let cname = CString::new(name).unwrap();
|
||||
let cvalue = CString::new(value).unwrap();
|
||||
let ret = unsafe { __system_property_set(cname.as_ptr(), cvalue.as_ptr()) };
|
||||
if ret >= 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("Failed to set Android property \"{}\" to \"{}\"", name, value))
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieve a property with name `name`. Returns None if the operation fails.
|
||||
#[cfg(not(feature = "bionic-deprecated"))]
|
||||
pub fn plat_getprop(_: &str, property_info: *const c_void) -> Option<String> {
|
||||
let mut result = Box::new(ValuePair {
|
||||
name: String::new(),
|
||||
value: String::new(),
|
||||
});
|
||||
if !property_info.is_null() {
|
||||
unsafe { __system_property_read_callback(property_info, property_callback, &mut *result) };
|
||||
}
|
||||
Some((*result).value)
|
||||
}
|
||||
|
||||
/// Retrieve a property with name `name`. Returns None if the operation fails.
|
||||
#[cfg(feature = "bionic-deprecated")]
|
||||
pub fn plat_getprop(name: &str, _: *const c_void) -> Option<String> {
|
||||
const PROPERTY_VALUE_MAX: usize = 92;
|
||||
let cname = CString::new(name).unwrap();
|
||||
let cvalue = CString::new(Vec::with_capacity(PROPERTY_VALUE_MAX)).unwrap();
|
||||
let raw = cvalue.into_raw();
|
||||
let ret = unsafe { __system_property_get(cname.as_ptr(), raw) };
|
||||
match ret {
|
||||
len if len > 0 => unsafe { Some(String::from_raw_parts(raw as *mut u8, len as usize, PROPERTY_VALUE_MAX)) },
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an iterator to vector, which contains all properties present in a system
|
||||
pub fn plat_prop_values() -> impl Iterator<Item = AndroidProperty> {
|
||||
let mut properties: Box<Vec<AndroidProperty>> = Box::new(Vec::new());
|
||||
unsafe {
|
||||
__system_property_foreach(foreach_property_callback, &mut *properties);
|
||||
}
|
||||
properties.into_iter()
|
||||
}
|
||||
|
||||
/// Find property_info pointer using bionic syscall
|
||||
///
|
||||
/// returns nullptr if not found, otherwise valid pointer
|
||||
#[cfg(not(feature = "bionic-deprecated"))]
|
||||
pub fn plat_get_property_info(name: &str) -> *const c_void {
|
||||
let cname = CString::new(name).unwrap();
|
||||
unsafe { __system_property_find(cname.as_ptr()) }
|
||||
}
|
||||
|
||||
/// Deprecated version to find property_info pointer
|
||||
///
|
||||
/// Always returns nullptr
|
||||
#[cfg(feature = "bionic-deprecated")]
|
||||
pub fn plat_get_property_info(_name: &str) -> *const c_void {
|
||||
std::ptr::null()
|
||||
}
|
||||
92
third-party/vendor/android-properties/src/lib.rs
vendored
Normal file
92
third-party/vendor/android-properties/src/lib.rs
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
//! android-properties is a rust wrapper for bionic property-related syscalls
|
||||
|
||||
#![deny(missing_docs, missing_debug_implementations, unused)]
|
||||
|
||||
use std::{fmt, os::raw::c_void};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::android::*;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
use crate::mock::*;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
/// The implementation of property API for Android bionic-based systems
|
||||
pub mod android;
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
/// The mock implementation of property API for non-Android based systems
|
||||
pub mod mock;
|
||||
|
||||
/// A struct representing android properties
|
||||
///
|
||||
/// This struct consists from a name-value pair
|
||||
#[derive(Debug)]
|
||||
pub struct AndroidProperty {
|
||||
/// Property name
|
||||
name: String,
|
||||
/// Property info pointer
|
||||
property_info: *const c_void,
|
||||
}
|
||||
|
||||
impl AndroidProperty {
|
||||
/// Initializes and returns struct representing android properties
|
||||
pub fn new(name: &str) -> Self {
|
||||
AndroidProperty {
|
||||
name: name.to_string(),
|
||||
property_info: std::ptr::null(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return property name
|
||||
pub fn name(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
/// Return property value
|
||||
pub fn value(&mut self) -> Option<String> {
|
||||
if self.property_info.is_null() {
|
||||
self.property_info = plat_get_property_info(&self.name);
|
||||
}
|
||||
plat_getprop(&self.name, self.property_info)
|
||||
}
|
||||
|
||||
/// Set property value
|
||||
pub fn set_value(&self, value: &str) -> Result<(), String> {
|
||||
plat_setprop(&self.name, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for AndroidProperty {
|
||||
// Output in format [<name>]: [<value>]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut property_info = self.property_info;
|
||||
if property_info.is_null() {
|
||||
property_info = plat_get_property_info(&self.name);
|
||||
}
|
||||
write!(
|
||||
f,
|
||||
"[{}]: [{}]",
|
||||
self.name,
|
||||
plat_getprop(&self.name, property_info).unwrap_or_else(|| "".into())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the property value if it exists
|
||||
pub fn getprop(name: &str) -> AndroidProperty {
|
||||
AndroidProperty::new(name)
|
||||
}
|
||||
|
||||
/// Sets the property value if it exists or creates new one with specified value
|
||||
pub fn setprop(name: &str, value: &str) -> Result<(), String> {
|
||||
AndroidProperty::new(name).set_value(value)
|
||||
}
|
||||
|
||||
/// Returns an iterator to vector, which contains all properties present in a system
|
||||
pub fn prop_values() -> impl Iterator<Item = AndroidProperty> {
|
||||
#[cfg(target_os = "android")]
|
||||
return crate::android::plat_prop_values();
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
return crate::mock::plat_prop_values();
|
||||
}
|
||||
31
third-party/vendor/android-properties/src/mock/mod.rs
vendored
Normal file
31
third-party/vendor/android-properties/src/mock/mod.rs
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use crate::AndroidProperty;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
/// Mock implementation for getprop
|
||||
///
|
||||
/// Always returns None
|
||||
pub fn plat_getprop(_: &str, _: *const c_void) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Mock implementation for setprop
|
||||
///
|
||||
/// Always returns Err
|
||||
pub fn plat_setprop(_name: &str, _value: &str) -> Result<(), String> {
|
||||
Err("Failed to set android property (OS not supported)".to_string())
|
||||
}
|
||||
|
||||
/// Mock implementation for prop_values
|
||||
///
|
||||
/// Always returns iterator to empty vector
|
||||
pub fn plat_prop_values() -> impl Iterator<Item = AndroidProperty> {
|
||||
let properties: Box<Vec<AndroidProperty>> = Box::new(Vec::new());
|
||||
properties.into_iter()
|
||||
}
|
||||
|
||||
/// Mock implementation to find property_info pointer
|
||||
///
|
||||
/// Always returns nullptr
|
||||
pub fn plat_get_property_info(_name: &str) -> *const c_void {
|
||||
std::ptr::null()
|
||||
}
|
||||
7
third-party/vendor/android-properties/workspace.code-workspace
vendored
Normal file
7
third-party/vendor/android-properties/workspace.code-workspace
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue