• 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)66     void bondStateChangeCallback(int status, byte[] address, int newState) {
67         mBondStateMachine.bondStateChangeCallback(status, address, newState);
68     }
69 
aclStateChangeCallback(int status, byte[] address, int newState, int hciReason)70     void aclStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
71         mRemoteDevices.aclStateChangeCallback(status, address, newState, hciReason);
72     }
73 
stateChangeCallback(int status)74     void stateChangeCallback(int status) {
75         mAdapterService.stateChangeCallback(status);
76     }
77 
discoveryStateChangeCallback(int state)78     void discoveryStateChangeCallback(int state) {
79         mAdapterProperties.discoveryStateChangeCallback(state);
80     }
81 
adapterPropertyChangedCallback(int[] types, byte[][] val)82     void adapterPropertyChangedCallback(int[] types, byte[][] val) {
83         mAdapterProperties.adapterPropertyChangedCallback(types, val);
84     }
85 
oobDataReceivedCallback(int transport, OobData oobData)86     void oobDataReceivedCallback(int transport, OobData oobData) {
87         mAdapterService.notifyOobDataCallback(transport, oobData);
88     }
89 
linkQualityReportCallback( long timestamp, int report_id, int rssi, int snr, int retransmission_count, int packets_not_receive_count, int negative_acknowledgement_count)90     void linkQualityReportCallback(
91             long timestamp,
92             int report_id,
93             int rssi,
94             int snr,
95             int retransmission_count,
96             int packets_not_receive_count,
97             int negative_acknowledgement_count) {
98         mAdapterService.linkQualityReportCallback(
99                 timestamp, report_id, rssi, snr, retransmission_count,
100                 packets_not_receive_count, negative_acknowledgement_count);
101     }
102 
103 }
104