• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012-2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.bluetooth.btservice;
18 
19 import android.bluetooth.OobData;
20 
21 final class JniCallbacks {
22 
23     private RemoteDevices mRemoteDevices;
24     private AdapterProperties mAdapterProperties;
25     private AdapterService mAdapterService;
26     private BondStateMachine mBondStateMachine;
27 
JniCallbacks(AdapterService adapterService, AdapterProperties adapterProperties)28     JniCallbacks(AdapterService adapterService, AdapterProperties adapterProperties) {
29         mAdapterService = adapterService;
30         mAdapterProperties = adapterProperties;
31     }
32 
init(BondStateMachine bondStateMachine, RemoteDevices remoteDevices)33     void init(BondStateMachine bondStateMachine, RemoteDevices remoteDevices) {
34         mRemoteDevices = remoteDevices;
35         mBondStateMachine = bondStateMachine;
36     }
37 
cleanup()38     void cleanup() {
39         mRemoteDevices = null;
40         mAdapterProperties = null;
41         mAdapterService = null;
42         mBondStateMachine = null;
43     }
44 
45     @Override
clone()46     public Object clone() throws CloneNotSupportedException {
47         throw new CloneNotSupportedException();
48     }
49 
sspRequestCallback(byte[] address, byte[] name, int cod, int pairingVariant, int passkey)50     void sspRequestCallback(byte[] address, byte[] name, int cod, int pairingVariant, int passkey) {
51         mBondStateMachine.sspRequestCallback(address, name, cod, pairingVariant, passkey);
52     }
53 
devicePropertyChangedCallback(byte[] address, int[] types, byte[][] val)54     void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] val) {
55         mRemoteDevices.devicePropertyChangedCallback(address, types, val);
56     }
57 
deviceFoundCallback(byte[] address)58     void deviceFoundCallback(byte[] address) {
59         mRemoteDevices.deviceFoundCallback(address);
60     }
61 
pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits)62     void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) {
63         mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits);
64     }
65 
bondStateChangeCallback(int status, byte[] address, int newState, int hciReason)66     void bondStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
67         mBondStateMachine.bondStateChangeCallback(status, address, newState, hciReason);
68     }
69 
addressConsolidateCallback(byte[] mainAddress, byte[] secondaryAddress)70     void addressConsolidateCallback(byte[] mainAddress, byte[] secondaryAddress) {
71         mRemoteDevices.addressConsolidateCallback(mainAddress, secondaryAddress);
72     }
73 
leAddressAssociateCallback(byte[] mainAddress, byte[] secondaryAddress)74     void leAddressAssociateCallback(byte[] mainAddress, byte[] secondaryAddress) {
75         mRemoteDevices.leAddressAssociateCallback(mainAddress, secondaryAddress);
76     }
77 
aclStateChangeCallback(int status, byte[] address, int newState, int transportLinkType, int hciReason)78     void aclStateChangeCallback(int status, byte[] address, int newState,
79             int transportLinkType, int hciReason) {
80         mRemoteDevices.aclStateChangeCallback(status, address, newState,
81                 transportLinkType, hciReason);
82     }
83 
stateChangeCallback(int status)84     void stateChangeCallback(int status) {
85         mAdapterService.stateChangeCallback(status);
86     }
87 
discoveryStateChangeCallback(int state)88     void discoveryStateChangeCallback(int state) {
89         mAdapterProperties.discoveryStateChangeCallback(state);
90     }
91 
adapterPropertyChangedCallback(int[] types, byte[][] val)92     void adapterPropertyChangedCallback(int[] types, byte[][] val) {
93         mAdapterProperties.adapterPropertyChangedCallback(types, val);
94     }
95 
oobDataReceivedCallback(int transport, OobData oobData)96     void oobDataReceivedCallback(int transport, OobData oobData) {
97         mAdapterService.notifyOobDataCallback(transport, oobData);
98     }
99 
linkQualityReportCallback( long timestamp, int report_id, int rssi, int snr, int retransmission_count, int packets_not_receive_count, int negative_acknowledgement_count)100     void linkQualityReportCallback(
101             long timestamp,
102             int report_id,
103             int rssi,
104             int snr,
105             int retransmission_count,
106             int packets_not_receive_count,
107             int negative_acknowledgement_count) {
108         mAdapterService.linkQualityReportCallback(
109                 timestamp, report_id, rssi, snr, retransmission_count,
110                 packets_not_receive_count, negative_acknowledgement_count);
111     }
112 
switchBufferSizeCallback(boolean is_low_latency_buffer_size)113     void switchBufferSizeCallback(boolean is_low_latency_buffer_size) {
114         mAdapterService.switchBufferSizeCallback(is_low_latency_buffer_size);
115     }
116 
switchCodecCallback(boolean is_low_latency_buffer_size)117     void switchCodecCallback(boolean is_low_latency_buffer_size) {
118         mAdapterService.switchCodecCallback(is_low_latency_buffer_size);
119     }
120 
121 }
122