-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimp_control_util.c
66 lines (61 loc) · 1.81 KB
/
imp_control_util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include "imp_control_util.h"
char* GetDeviceID() {
SUDevID devID;
int ret = SU_Base_GetDevID(&devID);
if (ret != 0) {
snprintf(response, sizeof(response), "Error: Failed to get device ID.");
return response;
}
snprintf(response, sizeof(response), "%s", devID.chr);
return response;
};
char* GetModelFamily() {
SUModelNum modelNum;
int ret = SU_Base_GetModelNumber(&modelNum);
if (ret != 0) {
snprintf(response, sizeof(response), "Error: Failed to get model family.");
return response;
}
snprintf(response, sizeof(response), "%s", modelNum.chr);
return response;
};
char* GetSysVersion() {
SUVersion version;
int ret = SU_Base_GetVersion(&version);
if (ret != 0) {
snprintf(response, sizeof(response), "Error: Failed to get SDK SYSUTILS Version.");
return response;
}
snprintf(response, sizeof(response), "Ingenic %s", version.chr);
return response;
};
char *GetIMPVersion(char *tokenPtr) {
IMPVersion version;
int ret = IMP_System_GetVersion(&version);
if (ret == 0) {
snprintf(response, sizeof(response), "Ingenic %s", version.aVersion);
} else {
snprintf(response, sizeof(response), "Failed to get IMP version");
}
return response;
}
const char* (*original_IMP_System_GetCPUInfo)(void) = NULL;
void initialize_original_functions() {
if (!original_IMP_System_GetCPUInfo) {
original_IMP_System_GetCPUInfo = dlsym(RTLD_NEXT, "IMP_System_GetCPUInfo");
}
}
char *GetCPUInfo(char *tokenPtr) {
initialize_original_functions(); // Ensure the original function is loaded
if (original_IMP_System_GetCPUInfo) {
const char* cpuInfo = original_IMP_System_GetCPUInfo(); if (cpuInfo != NULL) {
snprintf(response, sizeof(response), "%s", cpuInfo);
} else {
snprintf(response, sizeof(response), "Failed to get CPU info");
}
return response;
}
}