mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-29 15:32:01 +00:00
(Android) Refactor away system_property_get_density - make regular calls to
system_property_get instead
This commit is contained in:
parent
4f77946761
commit
63924971aa
@ -776,7 +776,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity,
|
||||
}
|
||||
|
||||
|
||||
int system_property_get(const char *name, char *value)
|
||||
int system_property_get(const char *command, const char *args, char *value)
|
||||
{
|
||||
FILE *pipe;
|
||||
int length = 0;
|
||||
@ -784,7 +784,7 @@ int system_property_get(const char *name, char *value)
|
||||
char cmd[PATH_MAX_LENGTH] = {0};
|
||||
char *curpos = NULL;
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "getprop %s", name);
|
||||
snprintf(cmd, sizeof(cmd), "%s %s", command, args);
|
||||
|
||||
pipe = popen(cmd, "r");
|
||||
|
||||
@ -818,14 +818,14 @@ int system_property_get(const char *name, char *value)
|
||||
|
||||
static void frontend_android_get_name(char *s, size_t len)
|
||||
{
|
||||
system_property_get("ro.product.model", s);
|
||||
system_property_get("getprop", "ro.product.model", s);
|
||||
}
|
||||
|
||||
static void frontend_android_get_version(int32_t *major,
|
||||
int32_t *minor, int32_t *rel)
|
||||
{
|
||||
char os_version_str[PROP_VALUE_MAX] = {0};
|
||||
system_property_get("ro.build.version.release", os_version_str);
|
||||
system_property_get("getprop", "ro.build.version.release", os_version_str);
|
||||
|
||||
*major = 0;
|
||||
*minor = 0;
|
||||
@ -851,7 +851,7 @@ static void frontend_android_get_version(int32_t *major,
|
||||
static void frontend_android_get_version_sdk(int32_t *sdk)
|
||||
{
|
||||
char os_version_str[PROP_VALUE_MAX] = {0};
|
||||
system_property_get("ro.build.version.sdk", os_version_str);
|
||||
system_property_get("getprop", "ro.build.version.sdk", os_version_str);
|
||||
|
||||
*sdk = 0;
|
||||
if (os_version_str[0])
|
||||
@ -1456,7 +1456,7 @@ static enum frontend_architecture frontend_linux_get_architecture(void)
|
||||
const char *val;
|
||||
#ifdef ANDROID
|
||||
char abi[PROP_VALUE_MAX] = {0};
|
||||
system_property_get("ro.product.cpu.abi", abi);
|
||||
system_property_get("getprop", "ro.product.cpu.abi", abi);
|
||||
val = abi;
|
||||
#else
|
||||
struct utsname buffer;
|
||||
@ -1916,7 +1916,7 @@ static void frontend_linux_get_env(int *argc,
|
||||
}
|
||||
|
||||
frontend_android_get_name(device_model, sizeof(device_model));
|
||||
system_property_get("ro.product.id", device_id);
|
||||
system_property_get("getprop", "ro.product.id", device_id);
|
||||
|
||||
g_defaults.settings.video_threaded_enable = true;
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "../../frontend/drivers/platform_linux.h"
|
||||
|
||||
/* forward declaration */
|
||||
int system_property_get(const char *name, char *value);
|
||||
int system_property_get(const char *cmd, const char *args, char *value);
|
||||
|
||||
typedef struct gfx_ctx_android_data
|
||||
{
|
||||
@ -387,52 +387,12 @@ static void android_gfx_ctx_bind_hw_render(void *data, bool enable)
|
||||
android->g_egl_hw_ctx : android->g_egl_ctx);
|
||||
}
|
||||
|
||||
static int system_property_get_density(char *value)
|
||||
{
|
||||
FILE *pipe;
|
||||
int length = 0;
|
||||
char buffer[PATH_MAX_LENGTH] = {0};
|
||||
char cmd[PATH_MAX_LENGTH] = {0};
|
||||
char *curpos = NULL;
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "wm density");
|
||||
|
||||
pipe = popen(cmd, "r");
|
||||
|
||||
if (!pipe)
|
||||
{
|
||||
RARCH_ERR("Could not create pipe.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
curpos = value;
|
||||
|
||||
while (!feof(pipe))
|
||||
{
|
||||
if (fgets(buffer, 128, pipe) != NULL)
|
||||
{
|
||||
int curlen = strlen(buffer);
|
||||
|
||||
memcpy(curpos, buffer, curlen);
|
||||
|
||||
curpos += curlen;
|
||||
length += curlen;
|
||||
}
|
||||
}
|
||||
|
||||
*curpos = '\0';
|
||||
|
||||
pclose(pipe);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
static void dpi_get_density(char *s, size_t len)
|
||||
{
|
||||
system_property_get("ro.sf.lcd_density", s);
|
||||
system_property_get("getprop", "ro.sf.lcd_density", s);
|
||||
|
||||
if (s[0] == '\0')
|
||||
system_property_get_density(s);
|
||||
system_property_get("wm", "density", s);
|
||||
}
|
||||
|
||||
static bool android_gfx_ctx_get_metrics(void *data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user