You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB

#include <VendorStorageClient.h>
using aidl::rockchip::aidl::vendorstorage::VendorStorageClient;
#define EXAMPLE_SIZE 256
int main(int argc, char **argv) {
if (argc < 3) {
cout << "Usage: " << argv[0] << " r <id> # Read from vendor storage" << endl;
cout << "Usage: " << argv[0] << " w <id> <data> # Write to vendor storage" << endl;
cout << "Usage: " << argv[0] << " rc <key> # Read from vendor storage cached" << endl;
cout << "Usage: " << argv[0] << " wc <key> <data> # Write to vendor storage cached" << endl;
return -1;
}
int ret = 0;
std::string command = argv[1];
char buf[EXAMPLE_SIZE] = {0};
VendorStorageClient aidl = VendorStorageClient();
aidl.setDebug(true);
if (command == "r") {
ret = aidl.read(std::stoi(argv[2]), buf, EXAMPLE_SIZE);
cout << "Read from vendorstorage: " << buf << endl;
} else if (command == "rc") {
ret = aidl.readCached(argv[2], buf, EXAMPLE_SIZE);
cout << "Read from vendorstorage: " << buf << endl;
} else if (command == "w" && argc > 3) {
ret = aidl.write(std::stoi(argv[2]), argv[3], strlen(argv[3]));
cout << "Write to vendorstorage: " << buf << endl;
} else if (command == "wc" && argc > 3) {
ret = aidl.writeCached(argv[2], argv[3], strlen(argv[3]));
}
// We can also add wait here to accept data from callback
return ret;
}