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 TOKEN_SYNC_MANAGER_SERVICE_H 17 #define TOKEN_SYNC_MANAGER_SERVICE_H 18 19 #include <string> 20 21 #include "event_handler.h" 22 #include "hap_token_info_for_sync_parcel.h" 23 #include "iremote_object.h" 24 #include "nocopyable.h" 25 #include "singleton.h" 26 #include "system_ability.h" 27 #include "token_sync_event_handler.h" 28 #include "token_sync_manager_stub.h" 29 30 namespace OHOS { 31 namespace Security { 32 namespace AccessToken { 33 enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; 34 class TokenSyncManagerService final : public SystemAbility, public TokenSyncManagerStub { 35 DECLARE_DELAYED_SINGLETON(TokenSyncManagerService); 36 DECLEAR_SYSTEM_ABILITY(TokenSyncManagerService); 37 38 public: 39 void OnStart() override; 40 void OnStop() override; 41 42 std::shared_ptr<TokenSyncEventHandler> GetSendEventHandler() const; 43 std::shared_ptr<TokenSyncEventHandler> GetRecvEventHandler() const; 44 int GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID) override; 45 int DeleteRemoteHapTokenInfo(AccessTokenID tokenID) override; 46 int UpdateRemoteHapTokenInfo(const HapTokenInfoForSync& tokenInfo) override; 47 48 private: 49 bool Initialize(); 50 51 std::shared_ptr<AppExecFwk::EventRunner> sendRunner_; 52 std::shared_ptr<AppExecFwk::EventRunner> recvRunner_; 53 std::shared_ptr<TokenSyncEventHandler> sendHandler_; 54 std::shared_ptr<TokenSyncEventHandler> recvHandler_; 55 ServiceRunningState state_; 56 }; 57 } // namespace AccessToken 58 } // namespace Security 59 } // namespace OHOS 60 #endif // TOKEN_SYNC_MANAGER_SERVICE_H 61