1 /* 2 * Copyright (c) 2022-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 #ifndef PRIVACY_MANAGER_STUB_H 17 #define PRIVACY_MANAGER_STUB_H 18 19 #include <map> 20 21 #include "i_privacy_manager.h" 22 #include "iremote_stub.h" 23 #include "nocopyable.h" 24 25 namespace OHOS { 26 namespace Security { 27 namespace AccessToken { 28 class PrivacyManagerStub : public IRemoteStub<IPrivacyManager> { 29 public: 30 PrivacyManagerStub(); 31 virtual ~PrivacyManagerStub() = default; 32 33 int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 34 35 private: 36 void AddPermissionUsedRecordInner(MessageParcel& data, MessageParcel& reply); 37 void SetPermissionUsedRecordToggleStatusInner(MessageParcel& data, MessageParcel& reply); 38 void GetPermissionUsedRecordToggleStatusInner(MessageParcel& data, MessageParcel& reply); 39 void StartUsingPermissionInner(MessageParcel& data, MessageParcel& reply); 40 void StartUsingPermissionCallbackInner(MessageParcel& data, MessageParcel& reply); 41 void StopUsingPermissionInner(MessageParcel& data, MessageParcel& reply); 42 void RemovePermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); 43 void GetPermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); 44 void GetPermissionUsedRecordsAsyncInner(MessageParcel& data, MessageParcel& reply); 45 void RegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply); 46 void UnRegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply); 47 void IsAllowedUsingPermissionInner(MessageParcel& data, MessageParcel& reply); 48 #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE 49 void RegisterSecCompEnhanceInner(MessageParcel& data, MessageParcel& reply); 50 void UpdateSecCompEnhanceInner(MessageParcel& data, MessageParcel& reply); 51 void GetSecCompEnhanceInner(MessageParcel& data, MessageParcel& reply); 52 void GetSpecialSecCompEnhanceInner(MessageParcel& data, MessageParcel& reply); 53 bool IsSecCompServiceCalling(); 54 #endif 55 void GetPermissionUsedTypeInfosInner(MessageParcel& data, MessageParcel& reply); 56 void SetMutePolicyInner(MessageParcel& data, MessageParcel& reply); 57 void SetHapWithFGReminderInner(MessageParcel& data, MessageParcel& reply); 58 bool IsPrivilegedCalling() const; 59 bool IsAccessTokenCalling() const; 60 bool IsSystemAppCalling() const; 61 bool VerifyPermission(const std::string& permission) const; 62 static const int32_t ACCESSTOKEN_UID = 3020; 63 #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE 64 AccessTokenID secCompTokenId_ = 0; 65 #endif 66 void SetPrivacyFuncInMap(); 67 #ifndef ATM_BUILD_VARIANT_USER_ENABLE 68 static const int32_t ROOT_UID = 0; 69 #endif 70 71 using RequestType = void (PrivacyManagerStub::*)(MessageParcel &data, MessageParcel &reply); 72 std::map<uint32_t, RequestType> requestMap_; 73 }; 74 } // namespace AccessToken 75 } // namespace Security 76 } // namespace OHOS 77 #endif // PRIVACY_MANAGER_STUB_H 78