• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "feature_stub_impl.h"
16 namespace OHOS::DistributedData {
FeatureStubImpl(std::shared_ptr<FeatureSystem::Feature> feature)17 FeatureStubImpl::FeatureStubImpl(std::shared_ptr<FeatureSystem::Feature> feature)
18     : featureImpl_(std::move(feature))
19 {
20 }
21 
~FeatureStubImpl()22 FeatureStubImpl::~FeatureStubImpl()
23 {
24     featureImpl_ = nullptr;
25 }
26 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int FeatureStubImpl::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
28 {
29     if (featureImpl_ == nullptr) {
30         return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
31     }
32     return featureImpl_->OnRemoteRequest(code, data, reply);
33 }
34 
OnInitialize()35 int32_t FeatureStubImpl::OnInitialize()
36 {
37     if (featureImpl_ == nullptr) {
38         return -1;
39     }
40     return featureImpl_->OnInitialize();
41 }
42 
OnAppExit(pid_t uid,pid_t pid,uint32_t tokenId,const std::string & bundleName)43 int32_t FeatureStubImpl::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName)
44 {
45     if (featureImpl_ == nullptr) {
46         return -1;
47     }
48     return featureImpl_->OnAppExit(uid, pid, tokenId, bundleName);
49 }
50 
OnAppUninstall(const std::string & bundleName,int32_t user,int32_t index,uint32_t tokenId)51 int32_t FeatureStubImpl::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index, uint32_t tokenId)
52 {
53     if (featureImpl_ == nullptr) {
54         return -1;
55     }
56     return featureImpl_->OnAppUninstall(bundleName, user, index, tokenId);
57 }
58 
ResolveAutoLaunch(const std::string & identifier,DistributedDB::AutoLaunchParam & param)59 int32_t FeatureStubImpl::ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam &param)
60 {
61     if (featureImpl_ == nullptr) {
62         return -1;
63     }
64     return featureImpl_->ResolveAutoLaunch(identifier, param);
65 }
66 
OnUserChange(uint32_t code,const std::string & user,const std::string & account)67 int32_t FeatureStubImpl::OnUserChange(uint32_t code, const std::string &user, const std::string &account)
68 {
69     if (featureImpl_ == nullptr) {
70         return -1;
71     }
72     return featureImpl_->OnUserChange(code, user, account);
73 }
74 
Online(const std::string & device)75 int32_t FeatureStubImpl::Online(const std::string &device)
76 {
77     if (featureImpl_ == nullptr) {
78         return -1;
79     }
80     return featureImpl_->Online(device);
81 }
82 
Offline(const std::string & device)83 int32_t FeatureStubImpl::Offline(const std::string &device)
84 {
85     if (featureImpl_ == nullptr) {
86         return -1;
87     }
88     return featureImpl_->Offline(device);
89 }
90 
OnReady(const std::string & device)91 int32_t FeatureStubImpl::OnReady(const std::string &device)
92 {
93     if (featureImpl_ == nullptr) {
94         return -1;
95     }
96     return featureImpl_->OnReady(device);
97 }
98 }