mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
Merge branch 'master' of https://gitee.com/openharmony/developtools_syscap_codec into syscap-extern
Change-Id: I4958028e552cd85fa31ae44f86c6b8129f291914
This commit is contained in:
@@ -151,6 +151,7 @@ build_ext_component("generate_pcid") {
|
||||
ohos_prebuilt_etc("PCID.sc") {
|
||||
deps = [ ":generate_pcid" ]
|
||||
source = "$root_out_dir/PCID.sc"
|
||||
subsystem_name = "developtools"
|
||||
part_name = "syscap_codec"
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
"syscap": [ "SystemCapability.Developtools.Syscap" ],
|
||||
"feature": [ "syscap_codec_config_path" ],
|
||||
"adapted_system_type": [ "small", "standard" ],
|
||||
"rom": "0",
|
||||
"ram": "0",
|
||||
"deps": {
|
||||
"components": [
|
||||
"napi",
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _SYSCAP_DEFINE_H
|
||||
#define _SYSCAP_DEFINE_H
|
||||
#ifndef SYSCAP_DEFINE_H
|
||||
#define SYSCAP_DEFINE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -283,6 +283,7 @@ typedef enum SystemCapabilityNum {
|
||||
GRAPHIC_SURFACE_LITE,
|
||||
GRAPHIC_GRAPHIC_UTILS_LITE,
|
||||
WINDOW_WINDOW_MANAGER_LITE,
|
||||
DRIVER_DEVICEMANAGER_EXTENSION,
|
||||
// Add before here
|
||||
SYSCAP_NUM_MAX = 500
|
||||
} SyscapNum;
|
||||
@@ -547,6 +548,7 @@ const static SyscapWithNum g_arraySyscap[] = {
|
||||
{"SystemCapability.Graphic.SurfaceLite", GRAPHIC_SURFACE_LITE},
|
||||
{"SystemCapability.Graphic.GraphicUtilsLite", GRAPHIC_GRAPHIC_UTILS_LITE},
|
||||
{"SystemCapability.Window.WindowManagerLite", WINDOW_WINDOW_MANAGER_LITE},
|
||||
{"SystemCapability.Driver.DeviceManager.Extension", DRIVER_DEVICEMANAGER_EXTENSION},
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -554,4 +556,4 @@ const static SyscapWithNum g_arraySyscap[] = {
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif // _SYSCAP_DEFINE_H
|
||||
#endif // SYSCAP_DEFINE_H
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _CREATE_PCID_H
|
||||
#define _CREATE_PCID_H
|
||||
#ifndef CREATE_PCID_H
|
||||
#define CREATE_PCID_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct ProductCompatibilityID {
|
||||
uint8_t osSyscap[OS_SYSCAP_BYTES];
|
||||
} PCIDMain;
|
||||
|
||||
typedef struct pcidHeader {
|
||||
typedef struct PcidHeader {
|
||||
uint16_t apiVersion : 15;
|
||||
uint16_t apiVersionType : 1;
|
||||
uint16_t systemType : 3;
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef struct ProductCompatibilityID {
|
||||
uint8_t osSyscap[OS_SYSCAP_BYTES];
|
||||
} PCIDMain;
|
||||
|
||||
static const char *pcidPath = "/system/etc/PCID.sc";
|
||||
static const char *g_pcidPath = "/system/etc/PCID.sc";
|
||||
|
||||
static void FreeContextBuffer(char *contextBuffer)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ bool EncodeOsSyscap(char *output, int len)
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = GetFileContext(pcidPath, &contextBuffer, &bufferLen);
|
||||
ret = GetFileContext(g_pcidPath, &contextBuffer, &bufferLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : /system/etc/PCID.sc\n");
|
||||
return false;
|
||||
@@ -160,7 +160,7 @@ bool EncodePrivateSyscap(char **output, int *outputLen)
|
||||
char *outputStr = NULL;
|
||||
uint32_t bufferLen;
|
||||
|
||||
ret = GetFileContext(pcidPath, &contextBuffer, &bufferLen);
|
||||
ret = GetFileContext(g_pcidPath, &contextBuffer, &bufferLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : /system/etc/PCID.sc\n");
|
||||
return false;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _SYSCAP_INTERFACE_H
|
||||
#define _SYSCAP_INTERFACE_H
|
||||
#ifndef SYSCAP_INTERFACE_H
|
||||
#define SYSCAP_INTERFACE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -76,4 +76,4 @@ int32_t FreeCompareError(CompareError *result);
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _SYSCAP_INTERFACE_H */
|
||||
#endif /* SYSCAP_INTERFACE_H */
|
||||
@@ -55,7 +55,7 @@ struct SystemCapabilityAsyncContext {
|
||||
int status = 0;
|
||||
};
|
||||
|
||||
static char* getSystemCapability()
|
||||
static char* GetSystemCapability()
|
||||
{
|
||||
bool retBool;
|
||||
int retError, priOutputLen, priCapArrayCnt, sumLen;
|
||||
@@ -179,7 +179,7 @@ napi_value QuerySystemCapability(napi_env env, napi_callback_info info)
|
||||
env, nullptr, resource,
|
||||
[](napi_env env, void* data) {
|
||||
SystemCapabilityAsyncContext *asyncContext = (SystemCapabilityAsyncContext *)data;
|
||||
char *syscapStr = getSystemCapability();
|
||||
char *syscapStr = GetSystemCapability();
|
||||
if (syscapStr != nullptr) {
|
||||
asyncContext->value = syscapStr;
|
||||
asyncContext->status = 0;
|
||||
@@ -248,7 +248,7 @@ static napi_module g_systemCapabilityModule = {
|
||||
/*
|
||||
* Module register function
|
||||
*/
|
||||
extern "C" __attribute__((constructor)) void systemCapabilityRegisterModule(void)
|
||||
extern "C" __attribute__((constructor)) void SystemCapabilityRegisterModule(void)
|
||||
{
|
||||
napi_module_register(&g_systemCapabilityModule);
|
||||
}
|
||||
|
||||
+17
-2
@@ -1,7 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// 首先需要通过requireInternal函数加载本模块
|
||||
const systemCapability = requireInternal('systemCapability');
|
||||
|
||||
// 这里定义了模块对外暴露的所有api
|
||||
export default {
|
||||
querySystemCapabilities: systemCapability.querySystemCapabilities
|
||||
}
|
||||
querySystemCapabilities: systemCapability.querySystemCapabilities
|
||||
};
|
||||
@@ -13,15 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "endian_internal.h"
|
||||
|
||||
#define B_L_SWAP16(A) ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8))
|
||||
#define B_L_SWAP32(A) ((((uint32_t)(A) & 0xff000000) >> 24) | (((uint32_t)(A) & 0x00ff0000) >> 8) | \
|
||||
(((uint32_t)(A) & 0x0000ff00) << 8) | (((uint32_t)(A) & 0x000000ff) << 24))
|
||||
|
||||
int32_t CheckEndian(void);
|
||||
static bool CheckEndian(void);
|
||||
|
||||
int32_t CheckEndian(void)
|
||||
static bool CheckEndian(void)
|
||||
{
|
||||
union {
|
||||
int32_t i;
|
||||
@@ -29,7 +30,7 @@ int32_t CheckEndian(void)
|
||||
} c;
|
||||
c.i = 0x12345678;
|
||||
|
||||
return (0x12 == c.s[0]);
|
||||
return (c.s[0] == 0x12);
|
||||
}
|
||||
|
||||
uint32_t HtonlInter(uint32_t h)
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ENDIAN_INTERNAL_H
|
||||
#define _ENDIAN_INTERNAL_H
|
||||
#ifndef ENDIAN_INTERNAL_H
|
||||
#define ENDIAN_INTERNAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -35,4 +35,4 @@ extern uint16_t NtohsInter(uint16_t n);
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ENDIAN_INTERNAL_H */
|
||||
#endif /* ENDIAN_INTERNAL_H */
|
||||
+2
-2
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
|
||||
char *outputpath = getcwd(curpath, sizeof(curpath));
|
||||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
static struct option longOptions[] = {
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"version", no_argument, 0, 'v' },
|
||||
{"RPCID", no_argument, 0, 'R' },
|
||||
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
int32_t flag = getopt_long(argc, argv, "hvRPC:edsi:o:", long_options, &optIndex);
|
||||
int32_t flag = getopt_long(argc, argv, "hvRPC:edsi:o:", longOptions, &optIndex);
|
||||
if (flag == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -335,7 +335,7 @@ FREE_SYSCAP_OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t CheckRpcidFormat(char *inputFile, char **Buffer, uint32_t *Len)
|
||||
static int32_t CheckRpcidFormat(char *inputFile, char **buffer, uint32_t *Len)
|
||||
{
|
||||
uint32_t bufferLen;
|
||||
uint16_t sysCaptype, sysCapLength;
|
||||
@@ -366,7 +366,7 @@ static int32_t CheckRpcidFormat(char *inputFile, char **Buffer, uint32_t *Len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
*Buffer = contextBuffer;
|
||||
*buffer = contextBuffer;
|
||||
*Len = bufferLen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _SYSCAP_CODEC_TEST_H
|
||||
#define _SYSCAP_CODEC_TEST_H
|
||||
#ifndef SYSCAP_CODEC_TEST_H
|
||||
#define SYSCAP_CODEC_TEST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -38,4 +38,4 @@ public:
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _SYSCAP_CODEC_TEST_H */
|
||||
#endif /* SYSCAP_CODEC_TEST_H */
|
||||
@@ -83,7 +83,8 @@ HWTEST_F(SyscapCodecTest, DecodeOsSyscap, TestSize.Level1)
|
||||
HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1)
|
||||
{
|
||||
char (*priOutput)[SINGLE_SYSCAP_LEN] = nullptr;
|
||||
char priSyscap[] = "Device.syscap1GEDR,Device.syscap2WREGW,Vendor.syscap3RGD,Vendor.syscap4RWEG,Vendor.syscap5REWGWE,";
|
||||
char priSyscap[] = "Device.syscap1GEDR,Device.syscap2WREGW,Vendor."
|
||||
"syscap3RGD,Vendor.syscap4RWEG,Vendor.syscap5REWGWE,";
|
||||
int decodePriCnt;
|
||||
char expectPriOutput001[] = "SystemCapability.Device.syscap1GEDR";
|
||||
char expectPriOutput002[] = "SystemCapability.Device.syscap2WREGW";
|
||||
|
||||
Reference in New Issue
Block a user