• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 "message_parcel.h"
17 
18 namespace OHOS {
19 namespace {
20 bool g_bgTaskFwkAbnormalWriteRemoteObjectFlag = true;
21 bool g_bgTaskFwkAbnormalReadRemoteObjectFlag = true;
22 bool g_bgTaskFwkAbnormalWriteInterfaceTokenFlag = true;
23 bool g_bgTaskFwkAbnormalReadInterfaceTokenFlag = true;
24 bool g_bgTaskFwkAbnormalWriteString16Flag = true;
25 bool g_bgTaskFwkAbnormalReadInt32WithParamFlag = true;
26 bool g_bgTaskFwkAbnormalWriteInt32WithParamFlag = true;
27 bool g_bgTaskFwkAbnormalWriteParcelableFlag = true;
28 bool g_bgTaskFwkAbnormalWriteStringFlag = true;
29 bool g_bgTaskFwkAbnormalWriteUint32Flag = true;
30 bool g_bgTaskFwkAbnormalReadInt32Flag = true;
31 }
32 
BgTaskFwkAbnormalSetWriteRemoteObjectFlag(bool flag)33 void BgTaskFwkAbnormalSetWriteRemoteObjectFlag(bool flag)
34 {
35     g_bgTaskFwkAbnormalWriteRemoteObjectFlag = flag;
36 }
37 
BgTaskFwkAbnormalSetWriteReadRemoteObjectFlag(bool flag)38 void BgTaskFwkAbnormalSetWriteReadRemoteObjectFlag(bool flag)
39 {
40     g_bgTaskFwkAbnormalReadRemoteObjectFlag = flag;
41 }
42 
BgTaskFwkAbnormalSetWriteInterfaceTokenFlag(bool flag)43 void BgTaskFwkAbnormalSetWriteInterfaceTokenFlag(bool flag)
44 {
45     g_bgTaskFwkAbnormalWriteInterfaceTokenFlag = flag;
46 }
47 
BgTaskFwkAbnormalSetReadInterfaceTokenFlag(bool flag)48 void BgTaskFwkAbnormalSetReadInterfaceTokenFlag(bool flag)
49 {
50     g_bgTaskFwkAbnormalReadInterfaceTokenFlag = flag;
51 }
52 
BgTaskFwkAbnormalSetWriteString16Flag(bool flag)53 void BgTaskFwkAbnormalSetWriteString16Flag(bool flag)
54 {
55     g_bgTaskFwkAbnormalWriteString16Flag = flag;
56 }
57 
BgTaskFwkAbnormalSetWriteReadInt32WithParamFlag(bool flag)58 void BgTaskFwkAbnormalSetWriteReadInt32WithParamFlag(bool flag)
59 {
60     g_bgTaskFwkAbnormalReadInt32WithParamFlag = flag;
61 }
62 
BgTaskFwkAbnormalSetWriteInt32WithParamFlag(bool flag)63 void BgTaskFwkAbnormalSetWriteInt32WithParamFlag(bool flag)
64 {
65     g_bgTaskFwkAbnormalWriteInt32WithParamFlag = flag;
66 }
67 
BgTaskFwkAbnormalSetWriteParcelableFlag(bool flag)68 void BgTaskFwkAbnormalSetWriteParcelableFlag(bool flag)
69 {
70     g_bgTaskFwkAbnormalWriteParcelableFlag = flag;
71 }
72 
BgTaskFwkAbnormalSetWriteStringFlag(bool flag)73 void BgTaskFwkAbnormalSetWriteStringFlag(bool flag)
74 {
75     g_bgTaskFwkAbnormalWriteStringFlag = flag;
76 }
77 
BgTaskFwkAbnormalSetWriteUint32Flag(bool flag)78 void BgTaskFwkAbnormalSetWriteUint32Flag(bool flag)
79 {
80     g_bgTaskFwkAbnormalWriteUint32Flag = flag;
81 }
82 
BgTaskFwkAbnormalSetReadInt32Flag(bool flag)83 void BgTaskFwkAbnormalSetReadInt32Flag(bool flag)
84 {
85     g_bgTaskFwkAbnormalReadInt32Flag = flag;
86 }
87 
WriteRemoteObject(const sptr<IRemoteObject> & object)88 bool MessageParcel::WriteRemoteObject(const sptr<IRemoteObject> &object)
89 {
90     return g_bgTaskFwkAbnormalWriteRemoteObjectFlag;
91 }
92 
WriteInterfaceToken(std::u16string name)93 bool MessageParcel::WriteInterfaceToken(std::u16string name)
94 {
95     return g_bgTaskFwkAbnormalWriteInterfaceTokenFlag;
96 }
97 
ReadInterfaceToken()98 std::u16string MessageParcel::ReadInterfaceToken()
99 {
100     if (g_bgTaskFwkAbnormalReadInterfaceTokenFlag) {
101         return std::u16string(u"string");
102     }
103     return std::u16string();
104 }
105 
WriteString16(const std::u16string & value)106 bool Parcel::WriteString16(const std::u16string &value)
107 {
108     return g_bgTaskFwkAbnormalWriteString16Flag;
109 }
110 
ReadInt32(int32_t & value)111 bool Parcel::ReadInt32(int32_t &value)
112 {
113     return g_bgTaskFwkAbnormalReadInt32WithParamFlag;
114 }
115 
WriteInt32(int32_t value)116 bool Parcel::WriteInt32(int32_t value)
117 {
118     return g_bgTaskFwkAbnormalWriteInt32WithParamFlag;
119 }
120 
WriteParcelable(const Parcelable * object)121 bool Parcel::WriteParcelable(const Parcelable *object)
122 {
123     return g_bgTaskFwkAbnormalWriteParcelableFlag;
124 }
125 
WriteString(const std::string & value)126 bool Parcel::WriteString(const std::string &value)
127 {
128     return g_bgTaskFwkAbnormalWriteStringFlag;
129 }
130 
WriteUint32(uint32_t value)131 bool Parcel::WriteUint32(uint32_t value)
132 {
133     return g_bgTaskFwkAbnormalWriteUint32Flag;
134 }
135 
ReadInt32()136 int32_t Parcel::ReadInt32()
137 {
138     return 1;
139 }
140 } // namespace OHOS
141