summaryrefslogtreecommitdiff
path: root/depend-0002-add-depend-for-openeuler.patch
blob: baf0915f130a566b738ff02ebcde510b683abff1 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
From: "liheavy" <lihaiwei8@huawei.com>
Date: Fir, 26 Nov 2022 09:45:38 +0800
Subject: [PATCH] Adaptation for depend of dsoftbus

---
diff -Nur a/BUILD.gn b/BUILD.gn
--- a/BUILD.gn	1970-01-01 08:00:00.000000000 +0800
+++ b/BUILD.gn	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1,59 @@
+import("//build/ohos.gni")
+
+config("hilog_config") {
+  include_dirs = [ 
+    "hilog/include",
+    "//third_party/bounds_checking_function/include",
+  ]
+}
+
+ohos_shared_library("libhilog") {
+  public_configs = [ ":hilog_config" ]
+  sources = [
+    "hilog/hilog.c",
+  ]
+  deps = [
+    "//third_party/bounds_checking_function:libsec_shared",
+  ]
+}
+
+group("system_ability_fwk") {
+}
+
+group("samgr_proxy") {
+}
+
+group("libpermissionsdk_standard") {
+}
+
+group("cesfwk_innerkits") {
+}
+
+group("want") {
+}
+
+group("appexecfwk_core") {
+}
+
+group("libaccesstoken_sdk") {
+}
+
+config("syspara_config") {
+  include_dirs = [
+    "syspara/include",
+  ]
+}
+
+ohos_shared_library("syspara") {
+  include_dirs = [
+    "syspara/include",
+  ]
+  sources = [
+    "syspara/syspara.c",
+  ]
+  public_configs = [ ":syspara_config" ]
+  deps = [
+    "//third_party/bounds_checking_function:libsec_shared",
+    "//third_party/mbedtls:mbedtls_shared",
+  ]
+}
diff -Nur a/hilog/hilog.c b/hilog/hilog.c
--- a/hilog/hilog.c	1970-01-01 08:00:00.000000000 +0800
+++ b/hilog/hilog.c	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "securec.h"
+#include "hilog_base/log_base.h"
+
+#ifndef LOG_PRINT_MAX_LEN
+#define LOG_PRINT_MAX_LEN 256
+#endif
+
+char *adapterStrForPrintfFormat(const char *fmt) {
+    char *left, *right;
+    char *buffer = (char *)malloc(LOG_PRINT_MAX_LEN * sizeof(char));
+    (void)memset_s(buffer, LOG_PRINT_MAX_LEN * sizeof(char), 0, LOG_PRINT_MAX_LEN * sizeof(char));
+    strcpy_s(buffer, LOG_PRINT_MAX_LEN * sizeof(char), fmt);
+    while (strstr(buffer, "{")) {
+        left = strstr(buffer, "{");
+        right = strstr(buffer, "}");
+        right++;
+        while (*right != '\0') {
+            *left = *right;
+            left++;
+            right++;
+        }
+        *left = '\0';
+    }
+    return buffer;
+}
+
+void printfAdapter(const char *fmt, ...) {
+    char *buffer;
+    buffer = adapterStrForPrintfFormat(fmt);
+    va_list ap;
+    va_start(ap, fmt);
+    vprintf(buffer, ap);
+    va_end(ap);
+    free(buffer);
+}
diff -Nur a/hilog/include/hilog/log.h b/hilog/include/hilog/log.h
--- a/hilog/include/hilog/log.h	1970-01-01 08:00:00.000000000 +0800
+++ b/hilog/include/hilog/log.h	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1,37 @@
+#ifndef _HILOG_H
+#define _HILOG_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif
+
+// Log type
+typedef enum {
+    LOG_TYPE_MIN = 0,
+    LOG_APP = 0,
+    // Log to kmsg, only used by init phase.
+    LOG_INIT = 1,
+    // Used by core service, framework.
+    LOG_CORE = 3,
+    LOG_TYPE_MAX
+} LogType;
+
+char *adapterStrForPrintfFormat(const char *fmt);
+void printfAdapter(const char *fmt, ...);
+
+#define HILOG_DEBUG(type, fmt, ...) printfAdapter(fmt"\n", ##__VA_ARGS__)
+#define HILOG_INFO(type, fmt, ...)  printfAdapter(fmt"\n", ##__VA_ARGS__)
+#define HILOG_WARN(type, fmt, ...)  printfAdapter(fmt"\n", ##__VA_ARGS__)
+#define HILOG_ERROR(type, fmt, ...) printfAdapter(fmt"\n", ##__VA_ARGS__)
+#define HiLogPrint(type, level, domain, tag, fmt, ...) printf(fmt"\n", ##__VA_ARGS__)
+#define HiLogBasePrint(type, level, domain, tag, fmt, ...) printfAdapter(fmt"\n", ##__VA_ARGS__)
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+
+#endif
diff -Nur a/hilog/include/hilog_base/log_base.h b/hilog/include/hilog_base/log_base.h
--- a/hilog/include/hilog_base/log_base.h	1970-01-01 08:00:00.000000000 +0800
+++ b/hilog/include/hilog_base/log_base.h	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1 @@
+#include <hilog/log.h>
diff -Nur a/ohos.build b/ohos.build
--- a/ohos.build	1970-01-01 08:00:00.000000000 +0800
+++ b/ohos.build	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1,114 @@
+{
+  "subsystem": "depend",
+  "parts": {
+    "hiviewdfx_hilog_native": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:libhilog",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+    "ces_standard": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:cesfwk_innerkits",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+    "aafwk_standard": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:want",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+    "appexecfwk_standard": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:appexecfwk_core",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+   "permission_standard": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:libpermissionsdk_standard",
+          "header": {
+            "header_files": [ ],
+            "header_base":"//depend"
+          }
+        }
+      ]
+    },
+    "safwk": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:system_ability_fwk",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+    "samgr_L2": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:samgr_proxy",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+    "samgr_standard": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:samgr_proxy",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    },
+    "access_token": {
+      "module_list": [ ],
+      "inner_kits": [
+        {
+          "name": "//depend:libaccesstoken_sdk",
+          "header": {
+            "header_files": [ ],
+            "header_base": "//depend"
+          }
+        }
+      ]
+    }
+  }
+}
+
diff -Nur a/syspara/include/parameter.h b/syspara/include/parameter.h
--- a/syspara/include/parameter.h	1970-01-01 08:00:00.000000000 +0800
+++ b/syspara/include/parameter.h	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1,20 @@
+#ifndef SYSPARA_PARAMETER_H
+#define SYSPARA_PARAMETER_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif /* __cplusplus */
+
+int GetDevUdid(char *udid, int size);
+
+char * GetDeviceType(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif /* __cplusplus */
+
+#endif /* SYSPARA_PARAMETER_H */
diff -Nur a/syspara/syspara.c b/syspara/syspara.c
--- a/syspara/syspara.c	1970-01-01 08:00:00.000000000 +0800
+++ b/syspara/syspara.c	2022-09-28 10:28:40.000000000 +0800
@@ -0,0 +1,86 @@
+#include <string.h>
+#include "securec.h"
+#include "parameter.h"
+#include "sha256.h"
+
+#define SN_FILE "/etc/SN"
+#define SN_LEN 65
+#define UDID_LEN 65
+#define DEV_BUF_LENGTH 3
+#define HASH_LENGTH 32
+static char *deviceType = "UNKNOWN";
+
+static int GetHash(const char *input, char *output, int size)
+{
+	char buf[DEV_BUF_LENGTH] = { 0 };
+	unsigned char hash[HASH_LENGTH] = { 0 };
+	mbedtls_sha256_context context;
+
+	mbedtls_sha256_init(&context);
+	mbedtls_sha256_starts_ret(&context, 0);
+	mbedtls_sha256_update_ret(&context, (const unsigned char*)input, strlen(input));
+	mbedtls_sha256_finish_ret(&context, hash);
+
+	for (size_t i = 0; i < HASH_LENGTH; i++) {
+		unsigned char value = hash[i];
+		memset_s(buf, DEV_BUF_LENGTH, 0, DEV_BUF_LENGTH);
+		sprintf_s(buf, sizeof(buf), "%02X", value);
+		if (strcat_s(output, size, buf) != 0) {
+			return -1;
+		}
+	}
+	return 0;
+}
+
+int GetDevUdid(char *udid, int size)
+{
+	FILE *fp;
+	char *realPath = NULL;
+	char sn[SN_LEN] = {0};
+	char out[UDID_LEN] = {0};
+	int ret;
+
+	realPath = realpath(SN_FILE, NULL);
+	if (realPath == NULL) {
+		printf("realpath fail.\n");
+		goto err_realpath;
+	}
+
+	fp = fopen(realPath, "r");
+	if (fp == NULL) {
+		printf("open SN fail.\n");
+		goto err_fopen;
+	}
+
+	ret = fscanf_s(fp, "%s", sn, SN_LEN);
+	if (ret < 1) {
+		printf("get sn fail.\n");
+		goto err_out;
+	}
+
+	ret = GetHash(sn, out, UDID_LEN);
+	if (ret < 0) {
+		printf("get hash fail.\n");
+		goto err_out;
+	}
+
+	ret = sprintf_s(udid, size, "%s", out);
+	if (ret <= 0) {
+		printf("sprintf_s error.\n");
+		goto err_out;
+	}
+
+	fclose(fp);
+	return 0;
+err_out:
+	fclose(fp);
+err_fopen:
+	free(realPath);
+err_realpath:
+	return -1;
+}
+
+char * GetDeviceType(void)
+{
+	return deviceType;
+}