| use std::process::Command; |
|
|
| |
| const EINK_MANUFACTURERS: &[&str] = &[ |
| "onyx", |
| "boox", |
| "amazon", |
| "kobo", |
| "remarkable", |
| "pocketbook", |
| "boyue", |
| "likebook", |
| "dasung", |
| "bigme", |
| "hisense", |
| "hanvon", |
| "tolino", |
| "bookeen", |
| "supernote", |
| "mobiscribe", |
| "xiaomi", |
| "meebook", |
| ]; |
|
|
| |
| const EINK_MODELS: &[&str] = &[ |
| "kindle", |
| "a5pro", |
| "a7cc", |
| "a7e", |
| "a9", |
| "inkpalm", |
| "eink", |
| "e-ink", |
| "paper", |
| "note air", |
| "note2", |
| "note3", |
| "note5", |
| "nova", |
| "poke", |
| "leaf", |
| "page", |
| "tab ultra", |
| "max lumi", |
| ]; |
|
|
| |
| fn get_system_property(prop: &str) -> Option<String> { |
| Command::new("getprop") |
| .arg(prop) |
| .output() |
| .ok() |
| .and_then(|output| { |
| if output.status.success() { |
| let value = String::from_utf8_lossy(&output.stdout).trim().to_string(); |
| if value.is_empty() { |
| None |
| } else { |
| Some(value) |
| } |
| } else { |
| None |
| } |
| }) |
| } |
|
|
| |
| pub fn is_eink_device() -> bool { |
| |
| let manufacturer = get_system_property("ro.product.manufacturer") |
| .or_else(|| get_system_property("ro.product.brand")) |
| .unwrap_or_default() |
| .to_lowercase(); |
|
|
| let model = get_system_property("ro.product.model") |
| .or_else(|| get_system_property("ro.product.device")) |
| .unwrap_or_default() |
| .to_lowercase(); |
|
|
| let device = get_system_property("ro.product.device") |
| .unwrap_or_default() |
| .to_lowercase(); |
|
|
| |
| for eink_manufacturer in EINK_MANUFACTURERS { |
| if manufacturer.contains(eink_manufacturer) { |
| |
| if *eink_manufacturer == "hisense" || *eink_manufacturer == "xiaomi" { |
| |
| for eink_model in EINK_MODELS { |
| if model.contains(eink_model) || device.contains(eink_model) { |
| return true; |
| } |
| } |
| } else { |
| return true; |
| } |
| } |
| } |
|
|
| |
| for eink_model in EINK_MODELS { |
| if model.contains(eink_model) || device.contains(eink_model) { |
| return true; |
| } |
| } |
|
|
| |
| if let Some(eink_support) = get_system_property("ro.eink.support") { |
| if eink_support == "1" || eink_support.to_lowercase() == "true" { |
| return true; |
| } |
| } |
|
|
| |
| if get_system_property("ro.onyx.devicename").is_some() { |
| return true; |
| } |
|
|
| false |
| } |
|
|