• 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 #ifndef NOTIFYCHANGE_FUZZER_H
17 #define NOTIFYCHANGE_FUZZER_H
18 
19 #define FUZZ_PROJECT_NAME "medialibrarynotification_fuzzer"
20 
21 #include "notify_info_inner.h"
22 #include "media_datashare_stub_impl.h"
23 #include "media_log.h"
24 #include "i_observer_manager_interface.h"
25 #include "media_observer_manager.h"
26 #include "notify_register_permission.h"
27 #include "observer_callback_recipient.h"
28 
29 namespace OHOS {
30 namespace Media {
31 const std::vector<Notification::AssetRefreshOperation> ASSET_REFRESH_OPERATION = {
32     Notification::ASSET_OPERATION_UNDEFINED,
33     Notification::ASSET_OPERATION_ADD,
34     Notification::ASSET_OPERATION_ADD_HIDDEN,
35     Notification::ASSET_OPERATION_ADD_TRASH,
36     Notification::ASSET_OPERATION_REMOVE,
37     Notification::ASSET_OPERATION_REMOVE_HIDDEN,
38     Notification::ASSET_OPERATION_REMOVE_TRASH,
39     Notification::ASSET_OPERATION_UPDATE_NORMAL,
40     Notification::ASSET_OPERATION_UPDATE_ADD_NORMAL,
41     Notification::ASSET_OPERATION_UPDATE_REMOVE_NORMAL,
42     Notification::ASSET_OPERATION_UPDATE_HIDDEN,
43     Notification::ASSET_OPERATION_UPDATE_ADD_HIDDEN,
44     Notification::ASSET_OPERATION_UPDATE_REMOVE_HIDDEN,
45     Notification::ASSET_OPERATION_UPDATE_TRASH,
46     Notification::ASSET_OPERATION_UPDATE_ADD_TRASH,
47     Notification::ASSET_OPERATION_UPDATE_REMOVE_TRASH,
48     Notification::ASSET_OPERATION_TRASH,
49     Notification::ASSET_OPERATION_UNTRASH,
50     Notification::ASSET_OPERATION_HIDDEN,
51     Notification::ASSET_OPERATION_UNHIDDEN,
52     Notification::ASSET_OPERATION_RECHECK,
53 };
54 class IRemoteObjectTest : public IRemoteObject {
55 public:
IRemoteObjectTest()56     IRemoteObjectTest() : IRemoteObject(u"mock_i_remote_object") {}
57 
~IRemoteObjectTest()58     ~IRemoteObjectTest() {}
59 
GetObjectRefCount()60     int32_t GetObjectRefCount() override
61     {
62         return 0;
63     }
64 
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)65     int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override
66     {
67         return 0;
68     }
69 
IsProxyObject()70     bool IsProxyObject() const override
71     {
72         return true;
73     }
74 
CheckObjectLegality()75     bool CheckObjectLegality() const override
76     {
77         return true;
78     }
79 
AddDeathRecipient(const sptr<DeathRecipient> & recipient)80     bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override
81     {
82         return true;
83     }
84 
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)85     bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override
86     {
87         return true;
88     }
89 
Marshalling(Parcel & parcel)90     bool Marshalling(Parcel &parcel) const override
91     {
92         return true;
93     }
94 
AsInterface()95     sptr<IRemoteBroker> AsInterface() override
96     {
97         return nullptr;
98     }
99 
Dump(int fd,const std::vector<std::u16string> & args)100     int Dump(int fd, const std::vector<std::u16string> &args) override
101     {
102         return 0;
103     }
104 
GetObjectDescriptor()105     std::u16string GetObjectDescriptor() const
106     {
107         std::u16string descriptor = std::u16string();
108         return descriptor;
109     }
110 };
111 
112 class IDataAbilityObserverTest : public AAFwk::DataAbilityObserverStub {
113 public:
IDataAbilityObserverTest()114     IDataAbilityObserverTest() {}
~IDataAbilityObserverTest()115     ~IDataAbilityObserverTest() {}
OnChange()116     void OnChange() override {}
AsObject()117     sptr<IRemoteObject> AsObject() override
118     {
119         if (objectTest == nullptr) {
120             objectTest = new (std::nothrow)IRemoteObjectTest();
121         }
122         return objectTest;
123     }
124 
125 private:
126     sptr<IRemoteObjectTest> objectTest;
127 };
128 
129 } // namespace Media
130 } // namespace OHOS
131 #endif