Skip to content

Commit

Permalink
Update gpapi to support google play api v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hainish committed Mar 29, 2024
1 parent 685caed commit a699d3f
Show file tree
Hide file tree
Showing 10 changed files with 2,935 additions and 2,043 deletions.
17 changes: 6 additions & 11 deletions gpapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,22 @@ repository = "https://github.com/EFForg/rs-google-play/tree/master/gpapi"

[dependencies]
prost = "0.12"
reqwest = { version = "0.11", features = ["stream"] }
reqwest = { version = "0.12", features = ["stream"] }
bytes = "1"
openssl = "0.10"
base64 = "0.21"
byteorder = "1"
hex = "0.4"
lazy_static = "1.4"
hyper = { version = "0.14", features = ["full"] }
hyper-openssl = "0.9"
googleplay-protobuf = "1"
hyper-tls = "0.5"
googleplay-protobuf = { path= "../googleplay-protobuf" }
bincode = "1"
futures-util = { version = "0.3", features = ["io"] }
futures = "0.3"
tokio-dl-stream-to-disk = "1"
indicatif = "0.17"
serde = { version = "1", features = ["derive"] }

[build-dependencies]
googleplay-protobuf = "1"
googleplay-protobuf = { path= "../googleplay-protobuf" }
prost = "0.12"
bincode = "1"
configparser = "3"
serde = { version = "1", features = ["derive"] }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
4 changes: 3 additions & 1 deletion gpapi/README.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ Documentation for this crate can be found on [docs.rs](https://docs.rs/gpapi/).

## Todo

Some of the functionality of the python library is missing, such as browsing and searching for packages.
This inludes some subset, but not all, of the Google Play API library. Some of the functionality is missing, such as browsing and searching for packages.

## Credits

This library was originally created by David Weinstein, and is currently maintained by Bill Budington.

It follows some of the conventions set by Aurora's [gplayapi java library](https://gitlab.com/AuroraOSS/gplayapi/). It was originally modeled after the [googleplay-api for python](https://github.com/NoMore200/googleplay-api.git) patterns.

License: {{license}}
61 changes: 43 additions & 18 deletions gpapi/build.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::Write;
use std::io::{Cursor, Write};
use std::path::Path;

use configparser::ini::Ini;
use prost::Message;

use googleplay_protobuf::{AndroidBuildProto, AndroidCheckinProto, DeviceConfigurationProto};
use googleplay_protobuf::{AndroidBuildProto, AndroidCheckinProto, DeviceConfigurationProto, DeviceFeature};

use serde::{Serialize, Deserialize};
include!("src/device_properties.rs");

fn main() {
if !Path::new("src/device_properties.bin").exists()
|| !Path::new("src/android_checkins.bin").exists()
{
if !Path::new("src/device_properties.bin").exists() {
let mut config = Ini::new();
config
.read(fs::read_to_string("device.properties").unwrap())
.unwrap();

let mut device_configurations = HashMap::new();
let mut android_checkins = HashMap::new();
let mut device_properties_map = HashMap::new();
for section in config.sections() {
println!("{:?}", section);
let mut extra_info = HashMap::new();
extra_info.insert("Build.ID".to_string(), config.get(&section, "Build.ID").unwrap_or_default());
extra_info.insert("Vending.versionString".to_string(), config.get(&section, "Vending.versionString").unwrap_or_default());
extra_info.insert("Vending.version".to_string(), config.get(&section, "Vending.version").unwrap_or_default());
extra_info.insert("Build.VERSION.RELEASE".to_string(), config.get(&section, "Build.VERSION.RELEASE").unwrap_or_default());
if let Some(sim_operator) = config.get(&section, "SimOperator") {
extra_info.insert("SimOperator".to_string(), sim_operator);
}
let mut android_build = AndroidBuildProto::default();
android_build.id = config.get(&section, "Build.FINGERPRINT");
android_build.product = config.get(&section, "Build.HARDWARE");
Expand Down Expand Up @@ -51,7 +60,6 @@ fn main() {
let mut android_checkin_encoded = Vec::new();
android_checkin_encoded.reserve(android_checkin.encoded_len());
android_checkin.encode(&mut android_checkin_encoded).unwrap();
android_checkins.insert(section.clone(), android_checkin_encoded);

let mut device_configuration = DeviceConfigurationProto::default();
device_configuration.touch_screen = config
Expand Down Expand Up @@ -96,14 +104,18 @@ fn main() {
.collect();
device_configuration.native_platform = config
.get(&section, "Platforms")
.unwrap()
.unwrap_or_default()
.split(",")
.map(|s| String::from(s))
.collect();
device_configuration.screen_width = config
.getint(&section, "Screen.Width")
.unwrap()
.map(|v| v as i32);
device_configuration.screen_height = config
.getint(&section, "Screen.Height")
.unwrap()
.map(|v| v as i32);
device_configuration.system_supported_locale = config
.get(&section, "Locales")
.unwrap()
Expand All @@ -116,19 +128,32 @@ fn main() {
.split(",")
.map(|s| String::from(s))
.collect();
let mut device_encoded = Vec::new();
device_encoded.reserve(device_configuration.encoded_len());
device_configuration.encode(&mut device_encoded).unwrap();
device_configurations.insert(section, device_encoded);
device_configuration.device_feature = config
.get(&section, "Features")
.unwrap()
.split(",")
.map(|s| {
let feature_name = String::from(s);
let mut device_feature = DeviceFeature::default();
device_feature.name = Some(feature_name);
device_feature.value = Some(0);
device_feature
})
.collect();
let mut device_configuration_encoded = Vec::new();
device_configuration_encoded.reserve(device_configuration.encoded_len());
device_configuration.encode(&mut device_configuration_encoded).unwrap();
let device_properties_encoded = EncodedDeviceProperties::new(
device_configuration_encoded,
android_checkin_encoded,
extra_info,
);
device_properties_map.insert(section.replace("gplayapi_", "").replace(".properties", ""), device_properties_encoded);
}

let checkins_encoded: Vec<u8> = bincode::serialize(&android_checkins).unwrap();
let devices_encoded: Vec<u8> = bincode::serialize(&device_configurations).unwrap();
let devices_encoded: Vec<u8> = bincode::serialize(&device_properties_map).unwrap();

let mut file = File::create("src/device_properties.bin").unwrap();
file.write_all(&devices_encoded).unwrap();

let mut file = File::create("src/android_checkins.bin").unwrap();
file.write_all(&checkins_encoded).unwrap();
}
}
Loading

0 comments on commit a699d3f

Please sign in to comment.