1 /*
2 * Copyright (c) 2024 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 "common_fuzzer.h"
17
18 #include <system_ability_definition.h>
19
20 #define protected public
21 #define private public
22 #include "edm_ipc_interface_code.h"
23 #include "enterprise_device_mgr_ability.h"
24 #include "element_name.h"
25 #undef protected
26 #undef private
27 #include "func_code.h"
28 #include "parcel.h"
29 #include "utils.h"
30
31 namespace OHOS {
32 namespace EDM {
OnRemoteRequestFuzzerTest(uint32_t code,const uint8_t * data,size_t size)33 void CommonFuzzer::OnRemoteRequestFuzzerTest(uint32_t code, const uint8_t* data, size_t size)
34 {
35 TEST::Utils::SetEdmInitialEnv();
36 sptr<EnterpriseDeviceMgrAbility> enterpriseDeviceMgrAbility = EnterpriseDeviceMgrAbility::GetInstance();
37 enterpriseDeviceMgrAbility->OnStart();
38 AppExecFwk::ElementName admin;
39 admin.bundleName_ = "com.example.edmtest";
40 admin.abilityName_ = "com.example.edmtest.EnterpriseAdminAbility";
41
42 MessageParcel parcel;
43 parcel.WriteInterfaceToken(IEnterpriseDeviceMgr::GetDescriptor());
44 parcel.WriteParcelable(&admin);
45 parcel.WriteBuffer(data, size);
46
47 MessageParcel reply;
48 MessageOption option;
49
50 enterpriseDeviceMgrAbility->OnRemoteRequest(code, parcel, reply, option);
51 TEST::Utils::ResetTokenTypeAndUid();
52 }
53 } // namespace EDM
54 } // namespace OHOS