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 DATASHARE_STUB_IMPL_H 17 #define DATASHARE_STUB_IMPL_H 18 19 #include "datashare_stub.h" 20 #include "datashare_ext_ability.h" 21 22 namespace OHOS { 23 namespace DataShare { 24 class TelephonyDataShareStubImpl : public DataShareStub { 25 public: TelephonyDataShareStubImpl()26 TelephonyDataShareStubImpl() {} ~TelephonyDataShareStubImpl()27 virtual ~TelephonyDataShareStubImpl() {}; 28 29 int Insert(const Uri &uri, const DataShareValuesBucket &value) override; 30 int Update(const Uri &uri, const DataSharePredicates &predicates, 31 const DataShareValuesBucket &value) override; 32 int Delete(const Uri &uri, const DataSharePredicates &predicates) override; 33 std::shared_ptr<DataShareResultSet> Query(const Uri &uri, const DataSharePredicates &predicates, 34 std::vector<std::string> &columns, DatashareBusinessError &businessError) override; 35 int BatchInsert(const Uri &uri, const std::vector<DataShareValuesBucket> &values) override; 36 37 std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; 38 int OpenFile(const Uri &uri, const std::string &mode) override; 39 int OpenRawFile(const Uri &uri, const std::string &mode) override; 40 std::string GetType(const Uri &uri) override; 41 bool RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override; 42 bool UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override; 43 bool NotifyChange(const Uri &uri) override; 44 Uri NormalizeUri(const Uri &uri) override; 45 Uri DenormalizeUri(const Uri &uri) override; 46 47 void SetOpKeyAbility(std::shared_ptr<DataShareExtAbility> extension); 48 void SetPdpProfileAbility(std::shared_ptr<DataShareExtAbility> extension); 49 void SetSimAbility(std::shared_ptr<DataShareExtAbility> extension); 50 void SetSmsMmsAbility(std::shared_ptr<DataShareExtAbility> extension); 51 52 private: 53 std::shared_ptr<DataShareExtAbility> GetOwner(const Uri &uri); 54 std::shared_ptr<DataShareExtAbility> GetTelephonyDataAbility(); 55 std::shared_ptr<DataShareExtAbility> GetOpKeyAbility(); 56 std::shared_ptr<DataShareExtAbility> GetPdpProfileAbility(); 57 std::shared_ptr<DataShareExtAbility> GetSimAbility(); 58 std::shared_ptr<DataShareExtAbility> GetSmsMmsAbility(); 59 60 private: 61 std::shared_ptr<DataShareExtAbility> telephonyDataAbility_ = nullptr; 62 std::shared_ptr<DataShareExtAbility> opKeyAbility_ = nullptr; 63 std::shared_ptr<DataShareExtAbility> pdpProfileAbility_ = nullptr; 64 std::shared_ptr<DataShareExtAbility> simAbility_ = nullptr; 65 std::shared_ptr<DataShareExtAbility> smsMmsAbility_ = nullptr; 66 std::mutex opKeyMutex_; 67 std::mutex pdpProfileMutex_; 68 std::mutex simMutex_; 69 std::mutex smsMmsMutex_; 70 }; 71 } // namespace DataShare 72 } // namespace OHOS 73 #endif // DATASHARE_STUB_IMPL_H