1 /* 2 * Copyright (c) 2022-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 EDM_UNIT_TEST_UTILS_H 17 #define EDM_UNIT_TEST_UTILS_H 18 19 #include <string> 20 #include <unistd.h> 21 #include "accesstoken_kit.h" 22 #include "nativetoken_kit.h" 23 #include "token_setproc.h" 24 25 namespace OHOS { 26 namespace EDM { 27 namespace TEST { 28 class Utils { 29 public: 30 static constexpr int32_t EDM_UID = 3057; 31 static constexpr int32_t ROOT_UID = 0; 32 static void ExecCmdSync(const std::string &cmd); 33 static void SetNativeTokenTypeAndPermissions(const char* permissions[], int size); 34 static void SetEdmInitialEnv(); 35 static void ResetTokenTypeAndUid(); 36 static bool GetEdmServiceState(); 37 static bool IsOriginalUTEnv(); 38 static void SetEdmServiceEnable(); 39 static void SetEdmServiceDisable(); 40 41 private: 42 static uint64_t selfTokenId_; 43 }; 44 } // namespace TEST 45 } // namespace EDM 46 } // namespace OHOS 47 #endif // EDM_UNIT_TEST_UTILS_H 48