/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_AAFWK_DATA_ABILITY_RECORD_H #define OHOS_AAFWK_DATA_ABILITY_RECORD_H #include #include #include #include #include #include #include "ability_record.h" #include "data_ability_caller_recipient.h" namespace OHOS { namespace AAFwk { class DataAbilityRecord { public: explicit DataAbilityRecord(const AbilityRequest &req); virtual ~DataAbilityRecord(); public: int StartLoading(); int WaitForLoaded(std::mutex &mutex, const std::chrono::system_clock::duration &timeout); sptr GetScheduler(); int Attach(const sptr &scheduler); int OnTransitionDone(int state); int AddClient(const sptr &client, bool tryBind, bool isSystem); int RemoveClient(const sptr &client, bool isSystem); int RemoveClients(const std::shared_ptr &client = nullptr); size_t GetClientCount(const sptr &client = nullptr) const; int KillBoundClientProcesses(); const AbilityRequest &GetRequest() const; std::shared_ptr GetAbilityRecord(); sptr GetToken(); void Dump() const; void Dump(std::vector &info) const; private: using IRemoteObjectPtr = sptr; using AbilityRecordPtr = std::shared_ptr; struct ClientInfo { IRemoteObjectPtr client; bool tryBind; bool isSystem; }; void OnSchedulerDied(const wptr &remote); private: std::condition_variable_any loadedCond_{}; AbilityRequest request_{}; AbilityRecordPtr ability_{}; sptr scheduler_{}; std::list clients_{}; sptr callerDeathRecipient_; // caller binderDied Recipient }; } // namespace AAFwk } // namespace OHOS #endif // OHOS_AAFWK_DATA_ABILITY_RECORD_H