1e1c44949Sopenharmony_ci/*
2e1c44949Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3e1c44949Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e1c44949Sopenharmony_ci * you may not use this file except in compliance with the License.
5e1c44949Sopenharmony_ci * You may obtain a copy of the License at
6e1c44949Sopenharmony_ci *
7e1c44949Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e1c44949Sopenharmony_ci *
9e1c44949Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e1c44949Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e1c44949Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e1c44949Sopenharmony_ci * See the License for the specific language governing permissions and
13e1c44949Sopenharmony_ci * limitations under the License.
14e1c44949Sopenharmony_ci */
15e1c44949Sopenharmony_ci
16e1c44949Sopenharmony_ci#define private public
17e1c44949Sopenharmony_ci#include "addcalltoken_fuzzer.h"
18e1c44949Sopenharmony_ci
19e1c44949Sopenharmony_ci#include "nativetoken_kit.h"
20e1c44949Sopenharmony_ci#include "token_setproc.h"
21e1c44949Sopenharmony_ci
22e1c44949Sopenharmony_ciusing namespace OHOS::Telephony;
23e1c44949Sopenharmony_cinamespace OHOS {
24e1c44949Sopenharmony_ciconst int PERMS_NUM = 6;
25e1c44949Sopenharmony_cistatic bool g_isInited = false;
26e1c44949Sopenharmony_ci
27e1c44949Sopenharmony_cibool IsServiceInited()
28e1c44949Sopenharmony_ci{
29e1c44949Sopenharmony_ci    if (!g_isInited) {
30e1c44949Sopenharmony_ci        DelayedSingleton<CallManagerService>::GetInstance()->OnStart();
31e1c44949Sopenharmony_ci        if (DelayedSingleton<CallManagerService>::GetInstance()->GetServiceRunningState() ==
32e1c44949Sopenharmony_ci            static_cast<int32_t>(CallManagerService::ServiceRunningState::STATE_RUNNING)) {
33e1c44949Sopenharmony_ci            g_isInited = true;
34e1c44949Sopenharmony_ci        }
35e1c44949Sopenharmony_ci    }
36e1c44949Sopenharmony_ci    return g_isInited;
37e1c44949Sopenharmony_ci}
38e1c44949Sopenharmony_ci
39e1c44949Sopenharmony_ciAddCallTokenFuzzer::AddCallTokenFuzzer()
40e1c44949Sopenharmony_ci{
41e1c44949Sopenharmony_ci    const char *perms[PERMS_NUM] = {
42e1c44949Sopenharmony_ci        "ohos.permission.PLACE_CALL",
43e1c44949Sopenharmony_ci        "ohos.permission.ANSWER_CALL",
44e1c44949Sopenharmony_ci        "ohos.permission.SET_TELEPHONY_STATE",
45e1c44949Sopenharmony_ci        "ohos.permission.GET_TELEPHONY_STATE",
46e1c44949Sopenharmony_ci        "ohos.permission.READ_CALL_LOG",
47e1c44949Sopenharmony_ci        "ohos.permission.WRITE_CALL_LOG",
48e1c44949Sopenharmony_ci    };
49e1c44949Sopenharmony_ci
50e1c44949Sopenharmony_ci    NativeTokenInfoParams testCallInfoParams = {
51e1c44949Sopenharmony_ci        .dcapsNum = 0,
52e1c44949Sopenharmony_ci        .permsNum = PERMS_NUM,
53e1c44949Sopenharmony_ci        .aclsNum = 0,
54e1c44949Sopenharmony_ci        .dcaps = nullptr,
55e1c44949Sopenharmony_ci        .perms = perms,
56e1c44949Sopenharmony_ci        .acls = nullptr,
57e1c44949Sopenharmony_ci        .processName = "call_fuzzer",
58e1c44949Sopenharmony_ci        .aplStr = "system_basic",
59e1c44949Sopenharmony_ci    };
60e1c44949Sopenharmony_ci    currentID_ = GetAccessTokenId(&testCallInfoParams);
61e1c44949Sopenharmony_ci    SetSelfTokenID(currentID_);
62e1c44949Sopenharmony_ci    Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
63e1c44949Sopenharmony_ci}
64e1c44949Sopenharmony_ci
65e1c44949Sopenharmony_ciAddCallTokenFuzzer::~AddCallTokenFuzzer() {}
66e1c44949Sopenharmony_ci} // namespace OHOS