1 /* 2 * Copyright (c) 2022 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 OHOS_MOCK_IPC_SKELETON_H 17 #define OHOS_MOCK_IPC_SKELETON_H 18 19 #include "accesstoken_kit.h" 20 #include "iremote_object.h" 21 22 namespace OHOS { 23 class IPCSkeleton { 24 public: 25 IPCSkeleton() = default; 26 ~IPCSkeleton() = default; 27 28 // default max is 4, only if you need a customize value 29 static bool SetMaxWorkThreadNum(int maxThreadNum); 30 31 // join current thread into work loop. 32 static void JoinWorkThread(); 33 34 // remove current thread from work loop. 35 static void StopWorkThread(); 36 37 static pid_t GetCallingPid(); 38 39 static pid_t GetCallingUid(); 40 41 static std::string GetLocalDeviceID(); 42 43 static std::string GetCallingDeviceID(); 44 45 static bool IsLocalCalling(); 46 47 static IPCSkeleton &GetInstance(); 48 49 static sptr<IRemoteObject> GetContextObject(); 50 51 static bool SetContextObject(sptr<IRemoteObject> &object); 52 53 static int FlushCommands(IRemoteObject *object); 54 55 static std::string ResetCallingIdentity(); 56 57 static bool SetCallingIdentity(std::string &identity); 58 59 static void SetCallingUid(pid_t uid); 60 61 static uint32_t GetCallingTokenID(); 62 63 static void SetCallingTokenID(Security::AccessToken::AccessTokenID callerToken); 64 }; 65 } // namespace OHOS 66 #endif // OHOS_MOCK_IPC_SKELETON_H 67