Files
chengxiang 0fce1961cd Description:add startremoteability interface
Team:OTHERS
Feature or Bugfix:Bugfix
Binary Source:No
PrivateCode(Yes/No):No

Change-Id: Id1ab4f680b6dcea209ce3bdca568adc9f90ac1bc
ChangeID:13809485
2021-04-26 11:09:28 +08:00

86 lines
2.3 KiB
C
Executable File

/*
* Copyright (c) 2020 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.
*/
#include "dmslite.h"
#include "dmsfwk_interface.h"
#include "dmslite_log.h"
#include "ohos_init.h"
#include "samgr_lite.h"
#define STACK_SIZE 0x1000
#define QUEUE_SIZE 20
#define EMPTY_SERVICE_NAME ""
static const char *GetName(Service *service);
static BOOL Initialize(Service *service, Identity identity);
static BOOL MessageHandle(Service *service, Request *request);
static TaskConfig GetTaskConfig(Service *service);
static DistributedService g_distributedService = {
.GetName = GetName,
.Initialize = Initialize,
.MessageHandle = MessageHandle,
.GetTaskConfig = GetTaskConfig
};
static const char *GetName(Service *service)
{
if (service == NULL) {
return EMPTY_SERVICE_NAME;
}
return DISTRIBUTED_SCHEDULE_SERVICE;
}
static BOOL Initialize(Service *service, Identity identity)
{
if (service == NULL) {
return FALSE;
}
((DistributedService*) service)->identity = identity;
return TRUE;
}
static BOOL MessageHandle(Service *service, Request *request)
{
if (request == NULL || service == NULL) {
return FALSE;
}
/* process for a specific service-level msgId can be added below */
switch (request->msgId) {
default: {
HILOGW("[Unkonwn msgId = %d]", request->msgId);
break;
}
}
return TRUE;
}
static TaskConfig GetTaskConfig(Service *service)
{
TaskConfig config = {LEVEL_HIGH, PRI_NORMAL, STACK_SIZE, QUEUE_SIZE, SINGLE_TASK};
return config;
}
static void Init()
{
BOOL result = SAMGR_GetInstance()->RegisterService((Service *)&g_distributedService);
HILOGI("[dms service start %s]", result ? "success" : "failed");
}
SYS_SERVICE_INIT(Init);