1 /* 2 * Copyright (c) 2023 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 UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H 17 #define UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H 18 19 #include "accesstoken_kit.h" 20 #include "nativetoken_kit.h" 21 #include "token_setproc.h" 22 23 namespace OHOS::AAFwk { 24 class IsMockSaCall { 25 public: IsMockSaCallWithPermission()26 static void IsMockSaCallWithPermission() 27 { 28 uint64_t tokenId; 29 const char* perms[] = { 30 perms[0] = "ohos.permission.ACCESS_DLP_FILE", 31 perms[1] = "ohos.permission.CLEAN_APPLICATION_DATA", 32 perms[2] = "ohos.permission.CLEAN_BACKGROUND_PROCESSES", 33 perms[3] = "ohos.permission.GET_RUNNING_INFO", 34 perms[4] = "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", 35 perms[5] = "ohos.permission.MANAGE_MISSIONS", 36 perms[6] = "ohos.permission.RUNNING_STATE_OBSERVER", 37 perms[7] = "ohos.permission.SET_ABILITY_CONTROLLER", 38 perms[8] = "ohos.permission.UPDATE_CONFIGURATION", 39 perms[9] = "ohos.permission.INSTALL_BUNDLE", 40 perms[10] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", 41 perms[11] = "ohos.permission.START_INVISIBLE_ABILITY", 42 perms[12] = "ohos.permission.START_ABILITIES_FROM_BACKGROUND", 43 perms[13] = "ohos.permission.START_ABILIIES_FROM_BACKGROUND", 44 perms[14] = "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", 45 perms[15] = "ohos.permission.MANAGER_ABILITY_FROM_GATEWAY", 46 perms[16] = "ohos.permission.PROXY_AUTHORIZATION_URI", 47 perms[17] = "ohos.permission.EXEMPT_AS_CALLER", 48 perms[18] = "ohos.permission.EXEMPT_AS_TARGET", 49 perms[19] = "ohos.permission.PREPARE_APP_TERMINATE", 50 perms[20] = "ohos.permission.START_ABILITY_WITH_ANIMATION", 51 perms[21] = "ohos.permission.MANAGE_APP_BOOT_INTERNAL", 52 perms[22] = "ohos.permission.CONNECT_UI_EXTENSION_ABILITY", 53 perms[23] = "ohos.permission.START_RECENT_ABILITY" 54 }; 55 56 NativeTokenInfoParams infoInstance = { 57 .dcapsNum = 0, 58 .permsNum = static_cast<int32_t>(sizeof(perms)/sizeof(perms[0])), 59 .aclsNum = 0, 60 .dcaps = nullptr, 61 .perms = perms, 62 .acls = nullptr, 63 .aplStr = "system_core", 64 }; 65 infoInstance.processName = "distributedsched"; 66 tokenId = GetAccessTokenId(&infoInstance); 67 SetSelfTokenID(tokenId); 68 Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); 69 } 70 }; 71 } // namespace OHOS::AAFwk 72 #endif // UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H