1 
2 /*
3  * Copyright 2019 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #pragma once
18 
19 #include "common/callback.h"
20 #include "hci/address.h"
21 #include "l2cap/cid.h"
22 #include "os/handler.h"
23 
24 namespace bluetooth {
25 namespace l2cap {
26 namespace classic {
27 
28 namespace internal {
29 class FixedChannelServiceManagerImpl;
30 }  // namespace internal
31 
32 class FixedChannelService {
33  public:
34   FixedChannelService() = default;
35   FixedChannelService(const FixedChannelService&) = delete;
36   FixedChannelService& operator=(const FixedChannelService&) = delete;
37 
38   using OnUnregisteredCallback = common::OnceCallback<void()>;
39 
40   /**
41    * Unregister a service from L2CAP module. This operation cannot fail.
42    * All channels opened for this service will be invalidated.
43    *
44    * @param on_unregistered will be triggered when unregistration is complete
45    */
46   void Unregister(OnUnregisteredCallback on_unregistered, os::Handler* on_unregistered_handler);
47 
48   friend internal::FixedChannelServiceManagerImpl;
49 
50  private:
FixedChannelService(Cid cid,internal::FixedChannelServiceManagerImpl * manager,os::Handler * handler)51   FixedChannelService(Cid cid, internal::FixedChannelServiceManagerImpl* manager, os::Handler* handler)
52       : cid_(cid), manager_(manager), l2cap_layer_handler_(handler) {}
53   Cid cid_ = kInvalidCid;
54   internal::FixedChannelServiceManagerImpl* manager_ = nullptr;
55   os::Handler* l2cap_layer_handler_;
56 };
57 
58 }  // namespace classic
59 }  // namespace l2cap
60 }  // namespace bluetooth
61