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 
36   using OnUnregisteredCallback = common::OnceCallback<void()>;
37 
38   /**
39    * Unregister a service from L2CAP module. This operation cannot fail.
40    * All channels opened for this service will be invalidated.
41    *
42    * @param on_unregistered will be triggered when unregistration is complete
43    */
44   void Unregister(OnUnregisteredCallback on_unregistered, os::Handler* on_unregistered_handler);
45 
46   friend internal::FixedChannelServiceManagerImpl;
47 
48  private:
FixedChannelService(Cid cid,internal::FixedChannelServiceManagerImpl * manager,os::Handler * handler)49   FixedChannelService(Cid cid, internal::FixedChannelServiceManagerImpl* manager, os::Handler* handler)
50       : cid_(cid), manager_(manager), l2cap_layer_handler_(handler) {}
51   Cid cid_ = kInvalidCid;
52   internal::FixedChannelServiceManagerImpl* manager_ = nullptr;
53   os::Handler* l2cap_layer_handler_;
54   DISALLOW_COPY_AND_ASSIGN(FixedChannelService);
55 };
56 
57 }  // namespace classic
58 }  // namespace l2cap
59 }  // namespace bluetooth
60