• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "dynamic_icon_info.h"
17 
18 #include <fcntl.h>
19 #include <unistd.h>
20 
21 #include "app_log_wrapper.h"
22 #include "parcel_macro.h"
23 #include "string_ex.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)27 bool DynamicIconInfo::ReadFromParcel(Parcel &parcel)
28 {
29     std::u16string bundleNameVal;
30     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, bundleNameVal);
31     bundleName = Str16ToStr8(bundleNameVal);
32     std::u16string moduleNameVal;
33     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, moduleNameVal);
34     moduleName = Str16ToStr8(moduleNameVal);
35     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, userId);
36     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appIndex);
37     return true;
38 }
39 
Marshalling(Parcel & parcel) const40 bool DynamicIconInfo::Marshalling(Parcel &parcel) const
41 {
42     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
43     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
44     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, userId);
45     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appIndex);
46     return true;
47 }
48 
Unmarshalling(Parcel & parcel)49 DynamicIconInfo *DynamicIconInfo::Unmarshalling(Parcel &parcel)
50 {
51     DynamicIconInfo *info = new (std::nothrow) DynamicIconInfo();
52     if (info && !info->ReadFromParcel(parcel)) {
53         APP_LOGW("read from parcel failed");
54         delete info;
55         info = nullptr;
56     }
57     return info;
58 }
59 } // OHOS
60 } // AppExecFwk
61