Home | History | Annotate | Download | only in btservice
      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 final class JniCallbacks {
     20 
     21     private RemoteDevices mRemoteDevices;
     22     private AdapterProperties mAdapterProperties;
     23     private AdapterState mAdapterStateMachine;
     24     private BondStateMachine mBondStateMachine;
     25 
     26     JniCallbacks(AdapterState adapterStateMachine,AdapterProperties adapterProperties) {
     27         mAdapterStateMachine = adapterStateMachine;
     28         mAdapterProperties = adapterProperties;
     29     }
     30 
     31     void init(BondStateMachine bondStateMachine, RemoteDevices remoteDevices) {
     32         mRemoteDevices = remoteDevices;
     33         mBondStateMachine = bondStateMachine;
     34     }
     35 
     36     void cleanup() {
     37         mRemoteDevices = null;
     38         mAdapterProperties = null;
     39         mAdapterStateMachine = null;
     40         mBondStateMachine = null;
     41     }
     42 
     43     @Override
     44     public Object clone() throws CloneNotSupportedException {
     45         throw new CloneNotSupportedException();
     46     }
     47 
     48     void sspRequestCallback(byte[] address, byte[] name, int cod, int pairingVariant,
     49             int passkey) {
     50         mBondStateMachine.sspRequestCallback(address, name, cod, pairingVariant,
     51             passkey);
     52     }
     53     void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] val) {
     54         mRemoteDevices.devicePropertyChangedCallback(address, types, val);
     55     }
     56 
     57     void deviceFoundCallback(byte[] address) {
     58         mRemoteDevices.deviceFoundCallback(address);
     59     }
     60 
     61     void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) {
     62         mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits);
     63     }
     64 
     65     void bondStateChangeCallback(int status, byte[] address, int newState) {
     66         mBondStateMachine.bondStateChangeCallback(status, address, newState);
     67     }
     68 
     69     void aclStateChangeCallback(int status, byte[] address, int newState) {
     70         mRemoteDevices.aclStateChangeCallback(status, address, newState);
     71     }
     72 
     73     void stateChangeCallback(int status) {
     74         mAdapterStateMachine.stateChangeCallback(status);
     75     }
     76 
     77     void discoveryStateChangeCallback(int state) {
     78         mAdapterProperties.discoveryStateChangeCallback(state);
     79     }
     80 
     81     void adapterPropertyChangedCallback(int[] types, byte[][] val) {
     82         mAdapterProperties.adapterPropertyChangedCallback(types, val);
     83     }
     84 
     85 }
     86