Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ cc_binary {
name: "pd-mapper",
vendor: true,
srcs: [
"pd-mapper.c",
"assoc.c",
"json.c",
"servreg_loc.c",
"assoc.c",
"json.c",
"pd-mapper.c",
"servreg_loc.c",
],
shared_libs: ["libqrtr"],
}
8 changes: 7 additions & 1 deletion json.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#if !defined(__ANDROID__)
#include <lzma.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -315,7 +317,9 @@ struct json_value *json_parse(const char *json)
return root;
}

#if !defined(__ANDROID__)
extern int lzma_decomp(const char *file);
#endif

struct json_value *json_parse_file(const char *file)
{
Expand All @@ -324,10 +328,12 @@ struct json_value *json_parse_file(const char *file)
int ret;
int fd;

#if !defined(__ANDROID__)
if ((strlen(file) > 3) && !strcmp(&file[strlen(file)-3], ".xz"))
fd = lzma_decomp(file);
else
fd = open(file, O_RDONLY);
#endif
fd = open(file, O_RDONLY);

if (fd < 0) {
fprintf(stderr, "failed to open %s: %s\n", file, strerror(errno));
Expand Down
19 changes: 9 additions & 10 deletions pd-mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,20 @@ static int concat_path(char *base_path, char *firmware_path, char *path, size_t
#ifndef ANDROID
#define FIRMWARE_BASE "/lib/firmware/"
#define FIRMWARE_PARAM_PATH "/sys/module/firmware_class/parameters/path"
#else
#define FIRMWARE_BASE "/vendor/firmware/"
#endif

static DIR *opendir_firmware(char *firmware_path, char *out_path_opened, size_t out_path_size)
{
int ret = 0, n;
int ret = 0;
DIR *fw_dir = NULL;
int fw_param_path = open(FIRMWARE_PARAM_PATH, O_RDONLY);
char fw_sysfs_path[PATH_MAX];

#ifndef ANDROID
int n;
int fw_param_path = open(FIRMWARE_PARAM_PATH, O_RDONLY);

if (fw_param_path < 0) {
warn("Cannot open sysfs path: %s", FIRMWARE_PARAM_PATH);
close(fw_param_path);
Expand Down Expand Up @@ -247,6 +253,7 @@ static DIR *opendir_firmware(char *firmware_path, char *out_path_opened, size_t

return fw_dir;
err:
#endif
ret = concat_path(FIRMWARE_BASE, firmware_path, out_path_opened, out_path_size);
if (ret)
return fw_dir;
Expand All @@ -257,14 +264,6 @@ static DIR *opendir_firmware(char *firmware_path, char *out_path_opened, size_t

return fw_dir;
}
#else
#define FIRMWARE_BASE "/vendor/firmware/"

DIR opendir_firmware(char *firmware_path)
{
return open_concat_path("/vendor/firmware/", firmware_path);
}
#endif

static char *known_extensions[] = {
".jsn.xz",
Expand Down