Home | History | Annotate | Download | only in btservice
      1 /*
      2  * Copyright (C) 2012 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     public Object Clone() throws CloneNotSupportedException {
     44         throw new CloneNotSupportedException();
     45     }
     46 
     47     void sspRequestCallback(byte[] address, byte[] name, int cod, int pairingVariant,
     48             int passkey) {
     49         mRemoteDevices.sspRequestCallback(address, name, cod, pairingVariant,
     50             passkey);
     51     }
     52     void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] val) {
     53         mRemoteDevices.devicePropertyChangedCallback(address, types, val);
     54     }
     55 
     56     void deviceFoundCallback(byte[] address) {
     57         mRemoteDevices.deviceFoundCallback(address);
     58     }
     59 
     60     void pinRequestCallback(byte[] address, byte[] name, int cod) {
     61         mRemoteDevices.pinRequestCallback(address, name, cod);
     62     }
     63 
     64     void bondStateChangeCallback(int status, byte[] address, int newState) {
     65         mBondStateMachine.bondStateChangeCallback(status, address, newState);
     66     }
     67 
     68     void aclStateChangeCallback(int status, byte[] address, int newState) {
     69 		mRemoteDevices.aclStateChangeCallback(status, address, newState);
     70     }
     71 
     72     void stateChangeCallback(int status) {
     73         mAdapterStateMachine.stateChangeCallback(status);
     74     }
     75 
     76     void discoveryStateChangeCallback(int state) {
     77         mAdapterProperties.discoveryStateChangeCallback(state);
     78     }
     79 
     80     void adapterPropertyChangedCallback(int[] types, byte[][] val) {
     81         mAdapterProperties.adapterPropertyChangedCallback(types, val);
     82     }
     83 
     84 }
     85