• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 OHOS_AAFWK_PENDING_WANT_RECORD_H
17 #define OHOS_AAFWK_PENDING_WANT_RECORD_H
18 
19 #include <list>
20 #include <mutex>
21 
22 #include "iremote_object.h"
23 #include "refbase.h"
24 
25 #include "ability_record.h"
26 #include "want_sender_stub.h"
27 #include "sender_info.h"
28 #include "pending_want_key.h"
29 
30 namespace OHOS {
31 namespace AAFwk {
32 class PendingWantManager;
33 class PendingWantRecord : public WantSenderStub {
34 public:
35     static const int START_CANCELED = -96;
36 
37     PendingWantRecord();
38     PendingWantRecord(const std::shared_ptr<PendingWantManager> &pendingWantManager, int32_t uid,
39         const sptr<IRemoteObject> &callerToken, std::shared_ptr<PendingWantKey> key);
40     virtual ~PendingWantRecord();
41 
42     virtual void Send(SenderInfo &senderInfo);
43     virtual void RegisterCancelListener(const sptr<IWantReceiver> &receiver);
44     virtual void UnregisterCancelListener(const sptr<IWantReceiver> &receiver);
45 
46     virtual int32_t SenderInner(SenderInfo &senderInfo);
47 
48 public:
49     std::shared_ptr<PendingWantKey> GetKey();
50     int32_t GetUid() const;
51     void SetCallerUid(const int32_t callerUid);
52     void SetCanceled();
53     bool GetCanceled();
54     std::list<sptr<IWantReceiver>> GetCancelCallbacks();
55 
56 private:
57     std::weak_ptr<PendingWantManager> pendingWantManager_ = {};
58     int32_t uid_ = 0;
59     int32_t callerUid_ = 0;
60     sptr<IRemoteObject> callerToken_ = {};
61     bool canceled_ = false;
62     std::shared_ptr<PendingWantKey> key_ = {};
63     std::list<sptr<IWantReceiver>> mCancelCallbacks_ = {};
64     std::recursive_mutex lock_ = {};
65 };
66 }  // namespace AAFwk
67 }  // namespace OHOS
68 #endif  // OHOS_AAFWK_PENDING_WANT_RECORD_H