Skip to content

Commit

Permalink
add version number
Browse files Browse the repository at this point in the history
  • Loading branch information
capntrips committed Oct 16, 2023
1 parent 77dc265 commit 54d739c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions oemlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <OemLockClient.h>
#include <android/hardware/oemlock/1.0/IOemLock.h>
#include <sysexits.h>
#include "version.h"

using android::sp;

Expand All @@ -17,7 +18,7 @@ static void usage(FILE* where, int /* argc */, char* argv[]) {
"%s - command-line wrapper for the oemlock HAL.\n"
"\n"
"Usage:\n"
" %s COMMAND\n"
" %s [-v|--version] [COMMAND]\n"
"\n"
"Commands:\n"
" hal-info - Show info about oemlock HAL used.\n"
Expand Down Expand Up @@ -63,14 +64,19 @@ static int do_is_oem_unlock_allowed_by_device(OemLockClient* module) {
return handle_return(ret, "Error calling isOemUnlockAllowedByDevice()\n");
}

static int do_version() {
fprintf(stdout, "OemLock: %s\n", version);
return EX_OK;
}

int main(int argc, char* argv[]) {
const auto client = android::hal::OemLockClient::WaitForService();
if (client == nullptr) {
fprintf(stderr, "Failed to get oemlock module.\n");
return EX_SOFTWARE;
}

if (argc < 2) {
if (argc != 2) {
usage(stderr, argc, argv);
return EX_USAGE;
}
Expand All @@ -81,6 +87,8 @@ int main(int argc, char* argv[]) {
return do_is_oem_unlock_allowed_by_carrier(client.get());
} else if (strcmp(argv[1], "is-oem-unlock-allowed-by-device") == 0) {
return do_is_oem_unlock_allowed_by_device(client.get());
} else if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
return do_version();
}

// Parameter not matched, print usage
Expand Down
6 changes: 6 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __OEMLOCK_VERSION_H_
#define __OEMLOCK_VERSION_H_

const char *version = "v1.0.0 (android-14.0.0_r2)";

#endif //__OEMLOCK_VERSION_H_

0 comments on commit 54d739c

Please sign in to comment.