1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "sys_event_callback_ohos_test.h"
17
18 #include "string_util.h"
19
20 namespace OHOS {
21 namespace HiviewDFX {
U16String2String(std::u16string source)22 static std::string U16String2String(std::u16string source)
23 {
24 std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
25 return converter.to_bytes(source);
26 }
27
Handle(const std::u16string & domain,const std::u16string & eventName,uint32_t eventType,const std::u16string & eventDetail)28 void SysEventCallbackOhosTest::Handle(const std::u16string& domain, const std::u16string& eventName, uint32_t eventType,
29 const std::u16string& eventDetail)
30 {
31 printf("domain %s.\n", U16String2String(domain).c_str());
32 printf("eventName %s.\n", U16String2String(eventName).c_str());
33 printf("eventType %u.\n", eventType);
34 printf("eventDetail %s.\n", U16String2String(eventDetail).c_str());
35 }
36 } // namespace HiviewDFX
37 } // namespace OHOS